next up previous
Next: 7. LIST STRUCTURES Up: 6. RUNNING THE LISP Previous: 6.3 Error Diagnostics

6.4 The Cons Counter and Errorset

The cone counter is a useful device for breaking out of program loops. It automatically causes a trap when a certain number of conses have been performed.

The counter is turned on by executing count[n], where n is an integer. If n conses are performed before the counter is turned off, a trap will occur and an error diagnostic will be given. The counter is turned off by uncount[NIL]. The counter is turned on and reset each time count[n] is executed. The counter can be turned on so as to continue counting from the state it was in when last turned off by executing count[NIL].

The function speak[NIL] gives the number of conses counted since the counter was last reset.

errorset is a function available to the interpreter and compiler for making a graceful retreat from an error condition encountered during a subroutine.

errorset[e;n;m;a] is a pseudo-function with four arguments. If no error occurs, then errorset can be defined by

errorset[e;n;m;a] = list[eval[e;a]]

n is the number of conses permitted before a cons trap will occur. The cons counter is always on during an errorset; however, when leaving the errorset the counter is always restored to the value it had before entering the errorset. The on-off status of the counter will also be restored.

When an error occurs inside an erroraet, the error diagnostic will occur if m is set true, but will not be printed if m is NIL.

If an error occurs inside of an errorset. then the value of errorset is NIL. If variables bound outside of the errorset have not been altered by using cset or set, and if no damage has been done by pseudo-functions, it may be possible to continue computation in a different direction when one path results in an error.


next up previous
Next: 7. LIST STRUCTURES Up: 6. RUNNING THE LISP Previous: 6.3 Error Diagnostics