order of evaluation parse date s - (nf)

utzoo!decvax!harpo!npoiv!hou5f!ariel!houti!hogpc!houxz!ihnp4!ixn5c!inuxc!pur-ee!uiucdcs!uicsl!preece utzoo!decvax!harpo!npoiv!hou5f!ariel!houti!hogpc!houxz!ihnp4!ixn5c!inuxc!pur-ee!uiucdcs!uicsl!preece
Fri Mar 11 16:57:13 AEST 1983

uicsl!preece    Mar 11 08:28:00 1983

***** uicsl:net.lang.c / alice!e /  3:46 pm  Mar  3, 1983
i = 4;
i = i++;

Regardless of whether the increment of the assignment comes first,
i == 5 afterwards.  Think:

If the increment comes first:
i++ (so i == 5)
i = i (so i == 5)

If the assignment comes first:
i = i (so i == 4)
i++ (so i == 5)
Think again:
	Stack old value of i
	Store incremented value in i
	Pop stacked (old) value into i (so i == 4)

This is a perfectly reasonable interpretation, given that the whole
line (i = i++) is one expression, and therefore re-arrangeable.
In fact, many would say it's the RIGHT way, since it means the
result of 'a = i++' and 'i = i++' are the same.

Clearly K+R says they're all right methods, and the author should
avoid ambiguous expressions.

[I agree with most of you out there that this topic has had
enough attention, but i also think it's worthwhile to keep
addressing mis-interpretations in the hopes of as many readers
as possible understanding the problem and avoiding such usage.]

scott e preece
uiuc coordinated science lab

More information about the Comp.lang.c mailing list