[Issue 3433] [tdpl] Comparing structs for equality is not member-by-member
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Nov 14 06:10:10 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3433
--- Comment #6 from Andrei Alexandrescu <andrei at metalanguage.com> 2009-11-14 06:10:08 PST ---
(In reply to comment #5)
> This has some tricky points. The first is that it's recursive. As well as
> structs, it also applies to fixed-length arrays: if either contains a struct
> with an opEquals, the entire struct must be compared member-by-member; and this
> check must be performed recursively.
Correct - more precisely, transitive for direct fields. I think the comparison
should simply call a template object.structCompare that we define as a library
function.
> Secondly, what happens with unions?
>
> struct Rectangle {
> union {
> Point leftBottom;
> int problematic;
> }
> }
> I think this should probably be an error.
I think so too.
> The third difficult part relates to protection. Any of the struct members may
> be private and defined in a different module.
>
> If a field in the struct is a class, it probably applies to it as well.
I'm not sure how to address this.
--
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