All right, all right! Interim decision regarding qualified Object methods

Jonathan M Davis jmdavisProg at gmx.com
Thu Jul 12 14:27:06 PDT 2012


On Thursday, July 12, 2012 16:50:21 Steven Schveighoffer wrote:
> I can't really remember the last time I simply used obj1.opEquals(obj2) to
> do comparisons instead of obj1 == obj2 (which should do the right thing if
> obj1.opEquals(obj2) is valid). The code that relies on this is probably
> very rare.

It's almost certainly bad code anyway. The free function version of opEquals 
specifically does extra work to make equality checks correct and avoids some of 
the pitfalls that opEquals causes in Java (e.g. doing comparison in both 
directions if the types aren't identical). So, if we break that, it's probably 
a _good_ thing. And if they _really_ want to do that, that can still do it 
with their derived classes which define opEquals. They just can't do it with 
Object.

- Jonathan M Davis


More information about the Digitalmars-d mailing list