Next: , Up: Local Call   [Contents][Index]


5.6.1 Self-Recursive Calls

Local call is used when a function defined by defun calls itself. For example:

(defun fact (n)
  (if (zerop n)
      1
      (* n (fact (1- n)))))

This use of local call speeds recursion, but can also complicate debugging, since trace will only show the first call to fact, and not the recursive calls. This is because the recursive calls directly jump to the start of the function, and don’t indirect through the symbol-function. Self-recursive local call is inhibited when the :block-compile argument to compile-file is nil (see compile-file-block.)