a ? b = c : d, and what the Manual says
Dick Grune
dick at tjalk.UUCP
Wed Mar 21 23:09:27 AEST 1984
Since here in Europe the net news often arrives a bit late, I generally do
not bother to answer, because anything I may have to contribute
usually appears repeated N times in the next few rounds of news.
Nevertheless, in the protracted discussion about the acceptability of
a == b ? c = d : e = f
I have not to date seen the essential remark that the reference
manual answers the question, so here I go.
I quote (RM 7, first paragraph):
"The precedence of ... operators is the same as the order of
the major subsections... . Thus, for example, the expressions
referred to as the operands of + ($7.4) are those defined in
$$7.1-7.3."
This effectively says how to expand the grammar in the manual to
obtain a more complete one. For $7.13 this expansion results in:
conditional_expression:
expression7_13 ? expression7_13 : expression7_13
expression7_13:
logical_or_expression /* 7.12 */
logical_and_expression /* 7.11 */
...
unary_expression /* 7.2 */
primary_expression /* 7.1 */
This grammar does not produce
a == b ? c = d : e = f
and you may draw your conclusions from that.
If this has been on the net, the news just hasn't come to me, and I
apologize for wasting time and bandwidth.
Dick Grune
Vrije Universiteit
Amsterdam
And my name isn't Richard!
More information about the Comp.lang.c
mailing list