Search                        Top                                  Index
HELP EXPRASS                                                   A.Sloman 1982

-- EXPRESSIONS AND ASSIGNMENT -----------------------------------------------

There are many sorts of expressions in POP-11. A quoted word, a number, a
list expression, a string expression and a vector expression are examples of
CONSTANT expressions, e.g.

    word:       "cat"
    number:     99
    list:       [a b c]
    string:     'father christmas'
    vector:     {a b c}

For more on these see HELP files for

An expression may also be either a single VARIABLE, e.g.

    x, list5

or composed of a procedure name applied to other expressions, e.g.

    conspair(x, list5)

including 'infix' procedure names, like '+', '-'

    x + 5
    66 + 99 - 5

An expression can be thought of as naming some object, e.g. the thing
directly specified (e.g. a word or number) or the value of the variable, or
the result of applying a procedure to some arguments. The object named can be
ASSIGNED to a variable, e.g.

    66 -> x;
    conspair("cat", []) -> list;

"->" is the assignment arrow. The expression to the left of it names an
object. That object is put on the stack, a specially reserved part of the
memory of the computer. "->" copies the contents of the top of the stack to
some other location specified by what follows "->". The item is also removed
from the stack. In the above examples, the item is merely stored in a
variable, X, or LIST. Assignment can also be used to transfer an item to a
location in a datastructure, e.g. a list, or vector. For instance, if the
value of the variable L is a list of 3 or more elements, then

    -> l(3)

transfers the element on the top of the stack to become the third item of the

Procedure arguments and results are transferred via the STACK. E.g. if
<e1> and <e2> are expressions, and PROC is the name of a procedure,
which takes two arguments and returns a result, then

    proc(<e1>, <e2>)

will mean, put the object denoted by the expression <e1> on the stack, then
put the object denoted by <e2> on the stack (so that there are then two
things on the stack), then execute the instructions in the procedure PROC.
PROC will remove the two items from the stack, and when it has worked out its
own result, will put that on the stack. This can then be assigned to a
variable if desired, e.g.

    proc("cat", "dog") -> x5;

Alternatively, the result of PROC can be left on the stack and used as the
argument for another procedure, say, PROC2, as in:

    proc2(proc("cat", "dog"))

in which case PROC2 will remove the result of PROC1 from the stack, and, if
it produces a result, will leave that on the stack.

For more information, see TEACH *POPSUMMARY.

Procedures in POP11 may in fact put more than one result on the stack.
There are various special procedures for manipulating the stack (see HELP

See also HELP
    * ASSIGN    -   use of the assignment arrow '->'
    * NDASSIGN  -   assignment without removing the value from the stack