MTS 8: LISP and SLIP in MTS
June 1976
Before we consider the various operations in SLIP, several points
must be discussed.
Programming Conventions (SLIP with FORTRAN IV) ______________________________________________
A FORTRAN subroutine-type subprogram does not return values other __________
than those of the variables, either in COMMON or in the list of the
subroutine arguments. A function-type subprogram, on the other hand, ________
returns, in addition, a single value, that of its name, as if the name
were a variable. This represents the main programming advantage of
functions: they can be nested in arbitrary depth in the argument list
of other subprograms (no recursive calls). Further, a function can be _____
CALLed like a subroutine, in which case the returned value is, of
course, lost. Finally, the results of the processes in a subroutine can
be obtained by including the subroutine name in a FORTRAN arithmetic
statement as if it were a function. A function must always have at
least one dummy argument lest it be mistaken for a variable.
The FORTRAN mode conventions need to be explained. Many SLIP
subprograms disregard the mode of the subprogram arguments but they are
concerned with addressing conventions. To avoid unwanted conversions,
the functions REALS and INTGER may be used for the output of ill-named
functions. For example, as we will see later, the subprogram TOP(LST)
retrieves the datum of the top cell of the list with alias name LST.
The cell’s datum may contain a list alias. If TOP is called as a
function, it delivers the contents of the top cell as its value. If
this value is an integer, we do not want it to be converted into a
floating-point number. To avoid this we use assignment statement
I=INTGER(TOP(LST))
to obtain the integer stored in the datum. Similarly, the function
REALS (REAL-short) delivers the single-precision REAL value without
conversion.
Let us consider a significant difference between FORTRAN and SLIP.
In FORTRAN, we manipulate contents of words that have symbolic names.
For example, the instruction
A = B+C
adds the contents of the words with symbolic addresses B and C and
places the sum into a word with symbolic address A. In SLIP, both the
contents and the addresses of words can be operands.
The following notation will be used uniformly in the arguments of
SLIP subprograms.
118 SLIP

MTS 8: LISP and SLIP in MTS
June 1976
Symbol Meaning Remark ______ _______ ______
X FORTRAN variable Symbolic address of a computer word of
any contents, mode, or format.
LST Alias name of a Symbolic address of a DOUBLE PRECISION
list computer word that contains, in re-
peated form the cell name of the first
word of the Header cell.
CADR or FORTRAN variable Symbolic address of a computer word or
MADR that contains, in integer format, the
name of a SLIP cell. CADR is an
INTEGER variable. Note that a name,
either in list name format or as an
integer in the left-word can be
offered as a MADR, a DOUBLE PRECISION
variable. [Note a MADR can always be
offered where a CADR is expected. The
converse is not true.]
KADR FORTRAN variable Symbolic address of a computer word
that contains, in integer format, the
machine address of another word.
NRD Alias name of a Symbolic address of a computer word
reader that contains, in integer format, the
name of the top cell of a Reader
stack.
A list notation which will often be convenient to represent list
structures is the so-called string format. For example, the following
two sets of strings are equivalent. On one hand
List A: (S3,Q1,(R2,R4),T1,(),(S1,T2))
List B: (U2,(V3,V1,(W0,Q2)),S2)
and on the other
List A: (S3,Q1,List C,T1,List D,List E)
List B: (U2,List F,S2)
List C: (R2,R4)
List D: ()
List E: (S1,T2)
List F: (V3,V1,List G)
List G: (W0,Q2)
As shown above, parentheses delimit lists and sublists; commas (or,
according to another notation, spaces) separate elements on a list,
which are written horizontally in a sequential manner. Direct input of
lists and list structures is similar to this in format (see RDLSTA and
PRLSTS).
SLIP 119
Previous Page Next Page