A curriosity in the C compiler...

Anthony Lapadula al710 at unh.UUCP
Mon Oct 31 10:25:53 AEST 1988


In article <181 at celerity.UUCP>, billd at celerity.UUCP (Bill Davidson) writes:
> In article <530 at uvicctr.UUCP> sbanner1 at uvicctr.UUCP (S. John Banner) writes:
> >	This is a quick test of the C compiler, for implied bracketing...
> >This will determine if the expression "a = b == c" is parsed
> >as "(a = b) == c" (which is correct), or as "a = (b == c)" (which is not).
> 
> ACK!  Please refer to page 49 of K&R or any other C book which has a
> precedence table.  "a = b == c" must be parsed as "a = (b == c)" by
> laws of precedence which have been in C for a very long time.
> 
> A C programmer who does not know his precedence laws by heart had better
> use a lot of parentheses or he can expect a LOT of problems.
>
> 	--Bill Davidson

Maybe it's just me (and it probably is), but isn't
      a = (b == c)
a whole lot clearer than
      a = b == c
?  (And where the heck should that question mark go, anyway?)

It seems that the first version clearly points out that 'a' is being
used as a boolean, where the second one is more of an exercise left
for the reader.

Just trying to stir up another one of those "= looks too much like ==
to me" arguments....

/*
**      What, you wanted something funny?
**             --- Anthony Lapadula (...!unh!al710)
*/



More information about the Comp.lang.c mailing list