Path: utzoo!attcan!uunet!wuarchive!decwrl!sun-barr!newstop!sun!boise.Eng.Sun.COM!wsb From: wsb@boise.Eng.Sun.COM (Walt Brainerd) Newsgroups: comp.lang.fortran Subject: Re: Side effects in boolean expressions Summary: It is legal Message-ID: <140684@sun.Eng.Sun.COM> Date: 15 Aug 90 15:33:26 GMT References: <2022@key.COM> <59110@lanl.gov> <2041@key.COM> Sender: news@sun.Eng.Sun.COM Lines: 15 In article <2041@key.COM>, sjc@key.COM (Steve Correll) writes: > ... the C code is legal and its behavior predictable; the Fortran is neither: > ^^^^^^^^^^^^^^^^^^^^^^ > if ((x < 0.0) || (sqrt(x) < 10.0)) ... > IF ((X .LT. 0.) .OR. (SQRT(X) .LT. 10.0)) ... > The Fortran code certainly is legal. The main point is that the _result_ is predictable; how the result is obtained is not, which is exactly the point of optimization. The difference is when you rely on function side effects, important in C, but never should be done in Fortran. -- Walt Brainerd Sun Microsystems, Inc. wsb@eng.sun.com MS MTV 5-40 Mountain View, CA 94043 415/336-5991