WAT: opCmp and opEquals woes
via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 25 11:04:09 PDT 2014
On Thursday, 24 July 2014 at 08:18:22 UTC, Daniel Gibson wrote:
> When I implement the "comparison operator" for my type, I
> expect it to be used for comparisons - and that includes
> equality.
> If I had the feeling that I could implement == in a more
> efficient way, or that I actually want equality to have
> different semantics, I'd just implement opEquals as well.
>
> IMHO, everything else would be just confusing to the "average"
> user, and if someone wants to be confused by counterintuitive
> rules (however much sense they may make in some way) he could
> as well just use C++ instead.
>
> But if the general view really is that opEquals should *not* be
> opCmp == 0 by default, for performance reasons or whatever,
> then please enforce defining opEquals when opCmd is defined, so
> it's at least explicit that opCmd does not define equality.
+1
Silently breaking (IMHO reasonable) expectations is bad.
More information about the Digitalmars-d
mailing list