[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tail recursion optimization

    Date: Tue, 03 Jun 86 06:27:53 PST
    From: franz!fimass!jkf@kim.Berkeley.EDU (John Foderaro)

     To answer earl's question: yes, a self-tail-recursive call is made
    with a jump to the beginning of the function code.

     I agree with Rob, this is an important optimization and 99% of the
    time is it precisely what you want.  I'd suggest that the Common
    Lisp Standard state that within the defun of foo, there is an impliclit 
    (declare (inline foo))
    and if the user plans on redefining foo while executing foo, it is his
    burden to (declare (notinline foo)).

Inline is orthogonal to tail recursion optimization.
	(defun foo (a b) (declare (inline foo)) (foo a (+ a b)))
is equivalent to
	(defun foo (a b) (+a (+ a (+ a (+ a ...)))))
and not
	(defun foo (a b) (loop (psetq a a b (+ a b))))