Next: Unknown Locations and Interrupts, Previous: Function Names, Up: Stack Frames

#### 5.3.4 Debug Tail Recursion

The compiler is “properly tail recursive.” If a function call is in a tail-recursive position, the stack frame will be deallocated at the time of the call, rather than after the call returns. Consider this backtrace:

         (BAR ...)
         (FOO ...)

Because of tail recursion, it is not necessarily the case that `FOO` directly called `BAR`. It may be that `FOO` called some other function `FOO2` which then called `BAR` tail-recursively, as in this example:

         (defun foo ()
           ...
           (foo2 ...)
           ...)

         (defun foo2 (...)
           ...
           (bar ...))

         (defun bar (...)
           ...)

Usually the elimination of tail-recursive frames makes debugging more pleasant, since these frames are mostly uninformative. If there is any doubt about how one function called another, it can usually be eliminated by finding the source location in the calling frame. See Source Location Printing.

The elimination of tail-recursive frames can be prevented by disabling tail-recursion optimization, which happens when the `debug` optimization quality is greater than `2`. See Debugger Policy Control.