Equality operator chaining?
Walter Bright
newshound2 at digitalmars.com
Sun Nov 10 19:23:20 PST 2013
On 11/10/2013 11:08 AM, "Øivind" wrote:
>> int b = x == y == z;
>
> 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.
Which is exactly why D rejects this code.
And, if D accepted the code, but gave it Python semantics, then C code that did
work would silently break.
So no, D's behavior should not be changed.
(This is an old topic, we've gone over it before.)
More information about the Digitalmars-d
mailing list