Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!mangoe From: mangoe@umcp-cs.UUCP (Charley Wingate) Newsgroups: net.lang Subject: Re: does Fortran 77 allow recursion? Message-ID: <1349@umcp-cs.UUCP> Date: Fri, 23-Aug-85 01:15:17 EDT Article-I.D.: umcp-cs.1349 Posted: Fri Aug 23 01:15:17 1985 Date-Received: Sat, 24-Aug-85 19:43:59 EDT References: <103600003@ima.UUCP> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 29 In article <103600003@ima.UUCP> johnl@ima.UUCP writes: >The Fortran 77 standard specifically disallows recursion. Section 15.2 >on "Referencing a Function" says: > A subprogram must not reference itself, either directly > or indirectly. >(Subprogram is previously defined to be a function or a subroutine.) >This is a historical artifact that the Fortran community is stuck with. >Existing Fortran compilers on IBM 370 machines use a calling discipline >where all of the register and return address save areas are allocated >statically. (When they came up with the 360 calling sequence, they didn't >seem to think that recursion or stacks were important.) PL/I later came >up with a modified semi-compatible version of that linkage which does use >a stack, does allow recursion, and is much slower. Ergo, if you want your >Fortran programs to be portable and standard, don't recurse. Static allocation is also enforced by the common use of data statements to initialize variables which are then changed during calls to the subroutine. Every Fortran compiler I've ever seen allocates storage so that the changed values persist (although some linkers manage to defeat this under the right circumstances). This feature is quite commonly used to have some one-time initialization performed for the routine. So it looks to me like any Fortran compiler which wants to offer recursion, even as an extension, must provide user control of whether allocation is static or not. Charley Wingate umcp-cs!mangoe