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

Maarten Litmaath maart at cs.vu.nl
Fri Sep 15 04:13:37 AEST 1989


gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
\...	0 && (i = 0)
\...
\Actually, now that I've gotten back to my desk where I keep a copy of
\the proposed Standard, I find that you must supply the parentheses to
\get a legal parse.  Without them there is no derivation from the
\grammar production rules.  (I think.  I keep getting this wrong.)

You're right, according to the January '88 :-( copy of the dpANS I have
at home.

[...	0 ? 0 : i = 0
is accepted, whereas
	0 && i = 0
is not.]

\Maybe the intention is to avoid confusion.  For example,
\	i = 0 && i = 0
\would either have to have an ambiguous parse, or else its interesting
\subexpression would be parsed differently depending on context, which
\is confusing. [...]

Allright, let's avoid the confusion; another example:

	a + b = 7

But why allow the `?:' expression, why make it a special case?
-- 
   creat(2) shouldn't have been create(2): |Maarten Litmaath @ VU Amsterdam:
      it shouldn't have existed at all.    |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.lang.c mailing list