MTS 8: LISP and SLIP in MTS
Page Revised January 1983 June 1976
THIS
(STATUS (10 ABUF T)) Makes the current contents of ABUF a
prefix.
0
(TERPRI ABUF) This has no effect since the prefix
is not treated as buffer content.
NIL
(PRINT ’PRINT2 ABUF)
THIS IS A TEST PRINT2
PRINT2
(STATUS (10 ABUF NIL)) Disables the prefix.
14
(PRINT ’PRINT3 ABUF)
THIS IS A TEST The first TERPRI prints buffer con-
tents (no longer a prefix).
PRINT3
PRINT3
(PRINT ’PRINT2 ABUF)
PRINT2
PRINT2
Buffer Overflow Interception ____________________________
The user may, on an I/O call, specify a read or print intercept
function as an optional argument. The intercept must be a function
which takes one argument. If an intercept function is specified in a
call to READ, READLINE, or READCH, on any attempt to do a physical read
into the buffer, the intercept function will be called first. The IOARG
for that READ will be passed to the intercept function as its argument.
If an intercept function is specified in a PRINT, PRIN1, or TERPRI
call, on any attempt to do a physical write from the buffer, the
intercept function will be called first. The IOARG for that PRINT
operation is passed as the argument to the intercept function.
Upon return from an intercept function, the LISP system will complete
the I/O operation.
End-of-File Processing ______________________
Each LISP file has an EOF function, which will be called if an
end-of-file is encountered while reading from that file. An EOF
function may be attached to a file by calling the STATUS function.
50 LISP

MTS 8: LISP and SLIP in MTS
June 1976
An EOF function must be a function of one argument. When the
function is called, the IOARG for the READ operation will be passed to
it.
All files initially use the system EOF function, called EOF, which
causes the file to be closed. Whenever a file is closed, it is changed
to reference *MSOURCE*. An end-of-file encountered on *MSOURCE* in
conversational mode will cause the user to be prompted to continue. In
batch mode, an end-of-file on *MSOURCE* causes immediate termination of
execution. The value of the function EOF is NIL.
The action which should be taken on return from an EOF function is
determined by the value returned from the function. If the value
returned is non-NIL, the READ is aborted, and that value is returned as
the value of READ. If the value returned from the EOF function is NIL,
then the READ will be tried again.
READMACRO and PRINTMACRO Functions __________________________________
It is possible for the LISP user to define functions which will be
called whenever a particular atom or character is encountered in the
input stream, or whenever a particular atom appears in the output
stream. A READMACRO or PRINTMACRO function must be a function with one
dummy argument, which will be bound to the current IOARG when the
function is called. An atom is defined as a READMACRO or PRINTMACRO by
calling the STATUS function with the appropriate arguments.
READMACRO Atoms
(STATUS (2 HIT T)) defines the atom HIT as a READMACRO. If HIT is
encountered in the input stream during a READ operation, the
function associated with HIT will be invoked immediately.
Upon return from the HIT function, the following action will be
taken:
(1) If the value returned from HIT is an atom, then HIT will
simply be "spliced out" of the input stream, and the READ will
continue.
(2) If the value returned from HIT is a list, then the elements of
that list will be "spliced in" to the input stream in place of
HIT, and the READ will continue.
The READMACRO function may itself call READ, in which case the
S-expression immediately following the atom HIT in the input stream
will be returned. For example,
(DEFUN HIT (X) (COND ((ATOM (SETQ X (READ)))
(LIST (LIST X ’HIT)))
LISP 51
Previous Page Next Page