comp.lang.c
[Top] [All Lists]

Re: ?: as an lvalue

Subject: Re: ?: as an lvalue
From: Willem
Date: Mon, 31 Mar 2008 18:56:28 +0000 UTC
Newsgroups: comp.lang.c

Eric wrote:
) Dave Hansen wrote:
)> Consider that it parses as
)> 
)>    (1>0)?(aa):(b=10);
)
)      Would you care to place a small wager on that?
)
)      You could refer to the formal grammar in the Standard
) to settle the question, or you could ask informally which
) of = and ?: "binds more tightly."  The parse you suggest
) would follow if = binds more tightly, in which case

Technically, it would also follow if = binds equally tightly.
Left-to-right and all that.

)       x = a ? b : c;
)
) would parse as
)
)       (x = a) ? b : c;

Again, purely technically, it would not if = were to bind equally tightly.

) Since we know that it actually parses as
)
)       x = (a ? b : c);
)
) you may be about to lose some money ...

I'm not going to bet on it though.


SaSW, Willem
-- 
Disclaimer: I am in no way responsible for any of the statements
            made in the above text. For all I know I might be
            drugged or something..
            No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy