NoNo for Associativity of Assignments?
Manfred Nowak
svv1999 at hotmail.com
Sat Feb 24 23:26:14 PST 2007
Joel C. Salomon wrote
> the meaning of chained assignments is unambiguous to compiler and
> programmer alike.
Are you sure?
int a=1, b=2, c=3;
a = b = c;
With associativity this can virtually be rewritten as both
( a = b ) = c;
or
a = ( b = c);
After "( a = b) = c;" a == 2, b == 3, c == 3.
After "a = ( b = c);" a == 3, b == 3, c == 3.
Of course one can _declare_ this to be unambigouous.
-manfred
More information about the Digitalmars-d
mailing list