[Nickle]Sequencing of expressions with side effects
Keith Packard
nickle@nickle.org
Tue, 23 Jul 2002 10:53:02 -0700
Around 10 o'clock on Jul 23, Bart Massey wrote:
> Naah. If you're gonna honor the precedence of operators in
> expression evaluation, you should also honor the
> associativity: assignment operators associate right-to-left,
> and should thus evaluate right-to-left.
I disagree. A strict left to right rule fixes problems with lexical scope
of identifiers:
a = (int b = 2) ** b;
Associativity only affects implicit parenthesization, I don't think it
should affect the evaluation order.
> a += b --> a = (int x1 = a) + (int x2 = b);
> which would still be consistent with the principles
> espoused above.
This isn't quite right -- 'a' must be evaluated only once in the 'a += b'
case:
a += b -> (poly* ap = &a), (*ap = *ap + b)
-keith