[log in to unmask] writes:
> Richard, [with snips to the bit that I find interesting]
> >Parentheses can be used to control
> >the order of evaluation of operators in some cases....
> However, why cannot the compiler be permitted to understand the
> commutative/associative/distributive laws of arithmetic?
It is permitted to understand them in some cases. There is a rule
allowing the compiler to do "mathematically equivalent" things even
when they aren't "computationally equivalent". But it is not allowed
to violate the integrity of parens.
The problem here (in my opinion - which I think at least a few others
share) is that parens are used for two purposes, which although
related, are not always identical. In some cases, you need parens
just to establish the mathematical meaning of an expression like
a*(b+c). You don't really care whether or not the compiler evaluates
it that way or expands it to a*b+a*c; whatever it finds faster is ok.
In other cases, parens are used to specifically to keep the compiler
from re-arranging things. One might write (a+b)+c to tell the
compiler that you specifically want to add a+b and then add c to that
sum; you do not want the compiler to do this as a+(b+c). Perhaps
there are roundoff/cancellation issues or whatever. In any case, you
are asserting that you really want it done this way.
It would be nice if there were a way to separate these two uses. It
has been debated. I just don't recall any specific proposals on how
to do such a thing that generated a sufficient consensus to proceed.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|