Path: utzoo!attcan!uunet!sco!seanf From: seanf@sco.COM (Sean Fagan) Newsgroups: comp.lang.fortran Subject: Re: i++, i+=1, i=i+1 Message-ID: <1267@scolex> Date: 16 Sep 88 19:45:57 GMT References: <3976@h.cc.purdue.edu> <3659@lanl.gov> Reply-To: seanf@sco.COM (Sean Fagan) Organization: The Santa Cruz Operation, Inc. Lines: 32 In article <3659@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <3976@h.cc.purdue.edu>, by ags@h.cc.purdue.edu (Dave Seaman): >> If you apply your preprocessor to >> x[i*f(j)+k*g(l)] += y >> you get >> x[i*f(j)+k*g(l)] = x[i*f(j)+k*g(l)] + y >> which is not the same expression at all, becauses it causes the the subscript >> to be evaluated twice. > [functions not allowed to return different values on the same input] [also not allowed to have side-effects] Wrong. They can. Also, with regards to side-effects, a FORTRAN function can modify a COMMON variable, or, happy happy, its argument. So what happens when j and l change between the first and second calls of f() and g(), respectively? Are you saying that the compiler can just optimize (incorrectly, I should add) the function calls into one function call? Which means that, in order to do what the programmer wants, he has to use temporary variables? Didn't I see an article a while ago saying that FORTRAN was nice because you didn't have to use temporary variables to get what you wanted evaluated correctly? >J. Giles >Los Alamos -- Sean Eric Fagan | "Joy is in the ears that hear, not in the mouth that speaks" seanf@sco.UUCP | -- Saltheart Foamfollower (S. R. Donaldson) (408) 458-1422 | Any opinions expressed are my own, not my employers'.