[Issue 3433] [tdpl] Comparing structs for equality is not member-by-member
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 21 14:15:29 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3433
--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> 2009-10-21 14:15:28 PDT ---
the default opEquals on a struct that contains only an integer member does a
bitwise comparison. You may interpret this as "it does this because this is
how you compare integers" or you may interpret this as "it does this because
the default opEquals for structs always does bit comparison." I think
according to the spec, the latter is the case, which is consistent with the
given behavior.
In that case, I think this should be marked as an enhancement, I don't think it
would be a trivial update. I would mark it as such, but I don't want to step
on toes...
Incidentally, it would be a nice enhancement because it would save a lot of
boiler-plate code.
(In reply to comment #3)
> Well bitwise comparison breaks encapsulation. If a type defines its own
> equality operator, it most definitely had its reason. Skipping that is ignoring
> the encapsulation attempted by the object.
I agree, if you want bitwise comparison, use 'is'.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list