next up previous contents
Next: Removing unwanted items Up: CHAPTER.3: PROCEDURES AND Previous: Some procedures which

Clearing items from the stack (erase)

ERASE removes one item from the stack, for example:

    2 + 3, 9 - 5, erase() =>
    ** 5
or

    5 + 5, 66, erase(), 8 * 8, 10 - 5, erase() =>
    ** 10 64
The assignment arrow followed by ";" or "," (or any other expression terminator) has the same effect as "erase()". Thus:

    5 + 5, 66, -> , 8 * 8, 10 - 5, -> =>
    ** 10 64
Whether you use this or "erase" is a matter of taste. (However, "erase" has to be used when a stack-clearing procedure is referred to explicitly, e.g. assigned to another procedure as input.)

ERASENUM takes an integer and removes that number of items from the stack. E.g.

    1,2,3,4,5,6; erasenum(2) =>
    ** 1 2 3 4
Which is equivalent to: erasenum(1,2,3,4,5,6,2) =>

SETPOP clears the stack. For example;

    2 + 3;
    setpop();
    stacklength() =>
    ** 0
Setpop does many others things besides clear the stack; it also aborts any running program. It also prints a message whenever it is called. An immediate call of setpop occurs whenever you type CTRL-C (unless you have redefined the procedure INTERRUPT, described later).

For more on procedures that manipulate the stack, see REF STACK



Aaron Sloman
Fri Jan 2 03:17:44 GMT 1998