[comp.emacs] Tail recursion in elisp

mleone@f.gp.cs.cmu.edu (Mark Leone) (08/02/89)

Does gnu-emacs lisp deal with tail recursion in a reasonable way?  In
particular, is it possible for a tail recursive function to cause a
stack overflow?  

How does the speed of a tail recursive function compare to a
corresponding iterative function?


Mark Leone
mleone@f.gp.cs.cmu.edu

liberte@m.cs.uiuc.edu (08/04/89)

GNU Emacs bytecompiles tail recursive functions in the naive way.
It just makes a call to the function.  So your stack may
overflow.  

Iteration is much faster than recursion in GNU Emacs.
A while loop is compiled into a conditional branch.

A bytecode optimizer would make an interesting project.

dan