Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: $Revision: 1.6.2.16 $; site ima.UUCP
Path: utzoo!watmath!clyde!bonnie!akgua!whuxlm!harpo!decvax!genrad!panda!talcott!harvard!bbnccv!ima!johnl
From: johnl@ima.UUCP
Newsgroups: net.lang
Subject: Re: Re: does Fortran 77 allow recursion?
Message-ID: <103600003@ima.UUCP>
Date: Thu, 22-Aug-85 10:46:00 EDT
Article-I.D.: ima.103600003
Posted: Thu Aug 22 10:46:00 1985
Date-Received: Sun, 25-Aug-85 02:26:40 EDT
References: <4152@alice.UUCP>
Lines: 23
Nf-ID: #R:alice:-415200:ima:103600003:000:1043
Nf-From: ima!johnl    Aug 22 10:46:00 1985


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.

You might hope that some Fortran systems that disallow recursion would at
least detect it and barf, by having an "active" flag for each routine.
But no, not in any compiler I've ever seen.

John Levine, ima!johnl