Path: utzoo!mnetor!uunet!husc6!cmcl2!beta!a!jlg From: jlg@a.UUCP (Jim Giles) Newsgroups: comp.lang.fortran Subject: recursion in general Message-ID: <531@a.UUCP> Date: 24 Mar 88 08:50:03 GMT Distribution: na Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 21 Keywords: recursion, addressing > 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