WAT: opCmp and opEquals woes

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 24 21:50:37 PDT 2014


On 7/23/2014 9:45 AM, H. S. Teoh via Digitalmars-d wrote:
> https://issues.dlang.org/show_bug.cgi?id=13179

Consider also:

http://www.reddit.com/r/programming/comments/2bl51j/programming_in_d_a_great_online_book_for_learning/cj75gm9

The current scheme breaks existing code - code that was formerly correct and 
working.

AAs don't make sense if the notion of == on members is invalid. AAs formerly 
required opCmp, and yes, opCmp could be constructed to give different results 
for opCmp==0 than ==, but I would expect such an object to not be used in an AA, 
again because it doesn't make sense.

Using the default generated opEquals for AAs may break code, such as the an AA 
of the structs in the parent post, but it seems unlikely that that code was 
correct anyway in an AA (as it would give erratic results).

Kenji's rebuttal https://issues.dlang.org/show_bug.cgi?id=13179#c2 is probably 
the best counter-argument, and I'd go with it if it didn't result in code breakage.


More information about the Digitalmars-d mailing list