Re: Dangling else

"Russ Cox" <>
24 Feb 2006 18:03:20 -0500

          From comp.compilers

Related articles
Dangling else (borneq) (2006-02-19)
Re: Dangling else (2006-02-19)
Re: Dangling else (SM Ryan) (2006-02-24)
Re: Dangling else (Russ Cox) (2006-02-24)
Re: Dangling else (Russ Cox) (2006-02-24)
Re: Dangling else (SM Ryan) (2006-03-05)
Re: Dangling else (SM Ryan) (2006-03-05)
Re: Dangling else (=?ISO-8859-1?Q?Jan_Vorbr=FCggen?=) (2006-03-05)
Re: Dangling else (2006-03-05)
Re: Dangling else (Dave Thompson) (2006-03-05)
Re: Dangling else (Dmitry A. Kazakov) (2006-03-06)
[8 later articles]
| List of all articles for this month |

From: "Russ Cox" <>
Newsgroups: comp.compilers
Date: 24 Feb 2006 18:03:20 -0500
Organization: Compilers Central
References: 06-02-168
Keywords: parse, design
Posted-Date: 24 Feb 2006 18:03:20 EST

> [I don't know anyone who thinks that C's million levels of precedences
> are a good idea. Back in the 1950s, it seemed reasonable in Fortran
> for exponentiation to bind tighter than multiplication and division
> which bound tighter than addition and subtraction, in line with most
> mathemetical notation, and then it got away from us. How do you like
> the APL rule that everything binds and associates the same? -John]

I haven't used APL much, but troff expressions have the same
rule--everything left to right, equal precedence--and there I find it
jarring to read expressions like 1+2*3 as 9. (To be fair, there are
enough other things about troff that are equally jarring, so it fits in
just fine.)

It's really hard to escape the mathematical precedences when reading.
If C had equal precedence for all operators, I think there would be far
more complaints about 1+2*3 not being 7 than there are about the fact
that if(x < y < z) or if(x&3 == 1) don't act the way they look.

I think that C makes some bad choices for its precedence levels (and
assigning left-to-right precedence to what should be nonassociative
operators) but I still think that precedence levels are useful.
Mathematicians don't seem to be giving up on them any time soon.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.