From: dnl@convex.is.macsch.com (David Lombard)
Subject: Re: function name as an argument
Organization: MacNeal-Schwendler Corp.
Date: Tue, 15 Dec 92 01:59:58 GMT

In article <1992Dec14.150347.17156@e2big.mko.dec.com> lionel@quark.enet.dec.com (Steve Lionel) writes:
>
>
>Absolutely true.  But even if you compiled all the routines together, what if
>you added another caller of SUB which passed FUNC declared as a different
>length?  Unless you additionally require procedure inlining, there is no way
>that SUB can know which routine called it and which length to statically
>allocate.  This is why the standard requires the length of a character
>function to be declared as an integer constant expression in the program
>unit which calls the function.  And this is why an implementation (such as
>VAX FORTRAN), which does allow the (*) in the referencing unit, passes the
>length along with the routine address, so that it may do run-time allocation
>for the function result.
>--
>
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO!

FLAME ON!

Learn the language!  This is the second time this (#^&*$* remark has been made.

FLAME OFF!

PLEASE, read sections 8.4.2 and 15.9.3.1 of the standard.  They explain why
all implementations of the language must maintain and pass around the
length of each character variable.  All implementations must allow the (*)
in subprograms.  This is not some mystical example of the great god VMS.
If an implementation does not support (*), then it is simply non-conforming.

Inlining has no bearing on a subrpogram knowing how large a character variable 
is.  The length must be passed.  PERIOD.  Some implementations, such as your 
blessed VAX, pass around a structure describing the string.  Other 
implementations pass two adjacent arguments, the address and the length.  
Others first pass all the addresses then all the lengths.  Others do other 
things.

In addition, the result is stored in a statically sized location, i.e. the
variable which is assigned the value of the function.


A word to the wise, the standard is not a document one can casually read.
The information is `scattered' throughout the document.  One must `swim'
in the standard to understand it.  This is not meant as an impeachment of
the standard, just a statement of fact.


                      MY COMMENTS, MY OPINIONS.

David N. Lombard    The first thing we do,         The MacNeal-Schwendler Corp
dnl@macsch.com      Let's kill all the lawyers.    815 Colorado Blvd
(213) 259-4911      II Henry VI, IV.ii             Los Angeles, CA  90041
Newsgroups: comp.lang.fortran