Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!sun-barr!newstop!texsun!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: ambiguous ? Message-ID: <6637@ficc.uu.net> Date: 23 Oct 89 15:07:06 GMT References: <6613@ficc.uu.net> <14104@lanl.gov> Reply-To: peter@ficc.uu.net (Peter da Silva) Organization: Xenix Support, FICC Lines: 46 In article <14104@lanl.gov> jlg@lanl.gov (Jim Giles) blathers: > 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). OK, so in FORTRAN the calling sequence is undefined, and in addition you're not allowed to write any code where that matters. That's a bloody great improvement. > As I've already said, > the solution I favor is to provide the user _explicit_ means > of specifying whether a function has side-effects and then > allowing the compiler to optimize _NON_SIDE-EFFECT_ function > calls in any way it likes. This has nothing to do with function calls that have side effects. We're talking about evaluation order of arguments... expressions that have side effects being used in arguments to function calls. In Fortran, you're just not allowed to do that. In C, you can do it but your code may not be portable. You have to watch out for dependencies among the arguments. You may be confused because in Fortran the only way an expression can have side effects is if it involves a function call. Here's another question: In FORTRAN: INTEGER I, J INTEGER GETCH ! Returns next byte at input. DATA I /0/ J = I * GETCH(5) J = 0 * GETCH(6) Is this legal? Is it guaranteed that GETCH(5) will be evaluated? Is it guaranteed that GETCH(6) will be evaluated? C makes these guarantees. -- Peter da Silva, *NIX support guy @ Ferranti International Controls Corporation. Biz: peter@ficc.uu.net, +1 713 274 5180. Fun: peter@sugar.hackercorp.com. `-_-' "I feared that the committee would decide to go with their previous 'U` decision unless I credibly pulled a full tantrum." -- dmr@alice.UUCP