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

tail recursion and debugging



    On the other hand, maybe the use of the stack as the primary
    source of information about the history of the computation is
    actually an unfortunate historical accident.  Maybe we should, as
    GLS hints, find other ways of recording debugging information as
    it goes by.  A FIFO buffer showing some number of the most recent
    procedure invocations with their arguments would often be much
    more useful than a stack backtrace, because after all, in a stack
    backtrace there is no information whatever about values computed
    by frames that have been returned from.

The MIT Scheme interpreter uses a history cache mechanism to record
reductions for some finite number of pending subproblems.  It is
implemented as a set of circular buffers connected by a circular
spine, and the actual workings are pretty hairy, so it's only really
appropriate for an interpreter, but it is sometimes a real life-saver.
Because it's finite (and even worse, because of the invalidation
mechanism that we use), sometimes it does not contain the desired
information.  However, users can, on demand, increase it's size
parameters before an execution, and often this allows the user to find
the wormhole through which her/his programs are jumping into
hyperspace.