precedence of ?: (was: precedence of && (was: precedence of ?:))

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Sep 17 10:10:40 AEST 1989


In article <2550103 at hpisod2.HP.COM> decot at hpisod2.HP.COM (Dave Decot) writes:
>Note that it also renders invalid several classes of expression that
>were completely correct in K&R I.

It wasn't at all clear what was intended by K&R I.

>Another interesting effect of the Standard's grammar is that:
>    k = (!y ? 0 : t = 1);
>is valid, but
>    k = (y ? t = 1 : 0);
>is a syntax error, although it had a single unambiguous parse in K&R I.

Other way around.

I think all existing usage where different compilers always parsed
the expressions the same way still work as before.  In cases where
there were varying interpretations, the Standard now provides a
single unambiguous prescription for how to parse the expressions.



More information about the Comp.lang.c mailing list