Should opEquals be removed from object? (Was: Re: How to check

Stewart Gordon smjg_1998 at yahoo.com
Tue Aug 28 06:24:35 PDT 2007


"Sean Kelly" <sean at f4.ca> wrote in message
news:favmpt$fkr$1 at digitalmars.com...
> Robert Fraser wrote:
<snip>
>> All object.opEquals() is doing is invoking "is", so it's kind of tricking 
>> people who don't know/remember that == doesn't test for identity and 
>> theoretically (it'd probably be inlined, but still) slowing down code. 
>> What's the point?  Seems like it'd be better all around to get rid of it 
>> entirely.

To serve as a default equality test for classes that don't implement their 
own.

> opEquals needs to be in Object because it is used by the AA code. 
> However, it could be changed to simply throw an exception, thus requiring 
> users to override it.

What would the point of this be?  I don't see there being any such thing as 
there being a class with no concept of equality, not even that of being one 
and the same object.

Besides, as at least one person has already said, this does nothing for the 
original subject: the null reference checking problem.

Stewart.





More information about the Digitalmars-d mailing list