Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: precedence of ?: (was: precedence of && (was: precedence of ?:)) Message-ID: <11069@smoke.BRL.MIL> Date: 14 Sep 89 21:44:32 GMT References: <1265@gmdzi.UUCP> <11030@smoke.BRL.MIL> <11039@smoke.BRL.MIL> <3236@solo10.cs.vu.nl> <11045@smoke.BRL.MIL> <3242@solo12.cs.vu.nl> <11054@smoke.BRL.MIL> <3260@solo5.cs.vu.nl> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <3260@solo5.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >[... 0 ? 0 : i = 0 >is accepted, whereas > 0 && i = 0 >is not.] >But why allow the `?:' expression, why make it a special case? I was mistaken in my original response; 0 ? 0 : i = 0 is not legal. However, to save another iteration in this series of postings, note that 0 ? i = 0 : 0 is legal. conditional-expression: logical-OR-expression logical-OR-expression ? expression : conditional-expression So the interesting question becomes, why is that "expression" for the second operand of ?: and not "logical-OR-expression". (I think that "conditional-expression" might result in ambiguity.) The Rationale says merely that "several extant implementations have adopted this practice". That must be the answer..