printf() and commutative operations problem <etc.(?illegal word in localpart?).(?illegal word in localpart?).(?illegal word in localpart?)> <15580 at gryphon.COM> ;

Alan J Rosenthal flaps at dgp.toronto.edu
Tue May 16 04:46:56 AEST 1989


In article <15580 at gryphon.COM> joe at gryphon.COM (Joseph Francis) writes:
>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.
[ proposes a prototype f(a, b; c; d, e, f) which guarantees that b is
  evaluated before c which is evaluated before d ]

I think you're paying insufficient attention to the other feature of `&&',
namely that if the lhs is false the rhs is never evaluated.  This could not
have any analogue for the proposed `;' operator, because some function argument
must still be supplied.  I would maintain that the major use of `&&' is this
conditional evaluation, not the sequencing.  (Of course, the conditional
evaluation implies the sequencing (in a non-parallel programming language), but
not vice versa.)

ajr

--
"The winners write the history books."




More information about the Comp.lang.c mailing list