After reading this google result, I'm now 100% sure that my recollection of the 1987 ANSI BASIC spec is exactly how FORTRAN works.
--------------------------------------------------------
Search Result 4
From: M. J. Saltzman (
[email protected])
Subject: Re: Interpretation of unparenthesized expressions
View: Complete Thread (27 articles)
Original Format
Newsgroups: sci.math
Date: 1991-04-18 15:59:16 PST
In article <
[email protected]>
[email protected] (Jeff Carroll) writes:
>
> It wasn't until I took my freshman FORTRAN class that I was introduced
>to the concept of operator precedence. Even there I was taught that it was not
>good programming style to count on operator precendence when using parens
>would make code easier to read.
>
FORTRAN, C, Pascal, Modula-2, PL/I, BASIC all conform to the same notion of
operator precedence (at least WRT *, /, +, -). (APL and LISP were the
first languages I encountered that didn't.) A compiler for any of
these languages that doesn't perform * and / before + and - is simply
broken. I firmly believe that this was done to conform to the
convention in the rest of the world that * and / have precedence
over + and -. It certainly wasn't done to make writing the compiler
easier.
The advice to parenthesize expressions in FORTRAN stems in part from
the fact that finite-precision arithmetic is not associative, that is,
(a+b)+c may give a different numerical result than a+(b+c) due to
cancellation, loss of precision or overflow. In FORTRAN, the
programmer can control the order of association of operators at the
same precedence level by adding parentheses, and (if I recall
correctly) the compiler must follow the sequences implied by the
parenthesized expression. If there are no parentheses, the compiler
is free to make any association that is convenient. C compilers do
not have this requirement, that is, the compiler is free to choose
(a+b)+c even if the programmer wrote a+(c+b). Of course, this does
*not* affect the precedence of * over +, that is (...) will override
the precedence in (a+b)*c.
Readability is important too, but it has nothing to do with the
definition of the language. Over-parenthesizing doesn't help
readability either...