Expression sequencing query (better test)

Gary M. Samuelson garys at bunker.UUCP
Sat Oct 4 06:02:31 AEST 1986


Instead of

	a = ((b=1),b) + ((b=2),b) + ((b=3),b);

I would like to suggest using

	a = ((b=1),b) + ((b=4),b) + ((b=16),b);

This has the advantage that the result in a is unambiguous.
For example, the answer '7' could be 1+3+3 or 2+2+3, but with
the modified test case, the same order of evaluation would
produce 33 or 24.  Furthermore, the (supposedly) correct answer
'6' could be incorrectly generated by 2+2+2, instead of 1+2+3.
The modified test will produce 12 or 21, respectively.

Gary Samuelson



More information about the Comp.lang.c mailing list