Orphaned Response - (nf)
#M.CONDICT
mnc at hou2g.UUCP
Tue Mar 20 01:08:45 AEST 1984
> In regard to this:
>
> cat = foo ? fu = bar : mouse;
>
> Precedence has nothing to do with it. Precedence only matters when there
> are two possible legal parses, such as "a + b * c" which could be either
> "(a + b) * c" or "a + (b * c)" without precedence to disambiguate.
>
> The only possible parse for the first expression is:
>
> cat = foo ? (fu = bar) : mouse;
>
> so that the "fu = bar" assignment happens before the assignment to cat
> if it happens at all. Golly.
What's wrong with the parse: (cat = foo) ? (fu = bar) : mouse; ?
This evaluates an if-then-else expression containing two assignments as
side effects and then throws away the result.
Michael Condict ...!hou2g!mnc
More information about the Comp.lang.c
mailing list