MTS 8: LISP and SLIP in MTS
June 1976
If no Ei matches EQUTHING, then FAIL is
evaluated, and its value is returned. It is
important to understand that the last argument
of SELECT is always treated as a form to
evaluate in case of failure, and never as a
(E1 S1...SN) type of expression. Thus, a FAIL
expression must be given.
(SELECT (GET ’BOOK ’COLOR)
(’BLUE (BLUEFN ’BOOK))
(’RED (REDFN ’BOOK))
(’GREEN (GREENFN ’BOOK))
(PROGN (PRINT ’(ERROR: BOOK ILLEGAL COLOR))
(ERRCOLOR ’BOOK)))
(PROG LA S1...SN)
(GO A) The PROG function allows the LISP user to
write subroutine-like sequences of LISP code,
with branching, and with the ability to exit
and return a value at any point.
LA is a list of local or PROG variables. The
PROG variables are bound to NIL upon entry to
the PROG, and unbound to their previous values
upon exit from the PROG. Thus, the PROG
variables may be used within a PROG as though
they were distinct from anything outside the
PROG. Note that this "protection" of PROG
variables applies only to their VALUEs. If
the property list of a PROG variable is
changed within a PROG, the change will not be
undone upon exit from the PROG. The PROG
variable list may be NIL, but it may not be
omitted.
S1...SN is a sequence of forms to be evaluated
in order. However, if any of these forms are
atoms, they are not evaluated, but rather are
interpreted as statement labels. If a form
(GO A) appears in the PROG, and A is used as a
statement label in the PROG, then evaluating
(GO A) causes the flow-of-control to be trans-
ferred to the form which appears after the
label A.
If the flow-of-control "drops through" the
last form of the PROG, then the value of that
form will be returned as the value of the
PROG. However, if the last form of the PROG
is an atom, then the atom itself, rather than
its VALUE, is returned as the value of the
PROG.
32 LISP