next up previous contents
Next: Clearing items from Up: CHAPTER.3: PROCEDURES AND Previous: Multiple assignments

Some procedures which work on the stack

STACKLENGTH can be used to find out how many things are on the stack. When invoked it counts the number of items on the stack and then leaves that number on the stack, for example:

    2 + 3, 9 - 5, stacklength() =>
    ** 5 4 2
Notice that in Pop-11 a procedure which takes no arguments is invoked by writing its name followed by two parentheses.

DUP

This procedure merely duplicates the top element of the stack.

    1,2,3,4, dup() =>
    ** 1 2 3 4 4
SETSTACKLENGTH

setstacklength(N)

Increases or decreases the stack length to N, if necessary by removing items or adding occurrences of [], the empty list (because the procedure is used by the Poplog Lisp compiler). Examples:

    1,2,3,4, setstacklength(2), setstacklength(6) =>
    ** 1 2 [] [] [] []


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