Why D is annoying =P

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 24 19:12:48 PDT 2012


On Wednesday, October 24, 2012 13:31:14 Walter Bright wrote:
> The default compare for structs is a bit compare of the contents.

Which definitely seems inherently broken. Doing that only works if the struct 
only contains integral types, character types, or bool. Nothing else will 
compare properly that way. It really needs to work like arrays do (or are 
supposed to anyway) and compare each member according to == and only fallback 
to an outright bitwise compare when it knows that the results would be 
identical (i.e. because all of the members are integral types, character 
types, bool, or other structs which hold only integral types, character types, 
or bool - be it directly or in other structs that they hold). Bitwise comparison
is the is operator's job, not ==.

- Jonathan M Davis


More information about the Digitalmars-d mailing list