jlg@a.UUCP (Jim Giles) (03/24/88)
> Plain-vanilla UNIX f77 (not exactly a paradigm of efficiency) will, in fact, > produce significantly faster and somewhat smaller code when stack references > are forced (via the extension storage class AUTOMATIC) than the default, > where it will use static data. It is faster on many machines to reference > memory indexed with small offsets from a register (i.e. the stack pointer) > than it is to reference it by absolute address. So, stack-based code > is a win-win situation with respect to both efficiency and recursion. -- > |------------Dan Levy------------| This is a problem with your compiler. ALL data could be referenced with the faster instructions even without putting it on the stack. It just requires loading the pointer to the static local data area at the start of a given procedure. Many machines DON'T run faster with indexed addressing though. Either way, this is not related directly to recursion. All else being equal, recursion is generally slower than iteration. If not, why is so much effort devoted to automatic recursion elimination in some languages? J. Giles Los Alamos
mcdonald@uxe.cso.uiuc.edu (03/28/88)
>We are extending Fortan for hypercubes and we have been rummaging around >the standard some. There seems to be no prohibition to recursion. >The 1977 FORTRAN standard, ANSI x3.9-1978 says (page 15-1, lines 55-56): > "A subprogram must not reference itself, either directly or indirectly." This is a restriction on CONFORMING PROGRAMS. It does not prevent writing compilers that allow recursion. It just says that a program that uses recursion is not required to work. >Recursion is explicitly allowed in Fortran 8x. When it is explicitly declared. My personal opinion is that it is good to allow recursion, but also good to require it to be declared; it might be that some machines run faster if recursion is prohibited. Doug McDonald