Tue, 19 Oct 1999 22:37:37 -0400
> > > You may want to try declaring the 2**4 expression as a
> > > which guarantees a static value at compile time regardless of the
> > > implementation or level of optimization. I hate code that relies on a
> > > particular optimizer anyway.
> > >
My response :
> > In this case I agree with you but in general I disagree with the
> > general feeling that you hate code that relies on a particular
> > optimizer.
Tucker Tafts info
> This particular case has nothing to do with optimization. All validated
> Ada compilers are required to evaluate "static" expressions at
> 2**4 is static, as are essentially all operations involving numeric
> named numbers, or named constants whose initial value is static. See
> 4.9 (or so) of the manual.
Point taken. The point I was going after in my response was not one of
optimization but rather style.
The fact that the compiler will replace 20 occurrences of 2**4 with a static
is nice (and I am glad to hear it is a requirement) but in any case for
style reasons I would
typically still want to see it done from a single constant unless there was
no better name
for the constant than Two_To_The_Fourth_Power which is one of the more
style of constant declarations I have seen.
But the discussion and answer info here from Tucker points out why writing
your code to
not require some particular compiler optimization is often silly since mere
mortals who were
not involved in writing the LRM are often assume they have to do something
to make the
code fast when in reality the compiler was required to do it for them.
Sometimes a hand rolled
optimization is the correct choice but not nearly as often as most