I have no problem with this thread, so long as nobody thinks they are
posting some new idea. (Well, hardly anybody.)
So I won't post anything new either. Just to reiterate a bit of history:
I joined X3J3 (now J3) around 1975 when "Fortran 77" (so-called later) was
in its final stages.
At that time, the text that has now been changed to permit "mathematically
equivalent" operations was under review. The former text listed the
commutative, associative, and distributive laws and probably a few other
rules, and said (roughly) that the processor can evaluate any expression
that it derives from the written program by applying any of the listed
transformations.
Some of us thought that the list was too restrictive. Walt Brainerd said we
should separate the "interpretation rules" (Sec. 6.5.1 of Fortran 77) from
the rules for "evaluation of expressions." So that is what was done, and
after quite a lot of agonizing work, F77 came out roughly as follows:
The interpretation of an expression (6.1.2) is governed by parentheses,
operator precedence, and left-to right evaluation except in exponentiation.
The evaluation of expressions (Sections 6.6.1 to 6.6.3) lists some rules
including integrity of parentheses, and then 6.6.4 says,
"The rules given in 6.1.2 specify the interpretation of an arithmetic
expression. Once the interpretation has been established in accordance with
those rules, the processor may evaluate any mathematically equivalent
expression, provided that the integrity of parentheses is not violated. (new
paragraph:) Two arithmetic expressions are mathematically equivalent if, for
all possible values of their primaries, their mathematical values are equal.
However, mathematically equivalent arithmetic expressions may produce
different computational results."
Then it explicitly mentions that the obvious transformations to integer
division can produce mathematically different results.
This was a very serious attempt to "almost" specify semantics, while still
permitting reasonable optimizations (which of course, long before the 1975,
were the hallmark of Fortran).
I was still on the committee when Interp #1 (if that is the number) came up,
but as I recall, a deadlock immediately arose concerning the proper
interpretation - especially, as I recall, about the fact that "all" actual
compilers did a lot more than changing the evaluation of expressions. It is
my impression that the deadlock was not resolved until the committee's
membership changed somewhat (including my departure for several years).
= Loren Meissner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|