Newsgroups: comp.lang.c
Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps
From: flaps@dgp.toronto.edu (Alan J Rosenthal)
Subject: Re: printf() and commutative operations problem
	<etc.(?illegal word in localpart?).(?illegal word in localpart?).(?illegal word in localpart?)> <15580@gryphon.COM> ;
Message-ID: <8905151846.AA15998@champlain.dgp.toronto.edu>
Keywords: C printf
Organization: Dynamic Graphics Project, University of Toronto
Date: Mon, 15 May 89 14:46:56 EDT


In article <15580@gryphon.COM> joe@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."

