home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!mailer.cc.fsu.edu!sun13!sun13.scri.fsu.edu!adk
- From: adk@sun13.SCRI.FSU.EDU (Tony Kennedy)
- Newsgroups: comp.lang.fortran
- Subject: Re: function name as an argument
- Message-ID: <ADK.92Dec12114449@ds2.sun13.SCRI.FSU.EDU>
- Date: 12 Dec 92 16:44:49 GMT
- References: <1992Dec8.051134.5968@news.Hawaii.Edu>
- <1992Dec8.140008.20523@e2big.mko.dec.com>
- <BURLEY.92Dec8185030@apple-gunkies.gnu.ai.mit.edu>
- <1992Dec10.012254.3535@alchemy.chem.utoronto.ca>
- <1992Dec10.155427.2271@e2big.mko.dec.com>
- <1992Dec11.204152.28787@new
- Sender: news@sun13.scri.fsu.edu
- Organization: SCRI, Florida State University
- Lines: 32
- In-reply-to: jlg@cochiti.lanl.gov's message of 11 Dec 92 20:41:52 GMT
-
- >> J. Giles <jlg@cochiti.lanl.gov> and
- >> Steve Lionel <lionel@quark.enet.dec.com> write:
-
- lionel> PROGRAM DUMB
- lionel> character*10 func,arg
- lionel> external func
- lionel> call sub(func,arg)
- lionel> end
-
- lionel> SUBROUTINE SUB (func,arg)
- lionel> character*(*) func,arg
- lionel> arg = func()
- lionel> write(*,*)arg
- lionel> END
-
- lionel> FUNCTION FUNC()
- lionel> character*(*) func
- lionel> func = 'abcdefghijklmnopqrstuvwxyz'
- lionel> END
-
- lionel> How does SUB know how much to allocate for the function result
- lionel> of SUB? This isn't known at compile time, so the length has to
- lionel> be passed in to SUB somehow so that SUB can allocate the space
- lionel> at run-time.
-
- jlg> Nope, the space can be allocated statically when PROGRAM DUMB
- jlg> is compiled! The descriptor passed to SUB can contain the
- jlg> length of the space which has been allocated and a reference
- jlg> to that memory. This is the same information that needs to
- jlg> be passed if FUNC were called *directly* by the main program.
-
- This is not possible because the three routines can be compiled separately.
-