Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!boulder!sunybcs!rutgers!mailrus!purdue!i.cc.purdue.edu!h.cc.purdue.edu!s.cc.purdue.edu!ags From: ags@s.cc.purdue.edu (Dave Seaman) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical analysis Message-ID: <3534@s.cc.purdue.edu> Date: 2 Sep 88 00:51:51 GMT References: <893@amelia.nas.nasa.gov> <3064@lanl.gov> <338@quintus.UUCP> Reply-To: ags@s.cc.purdue.edu.UUCP (Dave Seaman) Organization: Purdue University Lines: 29 In article <338@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >In article <3064@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >>The fact that C parentheses don't force execution order is sufficient >>to exclude C from use in some instances. > >Fortran's kludge of using () to control evaluation order (which means that >it has no way of expressing plain grouping *without* forcing evaluation >order) has been adopted in the draft ANSI C standard, so this should cease >to be a problem. On the contrary, Fortran's parentheses control only grouping and have nothing to do with evaluation order. Consider the statement Y = A(X) + (B(X) + C(X)) where A, B and C are external functions. There are 3! = 6 possible orders of evaluation for the three functions. All six of them are legal in Fortran. For example, a perfectly legal code sequence would be the following: 1. Evaluate C(X) and place the result in a temporary, t1. 2. Evaluate A(X) and place the result in a temporary, t2. 3. Evaluate B(X) and place the result in a temporary, t3. 4. Add t3 to t2 and place the result in t3. 5. Add t3 to t1 and store the result in Y. -- Dave Seaman ags@j.cc.purdue.edu