Why does Object.opEquals *exist*

Chris Nicholson-Sauls ibisbasenji at gmail.com
Thu Nov 9 06:29:17 PST 2006


Bill Baxter wrote:
> Anders F Björklund wrote:
> 
>> Kristian Kilpi wrote:
>>
>>> So the original question remains: why 'opEquals' returns int?
>>
>>
>>
>> Walter says it is for performance reason, when e.g. sorting...
>>
>> http://www.digitalmars.com/d/archives/digitalmars/D/bugs/7933.html
>>
>> --anders
> 
> 
> Thanks for the link.  Not sure how it matters when sorting, because then 
> you'd be using opCmp.  I'd certainly find the performance argument more 
> convincing with some actual performance measurements to back it up, but 
> oh well.  Much bigger fish to fry out there than the return value of opCmp.
> 
> --bb

The main use seems to be for AA's, along with toHash().  At least that's what I recall... 
been a good while since I trek'd through the internals.  Note, however, that yes it does 
hearken from the days before we had the current 'bool' type (ah yes, the days of 'bit') 
and it was indeed for performance reasons.

BUT, now that we have 'bool', I see no apparent reason why it /shouldn't/ be a bool.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list