Why D is annoying =P

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Oct 27 22:30:25 PDT 2012


On Sat, Oct 27, 2012 at 07:52:37PM -0700, Jonathan M Davis wrote:
[...]
> TDPL clearly states that each of the struct's members are supposed to
> be checked for equality (see section 7.1.5.2, p. 258 - 259). It's
> outright a bug for structs to be checked for equality with a bitwise
> comparison when the bitwise comparison does not do exactly what ==
> would have done had each and every member variable been compared with
> ==. And as with all bugs, fixing it could break code which depends on
> the buggy behavior. But given the nature of this bug, I seriously
> question that much of anyone thought that the == on structs was
> supposed to do anything other than what TDPL states that it should and
> that pretty much no one was expecting it to do a bitwise comparison.
> So, if anything, this will _fix_ far more code than it breaks.
[...]

+1.

I have to say I was surprised to find out about this after I started
using D; after first reading TDPL, I had the impression that it was
supposed to do the "right thing" (and the right thing being == on each
field, which I assumed the compiler would optimize into a bitwise
compare where possible).

Let's fix this.


T

-- 
He who does not appreciate the beauty of language is not worthy to bemoan its flaws.


More information about the Digitalmars-d mailing list