Recursive Execution

Each time the function fact is entered, a new binding of n to its current value is created. These bindings are held on a stack, so that the new binding does not replace the old value of n, but shadows it. When the function fact exits, the binding of n is removed from the stack, leaving the previous value.

The special function trace is very useful for seeing the arguments and results of recursive calls:

   : (trace fact)

: (fact 3) Entry (fact 3) |Entry (fact 2) | Entry (fact 1) | Entry (fact 0) | ==> 1 | ==> 1 |==> 2 ==> 6 6

: (untrace)


Contents    Page-10    Prev    Next    Page+10    Index