ProtoObject and comparison for equality and ordering

Mike Franklin slavo5150 at yahoo.com
Tue May 14 21:18:32 UTC 2019


On Tuesday, 14 May 2019 at 21:05:02 UTC, Andrei Alexandrescu 
wrote:

>> And are you talking about reference equality or value equality?
>
> Depends on how the user implements it. The intent is to support 
> meaningful comparison of the content of objects.

Yeah, C# allows that if the user chooses to overload `Equals`, 
and I hate it because it allows the author to effectively change 
the semantics of the `==` operator.  I like that D has a clear 
distinction between `is` and `==`.  Please keep them distinctly 
separate.

>> IMO, objects should only support reference equality out of the 
>> box.
>
> So that means "x is y" works but not "x == y"?

Yes.

>> Classes in C# only support reference equality out of the box: 
>> https://dotnetfiddle.net/AOQ0Ry
>
> Affirmative. Same in Java, is that correct?

Sorry, I don't have any experience with Java in this regard.

Mike




More information about the Digitalmars-d mailing list