next up previous contents
Next: 3.3.6 Unknown Locations and Up: 3.3 Stack Frames Previous: 3.3.4 Funny Frames

3.3.5 Debug Tail Recursion

     

Both the compiler and the interpreter are ``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 theses 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 (section 3.5.)

For a more thorough discussion of tail recursion, see section 5.5.



Raymond Toy
Mon Jul 14 09:11:27 EDT 1997