MTS 8: LISP and SLIP in MTS
June 1976
Note: In general, the term "LAMBDA-expression" is a generic term
including the NLAMBDA and FLAMBDA-expressions.
Named LAMBDA-Expressions (LABEL-Expressions) ____________________________________________
LISP provides a special syntax for writing LAMBDA-expressions which
are capable of calling themselves. This is the LABEL-expression. The
basic form of a LABEL-expression is:
(LABEL NAME LAMBDA-EXP)
where NAME may be any atom. NAME is first bound to the LAMBDA-
expression which is the second argument of the LABEL-expression. The
evaluation continues as though the LAMBDA-expression had been given.
The effect is that NAME is temporarily defined as the LAMBDA-expression,
provided that NAME is not already defined as a function within the
system.
Thus, within the LAMBDA-expression, explicit calls to NAME may be
made, which will invoke the LAMBDA-expression recursively. For example,
((LABEL COUNT (LAMBDA (L N)
(COND ((NOT L) N)
((COUNT (CDR L) (ADD1 N))))))
’(A B C D E) 0) = 5
This LABEL-expression temporarily defines a function COUNT, which will
return the sum of its second argument and the number of elements in its
first argument.
Accessing Defined Functions ___________________________
When an atom is to be used as a function name, a link to the function
definition is maintained on the property-list of that atom. The
following special system indicators are used to mark function
definitions:
SUBR
NSUBR
FSUBR
EXPR
BUG
SUBR, NSUBR, and FSUBR are indicators which mark the three types of
built-in LISP functions. SUBRs take their arguments EVALed, like
LAMBDA-functions; NSUBRs take their arguments without evaluation as do
NLAMBDA-functions, and FSUBRs take their arguments in a list, like
38 LISP