Difference between a MACRO and a FUNCTION

R

Richard Tobin

$)CHarald van D )& k said:
The relevant rules from the grammar are:

primary-expression:
( expression )

conditional-expression:
logical-OR-expression ? expression : conditional-expression

Assuming a is an expression, it is valid in both forms.

Yes. For it to break when the parenthesized version works, there
would have to be something that is parsable as an expression when
parenthesized, but not otherwise. All parentheses do is turn an
expression into a primary-expression, so if parentheses make it
an expression it already was one.

[We can see that parentheses are needed for the third operand, since
there *are* things that are parsable as a conditional-expression when
parenthesized, but not otherwise: a=b for example.]

-- Richard
 
A

Army1987

Keith Thompson said:


That was my principal method of attack. I couldn't break it that way, but
that doesn't mean it can't be broken. (Nor does it mean it can,
obviously.)

I suspect that a grammatical analysis will bear more fruit than any number
of attempts at a crack.

Given the syntax and the fact that the only place where the token
? and the token : can occur is a conditional expression, adding
( after ?, or ) before :, should be no more useful that adding
( after [, or ) before ].
Compare:

Syntax
1 postï¬x-expression:
primary-expression
postï¬x-expression [ expression ]
<snip>

and:

Syntax
1 conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression

(Yes, there could be some mysterious, hidden point that I'm
missing, considering that I was almost as self-assured as now when
I claimed that #define INT_MIN -128 couldn't possibly be broken.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top