Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!a!jlg From: jlg@a.UUCP (Jim Giles) Newsgroups: comp.lang.fortran Subject: Fortran 8x, recursive procedures Message-ID: <522@a.UUCP> Date: 22 Mar 88 10:57:27 GMT Distribution: na Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 36 Keywords: Fortran 8x standard, recursive > The criterion for Fortran 8x features (in my opinion) should be to > certify existing practice or to extend the language in a significant > way. I will use this criterion throughout this discussion. There are a number of Fortran environments that already allow recursive subroutines and/or functions. The addition of recursion is something that is long overdue. Efficient implementations of any given algorithm will probably remain iterative, but recursion is often the most natural presentation of an algorithm and should be provided (if only to allow quick testing of ideas). The main question I have is: why is the keyword RECURSIVE required? The standard should just state that procedures may invoke themselves, either directly or indirectly. I can think of only two reasons that the RECURSIVE keyword was included. First, the committee wanted to make it possible for the compiler and loader to check that recursion is not unintentionally present. But, I have seen no implementation of Fortran (where recursion was allowed) that actually performs such checks. The second reason is that in spite of the introduction of SAVE in Fortran 77, many Fortran environments have not fully implemented stack-based code. Since stack-based code is absolutely required for recursion to work, the committee wanted to make it possible for the compiler to generate stack references ONLY for the recursive procedures. Non-recursive procedures would continue to work as before (and without the stack references they might run slightly faster). In any case, both (or neither) of these reasons might have been involved. It really doesn't matter a lot if the RECURSIVE keyword remains in the new standard. It just seemed to be unnecessary. J. Giles Los Alamos