Order of Evaluation (plus ?'s)

Walter Murray walter at hpclwjm.HP.COM
Tue Nov 21 05:42:58 AEST 1989


Doug Gwyn writes:
> In article <13871 at orstcs.CS.ORST.EDU> bailey at jacobs.CS.ORST.EDU.UUCP (Kirk Bailey) writes:
> -I'm curious about the fate of the changed floating point evaluation
> -constraints which were a part of some of the intermediate dpANSI "C" documents;
> -the idea being that the programmer could be assured of a fixed evaluation
> -order without requiring the use of temps.  The current doc's I have seem to
> -no longer mention this (or the synchronization aspect of unary '+')?

> Unary + is no longer the way to do this.  Use parentheses instead.

There are times when the parentheses aren't even needed.  ANSI C guarantees
that
   p = q + r + s;
will behave exactly the same as
   p = (q + r) + s;
In this respect a standard-conforming C compiler will actually have
less latitude than a FORTRAN compiler when it comes to rearranging
expressions.

Walter Murray
----------



More information about the Comp.std.c mailing list