Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!convex!sushi!grogers From: grogers@sushi.uucp (Geoffrey Rogers) Newsgroups: comp.lang.c Subject: Re: ambiguous ? Message-ID: <2320@convex.UUCP> Date: 23 Oct 89 21:43:44 GMT References: <6613@ficc.uu.net> <14104@lanl.gov> Sender: usenet@convex.UUCP Reply-To: grogers@sushi.UUCP (Geoffrey Rogers) Organization: Convex Computer Corporation, Richardson, Tx. Lines: 47 In article <14104@lanl.gov> jlg@lanl.gov (Jim Giles) writes: >From article <6613@ficc.uu.net>, by peter@ficc.uu.net (Peter da Silva): >> [ in Fortran, >> CALL SUBR(FUNC, FUNC) >> May be called as >> TEMP=FUNC >> CALL SUBR(TEMP, TEMP) >> So, FORTRAN does have ambiguous and unspecified behaviour. It just >> describes it in different terms. If Jim Giles has a problem with C, >> then he must have an even bigger problem with FORTRAN. If not, then >> his opposition to C must be based on religious beliefs rather than >> logical reasoning. > > As I've already pointed out, the first >call given above is _illegal_ in Fortran if the order (or >number) of function evaluations will effect the meaning of >the program (that is, if FUNC has side-effects). It is! Where does it say that in the FORTRAN 77 standard? Here what the Fortran 77 standard says: 6.6.2 Order of Evaluation of Functions. If a statement contains more than one function reference, a processor may evaluate the functions in any order, except for logical IF statements and a function argument list containing function references. For example, the statement Y = F(G(X)) where F and G are functions, requires G to be evaluated before F is evaluated. In a statement that contains more than one function reference, the value provided by each function reference must be independent of the order chosen by the processor for evaluation of the function reference. From this I would say that the first calling sequence is legal no matter what the side effects are from the evaluation order of the functions. Also note that the second calling sequence is illegal, because you are generating an illegal form of aliasing. From this I would say that FORTRAN is just as ambigous as C. If you are going to compare C to other languages such as FORTRAN, please know what in the standard before you say what is or isn't legal. Geoffrey C. Rogers "Whose brain did you get?" {sun,uunet}!convex!grogers "Abie normal!" grogers@convex.com