Expression Sequencing Query

Joshua W. Knight JOSH at ibm-sj.ARPA
Sat Oct 18 14:10:47 AEST 1986


There have been lots of lamentations about C not providing a way to
force evaluation order.  The original subject (with multiple "side
effect" assignments to the same variable) isn't really the issue here.
One legitimate concern is truncation and such in numerical calculations.
The ANSI C draft standard provides the unary plus operator for coercing
evaluation order.  Thus

    a = +(b + c) + +(d) ;

should force the sum of b+c to be calculated and added to d. This is
probably less pleasing to the eye but, as has been pointed out before,
parentheses already have a meaning in C, and it is explicitly NOT one
that forces order of evaluation.

Of course I speak only for myself, not my employer.

			Josh Knight
			IBM T.J. Watson Research Center
josh at ibm.com, josh at yktvmh.BITNET



More information about the Comp.lang.c mailing list