printf() and commutative operations problem

Joseph Francis joe at gryphon.COM
Mon May 8 17:27:07 AEST 1989


The problem having been well characterized, why not a new specification
for evaluation. The bitwise & operator is well-known to be commutative
so it is left to the compiler to rearrange subterms for optimal
evaluation, and therefore the 'deadly' getchar() used as 
getchar() & getchar() (useless, but similar to the original problem) combined
with something else can have unpredictable side-effects.  However, the
getchar() && getchar() will always be L-R evaluated.  So, for function
definition, why not something like f(a, b; c; d, e, f) either in the
prototype or at invocation which guarantees the ordering of b->c->d
and leaves the others unspecified; mixed commtative and non-commutative
argument delimiting.  I realize, of course, this could be controlled with
macros, something hideous like 
#def f(A,B,C) { argtype a,b,c; a=A; b=B; c=C; g(a,b,c) }
or with better coding, but why not allow more sequencing control, if you
allow it with && and other operators?

-- 
joe at gryphon		...!elroy!gryphon!joe	
but jojo to my beeeest frieeeends.



More information about the Comp.lang.c mailing list