home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / fortran / 4702 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.2 KB  |  54 lines

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