MTS 8: LISP and SLIP in MTS
June 1976
however, include C, (D E), and all of its sublists, as well as all
the sublists of the top-level list.
NIL
The list of zero elements ( ) is equivalent to the atom NIL within
the LISP system. Thus, the CDR of (A) is ( ), or NIL. The result
of this dual interpretation is that NIL is treated as an atom for
most purposes, and as a list for some other purposes. For example,
the CONC function which accepts only list arguments, and the COPY
function, whose argument may be a list or an atom, both treat NIL
as the null list ( ).
The LISP Interpreter ____________________
LISP is an interpretive language. The system reads one S-expression,
or form, from its input stream, evaluates it, and prints out the value
computed, then reads another S-expression, etc. Since the top-level
controller calls READ to get an S-expression, EVAL to evaluate it, and
PRINT to print out the result, the top level function of LISP is often
referred to as a READ-EVAL-PRINT loop.
Input to LISP
Input to LISP is free format, with blanks, commas, periods,
parentheses, angle brackets ( and ), and ends-of-line acting as
separators. Any time a separator appears, it may be surrounded by
any number of blanks. Extra right parentheses may be inserted at
the beginning or the end of a top-level form; they are ignored.
For example:
)) (A B C D)))) = (A B C D)
If a semicolon (;) appears anywhere in an input line, the system
ignores the remainder of the line, and skips to the next line.
Thus, the semicolon is equivalent to an end-of-line. This allows
the user to put comments in his input file without the expense of
making an atom from every word.
Warning: The semicolon is an MTS carriage-control character which
causes a line printer to skip to a new page if it is the first
character in an output line.
Note: An exception is made to the treatment of the period as a
separator when it occurs in a legal floating-point number. In that
case, the period is interpreted as part of the number. To make a
dotted pair of two numbers, the period must be surrounded by
blanks. For example, (123.456) is a list of a single numeric atom,
while (123 . 456) is a dotted pair of two integers.
14 LISP

MTS 8: LISP and SLIP in MTS
June 1976
A special feature of LISP which is not strictly part of the LISP
syntax is the angle bracket. Any time a left angle bracket ()
occurs, it is treated as a normal left parenthesis, and the level
at which it occurred is remembered. When a right angle bracket ()
occurs, it has the effect of inserting enough right parentheses to
close out the most recent left angle bracket. A left angle bracket
may not be closed out by a normal right parenthesis. If angle
brackets are not balanced correctly, an error is generated.
In order to allow the incorporation of separator characters into
atom PNAMEs, LISP defines a special input convention. If a quote
character (") occurs at the beginning and the end of an atom name,
all characters which occur between the quotes are treated as the
PNAME of a single atom. The closing quotes must be part of the
same input line as the opening quotes; the quotes are not part of
the PNAME of the atom. For example, if the input stream contains
the atom name
"AB CD.EF"
an atom with the PNAME AB CD.EF is created.
If two quotes in a row appear within a quoted string, they are
interpreted as a literal quote. If quotes appear at the beginning
of an atom name, however, this generates a syntax error. For
example, if "ABC""DE" is read in, the literal atom ABC"DE is
created.
Quotes which appear strictly within an atom name have no special
significance, and are treated like any other character.
Operation of EVAL
Evaluation of LISP expressions is done by the function EVAL. If
the form being EVALed is an atom, then the value of the form is the
VALUE of the atom.
If the form is not an atom, it must be a list. The first element,
or the CAR of the list, specifies a function to be called. The
remaining elements of the list, or the CDR, represent the arguments
of the function. If the CAR of the form is an atom, then LISP
interprets it as the name of a function, and calls that function.
(It will be seen later that there are ways of invoking functions
other than a direct call.) For example, if the form read by LISP
is (ADD X Y), then the function ADD is called with the VALUE of X
as its first argument, and the VALUE of Y as its second argument.
Notice that, as in other languages, it is not the name of the
argument which is passed to the function, but its value. For this
reason, elements which actually appear in the form are referred to
as argument-designators, and the term "argument" is reserved for
the values which are actually passed to the function.
LISP 15
Previous Page Next Page