www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Default opCmp() for classes

reply "Uwe Salomon" <post uwesalomon.de> writes:
Hello,

what exactly is the reason for the existence of a default opCmp() for  
classes? Every class that an opCmp() really makes sense for has to  
implement it anyways, and the others don't want to be compared i guess. If  
there weren't a standard implementation (or the standard would only throw  
an exception) this would help detecting programming errors. Or is the  
operator necessary for the AA-implementation?

Ciao
uwe
Apr 06 2005
next sibling parent Stewart Gordon <smjg_1998 yahoo.com> writes:
Uwe Salomon wrote:
 Hello,
 
 what exactly is the reason for the existence of a default opCmp() for  
 classes? Every class that an opCmp() really makes sense for has to 
 implement it anyways, and the others don't want to be compared i guess. 
 If there weren't a standard implementation (or the standard would only 
 throw an exception) this would help detecting programming errors. Or is 
 the operator necessary for the AA-implementation?

I'm not sure if anyone knows the original reason for putting it in. And several of us have been wanting to get rid of it for ages. digitalmars.D/10558 Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Apr 06 2005
prev sibling parent "Matthew" <admin.hat stlsoft.dot.org> writes:
"Uwe Salomon" <post uwesalomon.de> wrote in message
news:opsotlm9jm6yjbe6 sandmann.maerchenwald.net...
 Hello,

 what exactly is the reason for the existence of a default opCmp() for 
classes? Every class that an opCmp() really 
 makes sense for has to  implement it anyways, and the others don't want to be
compared i guess. If  there weren't a 
 standard implementation (or the standard would only throw  an exception) this
would help detecting programming errors. 
 Or is the  operator necessary for the AA-implementation?

I think you have it right. FWIW, it's a very unpopular feature.
Apr 06 2005