MTS 8: LISP and SLIP in MTS
June 1976
(4) If either DEFN1 or DEFN2 is NIL, then that portion of the BUG
will be ignored and the function A will be invoked or exited
without intervention.
Example:
A BUG is put on the function COUNT, to trace the entry and exit,
and to print out the arguments.
(DEFUN COUNT (L N) (COND ((NOT L) N)
((COUNT (CDR L) (ADD1 N)))))
(DEFINE (COUNT BUG ((FLAMBDA (ARGS)
(PRINT ’ENTRY-TO-COUNT)
(PRIN1 ’ARGUMENTS:)
(PRIN1 ARGS) (TERPRI))
.(LAMBDA (RET)
(PRINT ’EXIT-FROM-COUNT)
(PRIN1 ’VALUE:) (PRIN1 RET)
(TERPRI)))))
Arrays ______
The basic form of a LISP array definition is
(DEFINE (A ARRAY (A1...AN) FILL))
This is the basic form of a LISP array definition. In this example, A
will be defined as an N-dimensional array with subscript bounds A1...AN.
A1...AN must be atoms whose VALUEs are integers. If a fourth argument,
FILL, is given, the initial value of each element in the array will be
set to that structure. Otherwise, each element in the array is
initially set to NIL.
An array definition associated with an atom operates like a function
definition for that atom. A pointer to the appropriate access code is
stored on the property-list of the atom, under the indicator SUBR. The
value of an array element is obtained by invoking the "function", with
the appropriate subscripts as arguments. For example,
(A 1 (ADD 3 5) (CADR ’(B 3)))
will evaluate to the array element A(1,8,3). It should be noted that
since an atom may be defined as a function in only one way at a time,
defining A as an array will negate any other function definition A may
have had, and defining A as a function will negate the definition of A
as an array.
To set the value of an array element, the SETA function is used:
42 LISP