home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!caen!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
- From: jlg@cochiti.lanl.gov (J. Giles)
- Subject: Re: function name as an argument
- Message-ID: <1992Dec14.215349.24872@newshost.lanl.gov>
- Sender: news@newshost.lanl.gov
- Organization: Los Alamos National Laboratory
- References: <1992Dec8.051134.5968@news.Hawaii.Edu> <ADK.92Dec12114449@ds2.sun13.SCRI.FSU.EDU> <1992Dec14.193634.5231@newshost.lanl.gov>
- Date: Mon, 14 Dec 1992 21:53:49 GMT
- Lines: 42
-
- In article <1992Dec14.193634.5231@newshost.lanl.gov>, jlg@cochiti.lanl.gov (J. Giles) writes:
- |> [...]
- |> Once again: there is no need to rely on dynamic memory to provide
- |> the above functionality. However, it appears that there *is* a
- |> constraint in the Fortran 77 standard which prohibits it. I don't
- |> know why and neither does our representative to the committee.
-
- Finally, someone who thinks rather than just reacting has sent me
- the answer to this. The example under discussion in this thread
- did *not* require any dynamic memory allocation (or even stack).
- However, an similar example would:
-
- subroutine asub(func, var)
- character*(*) func, var
- ...
- var = other_fcn(func(1), func(2))
- ...
- end
-
- Any example in which the passed-in function would be called more than
- once in a single statement would require that more than one chunk of
- intermediate space be reserved. This is apparently the reason for the
- constraint in the standard. No thanks to those whose responses just
- echoed the party line with no thought or explanation given. Thanks
- for the correct answer are due to Peter Montgomery of Oregon State.
-
- Of course, a weaker constraint that allowed functions with passed-in
- lengths to be used, but only if they were limited to one call per
- statement, would also be possible. It's not clear this was ever
- even considered (such a subtle constraint would probably be confusing
- anyway).
-
- The Fortran 90 standard allows automatic and dynamic allocation and
- should have no problem eliminating the constraint altogether. And,
- indeed, I cannot find any mention of such a constraint in the Fortran 90
- document.
-
- Thanks once again to Peter Montgomery for setting me straight on this
- issue.
-
- --
- J. Giles
-