ambiguous ?

Geoffrey Rogers grogers at sushi.uucp
Tue Oct 24 07:43:44 AEST 1989


In article <14104 at lanl.gov> jlg at lanl.gov (Jim Giles) writes:
>From article <6613 at ficc.uu.net>, by peter at 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 at convex.com



More information about the Comp.lang.c mailing list