Equality operator chaining?

Meta jared771 at gmail.com
Sun Nov 10 12:35:39 PST 2013


On Sunday, 10 November 2013 at 19:32:58 UTC, bearophile wrote:
> Øivind:
>
>> Although GCC accepts the code, I don't think it does what you 
>> think here. It will basically z will be compared with '1', 
>> which is the value of (4 == 4), and b will become 0, or false.
>
> OK, so it's like in the chained < comparisons.
>
> So I presume D disallows the chained equality for the same 
> reasons it disallows the chained < comparisons.
>
> Bye,
> bearophile

I was re-reading TDPL recently, and Andrei explicitly mentions 
this. The reason D disables this instead of allowing it is 
because it was deemed a bad idea to allow the code to compile 
with different semantics than the equivalent C code.


More information about the Digitalmars-d mailing list