Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Fortran versus C for numerical analysis Message-ID: <3185@lanl.gov> Date: 2 Sep 88 20:43:10 GMT References: <344@quintus.UUCP> Organization: Los Alamos National Laboratory Lines: 26 From article <344@quintus.UUCP>, by ok@quintus.uucp (Richard A. O'Keefe): > What I meant was that there is no method of saying "this grouping is > just syntactic so that I can read the expression, mathematical laws may > be applied". The point is that some expressions can't be written > without using parens, and there is no way of distinguishing those parens > from ones that you *want* to have the special effect. For example, > unless I am mistaken, (1.0+X)*2.0 must be evaluated that way rather than > as 2.0+2.0*X. Sometimes you care, but sometimes you don't. This is what I meant when I said that parenthesis aren't necessarily the _best_ way of doing this. But _some_ method is needed. In this respect, Fortran beats C. > [...] In This > particular example, unless you want to do part of the calculation > yourself, you have to put the parens in to get around the operator > priorities. If, however, I write 2*I+2, the compiler *is* free to > rearrange this as 2*(I+1). Isn't it? YES! Fortran _can_ optimize using the distributive rule in reverse. Maybe what's needed is a new syntax which specifies meaning without forcing order. How about {A+B}*C, which the compiler would be allowed to implement as A*C+B*C. J. Giles Los Alamos