Precedence Question - (nf)

Morris Keesan keesan at bbncca.ARPA
Wed Feb 15 01:12:45 AEST 1984

(Pardon the first attempt at this if I didn't manage to cancel it in time -- 
I've just moved to a new office, and my terminal connection is very flaky.)
A trivial quibble:
John Levine (ima!johnl) says
> In regard to this:
> 	  cat = foo ? fu = bar : mouse;
> Precedence has nothing to do with it.
> The only possible parse for the first expression is:
>	 cat = foo ? (fu = bar) : mouse;
    I agree that the original question posed by smu!pedz has nothing to do
with precedence, but is an "order of evaluation" question.  However, precedence
does enter into the parsing of the expression, and it's exactly the precedence
rule that Pedz was misapplying, the precedence of ?: over assignment, that
makes the correct parse

	cat = (foo ? (fu = bar) : mouse);

instead of

	(cat = foo) ? (fu = bar) : mouse;

which makes all the difference in the world as far as what gets assigned to cat.
					Morris M. Keesan
					keesan @ BBN-UNIX.ARPA

More information about the Comp.lang.c mailing list