Stanford LISP 1.6 Manual - Software Preservation Group

Transcription

Stanford LISP 1.6 Manual - Software Preservation Group
n
0
SAILON 28,2
*
rLw
0
ABSTRACT
.
.
I
I
5
a
.
T h i s manual d e s c r i b e s t h e ~ ~ ~ - 6 LISP
/ 1 0 1 . 6 s y s t e m d e v e l o p e d by
t h e S t a n f o r d A r t i f i c i a l I n t e l l i g e n c e P r o j e c t . The manual i s n o t a
*
t u t o r i a l on LISP b u t i s i n t e n d e d t o s u p p l e m e n t e x i s t i n g LISP t u t o r i a l s . ,
D i f f e r e n c e s from o t h e r LISP s y s t e m s a n d new f u n c t i o n s a n d f e a t u r e s are , " ' .
d e s c r i b e d i n o r d e r t o p r e p a r e one t o u n d e r s t a n d and ,u s -e .t h i s LISP
system.
) .
.,
"
q
ACKNOWLEDGMENT
,,
i.
.
*
/
. .. .
'.
T h i s manual s u p e r c e d e s . and r e p l a c ' e s SAILONS 1*, 4 ; -28 and. 28.1.
.
.
. . *
*
.
I
..
.
..
.
,
.
The S t a n f o r d A1 LISP 1 . 6 s y s t e m i s a n a d a p t a t i o n by J o h n R. ~ l i e s i
Sections of
and Lynn H. Quam o f a LISP system' d e v e l o p e d a t M.I.T.
'
t h i s document were c o n t r i b u t e d by J o h n R. A l l e n a n d Anthony C. Hearn..T h i s work was s u p p o r t e d by t h e Advanced Research P r o j e c t s Agency of
* .
t h e O f f i c e o f t h e S e c r e t a r y o f Defense u n d e r C o n t r a c t SD-183,
.
>
.
SAILON No 28.2
TABLE OF CONTENTS
..........................
......................
Abstract
Acknowledgement
CHAPTER
1 INTRODUCTION . . * * . . . * . * * *
1.1 Document Conventions
2 INTERACTIVE USE OF THE SYSTEM
2.1 The Top Level
2.2 Special Control Characters
3
IDENTIFIERS
3.1 Property Lists
3.2 TheOblist
4 NUMBERS
4.1 Integers
4.2 Reals
5
S-EXPRESSIONS
.
.
.
.
.
6 9
. . . ... .. .. . .. .. . . . . . . .
............
..........;......
...........
....................
..................
..................
......................
......................
....................
....................
L&4BBAEXPt#ZB5ION§
s
*
s
s
s
s
s
s
s
s
s
e
e
s
........................
....................
....................
......
............
...............
................
.............
.............
....................
............
.............
........
.
..
..
.
..
.
........
9
#
7
8
9
.
.
.
6.1 EXPRs
6.2 FEXPRs
6.3 LEXPRs
6.4 MACROS
..............
EVALUATION OF S-EXPWSSIONS
7.1 Variable Binding
7.2 The A-List
,7.3 Functional Arguments
CONDITIONAL EXPRESSIONS
PREDICATES
9.1 S-Expression Predicates
9.2 Numertcal Predicates
9.3 Boolean Predicates
FUNCTIONS OF S-EXPRESSIONS
10.1 S-Expression Building Functions
10.2 S-Expressions Fragmenting Functions
10.3 S-Expression Modifying Functions
10.4 S-Expression Transforming Functions
10.5 S-Expression Mapping Functions
10.6 S-Expression Searching Functions
10.7 Non-Standard S-Expression Functions
FUNCTIONS ON IDENTIFIERS
11.1 Property List Functions
11.2 Oblist Functions
11.3 Identifier Creating Functions
FUNCTIONS ON NUMBERS
12.1 Arithmetic Functions
12.2 Logical Functions
......
.........
...
.......
..........
1
Page
i...
i.,
SAILON 28.2
,CHAPTER
13. PROGRAMS
$
13.1 SET a n d SETQ
i.
t.
1 4 . INPUT/OUTPUT
1 4 . 1 D e v i c e S e l e c t i o n a n d C o n t r o l rn
14.2 I n p u t . .
14.3 Output
15. ARRAYS . . . . . . . . . . . . . . . . . . . . . . . . . 1 5 - 1
Page
13.1
13-2
.... . . . . . . . . . . 14-1
. . . . . . . * . . . . . . . . . . .. . . 14-1
. . . . . . . . . . . . . . . . . . . . . . 14-3
14-5
....
. l o
APPENDIX A.
APPENDIX
APPENDIX
APPENDIX
APPENDIX
APPENDIX
APPENDIX
APPENDIX
APPENDIX
B.
C.
D.
E.
F.
G.
H,
I.
APPENDIX J,
DIFFERENCES FROM STANDARD LISP
byAnthonyC.Hearn
ERROR CONDITIONS AND CONTROL
MEMORYALLOCATION
GARBAGECOLLECTION
COMPILED 'FUNCTION LINKAGE AND ACCUMULATOR USAGE
THE LISP COMPILER
THELISPASSEMBLER-LAP
TIjELOADER
.
~
.
~
.
.
.
.
.
~
.
~
.
THE LISP EDITOR
ALVINE
*
byJohnR.Allen
BIGNUMS
ARBITRARY PMCISION INTEGERS
--- -
-
-
-
- -
........... ...
0
l
iii
.
~
e
o
~
SAILON 28.2
CHAPTER 1
INT RODUCTION
This manual i s intended t o e x p l a i n t h e i n t e r a c t i v e LISP 1.6 system
which has been developed f o r t h e P D P - ~ / ~ O a t t h e Stanford U n i v e r s i t y
A r t i f i c i a l I n t e l l i g e n c e P r o j e c t . It i s assumed t h a t t h e r e a d e r i s
f a m i l i a r with e i t h e r some o t h e r LISP system o r t h e LISP 1.5 PRIMER by
Clark Weissman. Users who a r e f a m i l i a r w i t h another system should s e e
Appendix A: Differences from Standard LISP.
The LISP 1.6 system described has a s a s u b s e t most of t h e f e a t u r e s
and f u n c t i o n s of o t h e r LISP 1.5 systems. I n a d d i t i o n , t h e r e a r e s e v e r a l
new f e a t u r e s such a s an a r b i t r a r y p r e c i s i o n i n t e g e r package, a n S-expres s i o n e d i t o r , up t o 14 a c t i v e input-ouput channels, t h e a b i l i t y t o c o n t r o l
t h e s i z e of memory spaces, a standard r e l o c a t i n g l o a d e r t o load assembly
language o r compiled programs, e t c
.
/
This system uses a n i n t e r p r e t e r ; hobever t h e r e i s a l s o a compiler
which produces machine code. Compiled f u n c t i o n s . a r e approximately t e n
times a s f a s t and a l s o t a k e l e s s memory space.
This manual i s organized i n a f u n c t i o n a l manner. F i r s t t h e b a s j c
d a t a s t r u c t u r e s a r e d e s c r i b e d ; then t h e f u n c t i o n s f o r o p e r a t i n g on
them. The appendices p r e s e n t more d e t a i l e d information on t h e system,
i t s i n t e r n a l s t r u c t u r e , t h e compiler, and s e v e r a l a u x i l i a r y packages,
'
I
1.1 DOCUMENT CONVENTIONS
1.1.1
REPRESENTATION CONVENTIONS
I n t h e d e s c r i p t i o n of d a t a s t r u c t u r e s , t h e following n o t a t i o n a l
conventions w i l l be used;
r e p r e s e n t s a 36-bit word i n
FREE STORAGE w i t h 2 1 8 - b i t
pointers.
I
1
1
I
:
means
-
-.
-
- ,.
.
- - -
-.
. .
r e p r e s e n t s a 3 6 - b i t .word - i n
FULL WORD SPACE.
'
.
'-
..
SAILON 28.2
1.1.2
SYNTAX CONVENTIONS
A m o d i f i e d BNF w i l l be used t o d e f i n e s y n t a x e q u a t i o n s . L i t e r a l
( t e r m i n a l ) s t r i n g s w i l l be e x p l i c i t l y q u o t e d w i t h I'
Non-terminal
P a r e n t h e s e s o c c u r around
syntax r u l e s a r e n o t bracketed w i t h c a n d
optional constructs.
>.
1.1.3
.
CALLING SEQUENCE CONVENTIONS
C a l l i n g s e q u e n c e s t o LISP f u n c t i o n s a r e p r e s e n t e d i n S - e x p r e s s i o n
form, w i t h t h e CAR o f t h e S - e x p r e s s i o n b e i n g t h e name o f t h e f u n c t i o n .
An argument t o a f u n c t i o n i s e v a l u a t e d u n l e s s t h a t argument i s s u r r o u n d e d
by q u o t e s ('I) i n t h e c a l l i n g s e q u e n c e d e f i n i t i o n . Quotes mean t h a t t h e
f u n c t i o n i m p l i c i t l y QUOTES t h a t argument.
Examples
(SETQ "ID"
V)
(QUOTE "v")
I D is not evaluated, but V is evaluated.
V is not evaluated.
@
1.1.4
OTHER CONVENTIONS
The b l a n k c h a r a c t e r '(ASCII 40) i s i n d i c a t e d by
for clarity.
'Id'
when a p p r o p r i a t e
SAILON No. 28.2
CHAPTER 2.
INTERACTIVE USE OF THE SYSTEM
This c h a p t e r a t t e m p t s t o e x p l a i n how t o use t h e LISP system i n t h e
i n t e r a c t i v e time s h a r i n g environment of t h e ~ ~ ~ - 6 / 1 0 .
2.1
THE TOP LEVEL
The t o p l e v e l of t h i s system does n o t use EVAIQUOTE as do many
systems. However, EVALQUOTE may be d e f i n e d a s follows:
(DE EVALQUOTE NIL
(PROG NIL
L
(TERPRI)
(PRINT (EVAL (CONS (READ) (MAPCAR
(FUNCTION (LAMBDA (X) (LIST (QUOTE QUOTE) X ) ) )
(READ) 1) ) )
(GO L)))
'
The t o p l e v e l of LISP i s e q u i v a l e n t t o :
(PROG N I L
L
(TERPRI)
(PRINT (EVAL (READ)))
(GO L))
D
A l l examples a t t h e t o p l e v e l assume t h i s d e f i n i t i o n .
The f o l l o w i n g d i a l o g shows how t o l o g i n t o t h e time-sharing system,
s t a r t t h e LISP system, and i n t e r a c t w i t h i t a t t h e t o p l e v e l . Under"t " means c a r r i a g e - r e t u r n and l i n e l i n e d c h a r a c t e r s a r e typed by LISP.
feed. " $ I 1 means altmode.
log i n
starting
LIS P
examples
at'
top
leve l
Give your project-programmer
number
Core s i z e may be s p e c i f i e d .
See n o t e 1.
Memory a l l o c a t i o n c a n be
s p e c i f i e d . See n o t e 2.
T and NIL always e v a l u a t e t o
themse l v e s
You a r e t a l k i n g t o EVAL.
This READS t h e f i l e SYS:SMILE
.
, " 2 : ~ ~ 1 ~ f 6 d ( d a t of
e system),
SMILEFNS ,
<a longysequence of out
(CONS 1 (QUOTE A)) $
2
The o u t p u t c a n be s u p p r e s s e d
w i t h TO.'
SAILON No. 28.2
.
Note 1.
For l i m i t e d use of t h e LISP system, type R LISPf
I f more c o r e i s needed, t y p e R LISP n
, where n is t h e
d e s i r e d number of 1024 word b l o c k s . d
Note 2.
For l i m i t e d u s e ,
a f t e r ALLOC?.. To a l l o c a t e memory
s p a c e s type Y.
The a l o c a t i o n procedure is e x p l a i n e d i n
Appendix C.
typef'
I
0
2,2
d
SPECIAL TELETYPE'CONTROL CHARACTERS
The time s h a r i n g system t r e a t s many c o n t r o l c h a r a c t e r s in.s p e c i a l
ways. For a complete d i s c u s s i o n of ' c o n t r o l c h a r a c t e r s s e e t h e PDP-10
TIME SHARING MONITOR MANUAL.
B r i e f l y , t h e following c o n t r o l c h a r a c t e r s
should be u s e f u l fn LTSP.
t e l e type
I11 d i s p l a y
tC
meaning
CALL
'
S t o p t h e job and t a l k t o t h e
time s h a r i n g system.
0
'
Suppress console printout
u n t i l an input is requested.
3
Delete t h e e n t i r e i n p u t l i n e
now being typed,
(Only w i t h
(DDTIN NIL)).
'r
Stop t h e LISP i n t e r p r e t e r and
return control t o the top
l e v e l of LISP.
Only effective
when LISP i s a s k i n g f o r c o n s o l e
input.
(
rubout
Delete t h e l a s t c h a r a c t e r
typed.
(For (DDTIN T) s e e
'
14.2.1).
*
..
SAILON No. 28.2
CHAPTER 3 .
IDENTIFIERS
I d e n t i f i e r s a r e s t r i n g s of c h a r a c t e r s which taken t o g e t h e r
r e p r e s e n t a s i n g l e atomic q u a n t i t y .
Syntax :
ignored-character
: := c a r r i a g e - r e t u r n
...=
. ll(11 I
delimiter
tab
....=
character
fl)fl
I
I
1 1 ~ 1 1
1
11/11
1
I
line-feed
blank
- .,
I
altmode
(any ASCII c h a r a c t e r o t h e r than n u l l and
rubout)
digit
::=
letter
identifier
. .=
..
....=
....=
.- =.
(any c h a r a c t e r n o t a d i g i t , n o t a delimLter,
and not an ignored-character)
letter
identifier lettbr
identifier digit
'I/"
--
.
'
character
: := i d e n t i f i e r
It/"
character
Semantics :
I d e n t i f i e r s a r e normally s t r i n g s of c h a r a c t e r s beginning w i t h a
l e t t e r and followed by l e t t e r s and d i g i t s . I t i s sometimes convenient
t o c r e a t e i d e n t i f i e r s which c o n t a i n d e l i m i t e r s o r begin w i t h d i g i t s .
The use of t h e d e l i m i t e r "1" ( s l a s h ) causes t h e following c h a r a c t e r t o
be taken l i t e r a l l y , and t h e s l a s h i t s e l f i s n o t p a r t of t h e i d e n t i f i e r ,
Thus, /AB i s t h e same a s AB i s t h e same a s /A/B.
Examples :
A
APPLE
FOObaz
TIME-OF-DAY
A1B2
/(
?
113245
/
.
LPT :
SAILON No, 28.2
Representation:
An i d e n t i f i e r i s i n t e r n a l l y represented a s a d o t t e d p a i r of the
following form:
identifier
-4
-1
1 -.-i - 2
property l i s t
which i s c a l l e d a n atom header.
Thus CDR of a n i d e n t i f i e r gives t h e property l i s t o f ~ h ei d e n t i f i e r ,
but CAR of an i d e n t i f i e r gives t h e p o i n t e r 777777; which i f used a s a n
address w i l l cause a n i l l e g a l memory r e f e r e n c e , and an e r r o r message.
An i d e n t i f i e r i s r e f e r r e d t o i n symbolic computation by t h e address of
i t s atom header.
.
.-.
1
'
3.1
',.
*
*
.
PROPERTY LISTS
(property
The property l i s t of a n i d e n t i f i e r i s a l i s t of p a i r s :
name, property value) a s s o c i a t e d with t h q t i d e n t i f i e r , The normal kinds
of p r o p e r t i e s which a r e found i n property l i s t s a r e p r i n t names, v a l u e s ,
and f u n c t i o n d e f i n i t i o n s corresponding t o i d e n t i f i e r s ,
3,l.l
PRINT NAWS
Every i d e n t i f i e r has a p r i n t name (PNAME) on i t s property l i s t .
The p r i n t name Of an i d e n t i f i e r i s a l i s t of f u l l words, each containing
f i v e ASCII c h a r a c t e r s .
Example:
follows :
The i d e n t i f i e r TIME-OF-DAY would be i n i t i a l l y r e p r e s e n t e d a s
a tom header
....
other properties
+~PNAME/
4-9
t
I
1
/
1
I?II
Y
p r i n t name
where
3.1.2
means n u l l o r ASCII
.
.
@.
SPECIAL CELLS
When a value i s assigned t o a n i d e n t i f i e r , t h e property name VALUE
i s put on t h e i d e n t i f i e r ' s property l i s t with property value being a
p o i n t e r t o a s p e c i a l c e l l . The CDR of t h e s p e c i a l c e l l (sometimes c a l l e d
SAILON No. 28.2
VALUE c e l l ) holds t h e v a l u e of the i d e n t i f i e r , and t h e address of a
s p e c i a l c e l l remains c o n s t a n t f o r t h a t i d e n t i f i e r u n l e s s REMPROPed, t o
enable compiled f u n c t i o n s t o d i r e c t l y r e f e r e n c e t h e v a l u e s of s p e c i a l
variables.
Global v a r i a b l e s and a l l v a r i a b l e s bound i n i n t e r p r e t e d ..'
f u n c t i o n s s t o r e t h e i r values i n s p e c i a l c e l l s .
Example:
The atom N I L has t h e following form:
atom header
NIL
3.2
>
A
property
list
1
0-w
THE OBLIST
I n order t h a t occurrences of i d e n t i f i e r s with t h e same p r i n t names
have fh6 same i n t e r n a l address (and hence v a l u e ) , a s p e c i a l l i s t which is
the VALUE of a g l o b a l variable eaP1ed OBEPST is used t o remember a l l
i d e n t i f i e r s which READ and some o t h e r f u n c t i o n s have seen. For t h e sake
of searching e f f i c i e n c y , t h i s l i s t has two l e v e l s ; t h e f i r s t l e v e l c o n t a i n s
s e q u e n t i a l l y s t o r e d "buckets" which a r e "hashed" i n t o a s a f u n c t i o n of t h e
p r i n t name of t h e i d e n t i f i e r . Each bucket i s a l i s t of a l l d i s t i n c t
i d e n t i f i e r s which have hashed i n t o t h a t bucket.
Thus, (CAR OBLIST) i s t h e
f i r s t bucket, and (CAAR OBLIST) i s t h e f i r s t i d e n t i f i e r of t h e f i r s t
bucket.
5
?
.
t
r .?
'5
.
ji'
,.
3-
.z
*%
1
.h.
:I:
t
d
'r
r
1
SAILON No. 28.2
2.
I-
'9
1
'.;,5
I
CHAPTER 4.
*
(8
NUMBERS
d
l
There a r e two s y n t a c t i c
t y p e s of numbers:
i n t e i e r and; r e a l .
4.
d
/?
,
'
4.1
INTEGERS
-
C
t.
Syntax:
..
4
'
4
.
I
integer
digits
sign
..=
..
..=
.
..=
.
....=
%
( s i g n ) d i g i t s (I1.")
!.n
.'
4c
-!
-'*
digit
'-
.'
digits digit
11+11
Z
.!
I
t
\,
+
i
'I
1
11- I l
i
1
Semantics:
The g l o b a l v a r i a b l e IBASE s p e c i f i e s t h e i n p u t r a d i x f o r 5 n t e g e r s
which a r e n o t followed by
I n t e g e r s , followed by 'I.''
a r e decimal
i n t e g e r s . IBASE i s i n i t i a l l y = 8. S i m i l a r l y , t h e g l o b a l v a r i a b l e USE
controls output radix f o r integers.
If BASE = 1@ t h e n ' i n t e g e r s w i l l
p r i n t w i t h a f o l l o w i n g ".'I
, u n l e s s t h e g l o b a l v a r i a b ~ e ~ * -~- =oT~ o ~ ~ ~
".".
-
.
Examples w i t h IBASE=8
input
meaning
--
19
17.
O
,
7
=+171g
Representation:
There a r e t h r e e r e p r e s e n t a t i o n s f o r i n t e g e r s depending on t h e
numerical magnitude of t h e i n t e g e r : INUM, FIXNUM, and BIGNUM.
Their
ranges a r e a s f o l l o w s :
-
INUM
K<
F IXNUM
B IGNUM
235
5
In1
(K
ln1
<235
In1
K i s u s u a l l y 2 16
SAILON No. 28.2
Representation of INUMs :
INUMs are represented by pointers outside of the normal LISP .
addressing space. INUMs are addresses in the range 2 1 8 - 2 ~ 1to 218-1,
Examples :
INUM
representation
- (K-1)
218-jK- (K-1)
-1
218-~-1
+(K- 1)
218- 1
I'
?
Representation of FIXNUMs :
1
FIXNUMs are represented by list structure of.the following form:
atom :leader
r-I
L-
i
--
P - + + **-i---~>
~
: value
~~~
: ~!
where value is the 2's ,complementrepresentation of the fixed point
number.
Examples :
Representation of BIGNUMs:
BIGNUMs are represented by list structure of the following forms:
Positive BIGNUMS
Nega tive BIGNUMs
~ L ~ O S N U M I+ d F + .
..431/]
SAILON No. 28.2
where Ni a r e p o s i t i v e 36 b i t i n t e g e r s ordered from l e a s t t o most
s i g n i f i c a n t . The value of a BIGNUM i s
sign
C
i=O
Note:
.
BIGNUMs a r e n o t normally a p a r t of t h e i n t e r p r e t e r . ~ ~ p ' e n d i xH
d e s c r i b e s t h e procedure f o r loading t h e BIGNUM package.
Syntax :
real
..=
.=
..
.
( s i g n ) d i g i t s exponent
( s i g n ) ( d i g i t s ) ' 'I. 'I (exponent)
exponent
: :=
"E"
(sign) d i g i t s
Examples :
meaning
Restrictions:
A r e a l number
x
must be ia t h e (approximate) range:
A r e a l number has approximately e i g h t s i g n i f i c a n t d i g i t s of accuracy.
Representation:
atom header
,
where value i s i n P D P - ~ / ~ @
2 ' s complement f l o a t i n g point r e p r e s e n t a t i o n .
SAILON No. 28.2
CHAPTER 5.
S -EXPRESS IONS
Syntax:
a tom
::=
I
identifier
S-expression
S -express ion- list
..=.
..=
.
....=
number
atom
"(If
S-expression-list
II
I1
(
11
..=.
....=
. .=
.
It)"
-
1
I1
= NIL
S-expression
S-expression
S-expression-list
S-expression list
".It
S-expression
Examples :
S -express ion
(A
. (B
representation
0)
Exceptions :
The identifier NIL is the identifier which represents the empty
list, i.e., ()
.
SAILON 28.2
CHAPTER 6.
LAMBDA EXPRESSIONS
LAMBDA expressions provide t h e means of c o n s t r u c t i n g computational
procedures ( o f t e n c a l l e d f u n c t i o n s , s u b r o u t i n e s , o r procedures) which
compute answers when values a r e assigned t o t h e i r parameters. A LAMBDA
expression can be bound t o an i d e n t i f i e r s o t h a t any r e f e r e n c e t o t h a t
i d e n t i f i e r i n f u n c t i o n a l c o n t e x t r e f e r s t o t h e LAMBDA expression. I n
LISP 1.6 t h e r e a r e s e v e r a l types of f u n c t i o n d e f i n i t i o n which determine
how arguments a r e bound t o t h e LAMBDA expression.
'
I
r
LAMBDA d e f i n e s a 'function by s p e c i f y i n g an ARGUMENT-LIST, which ' i s
a l i s t of i d e n t i f i e r s (except f o r LEXPRs, s e e 6 . 3 ) and a BODY, which i s
an S-expression. LAMBDA expressions may have no more t h a n f i v e arguments
i f they a r e t o be compiled.
:
.
.
.)
(LAMBDA NZL 1)
his LAMBDA expression of no a l f g m e R e l a 1 ~ ~ y€ !8v ~ I ~ I I P ~ @ ! ! I
t o one.
(LAMBDA (X) (TIMES X X ) )
This LAMBDA expression computes t h e square of i t s
argument.
"ID" "LAMBDA-EXPR")
(LABEL
---.----.-
P
LABEL c r e a t e s a temporary name I D f o r i t s LAMBDA expression.
This makes i t p o s s i b l e t o c o n s t r u c t r e c u r s i v e f u n c t i o n s w i t h temporary
names.
I
s
Example :
0
(DE REVZRSE (L)
((LABEL REVERSE1
(TAMBDA (L M)
(COND ((ATOM L) M)
(T (REVERSE1 (CDR L) (CONS (CAR L) M ) ) ) ) ) )
L NIL))
LAMBDA expressions a r e evaluated by "binding" a c t u a l arguments
t o dummy v a r i a b l e s of t h e LAMBDA expression, ( s e e Chapter 14) then
e v a l u a t i n g t h e body i n s i d e t h e LAMBDA expression with t h e c u r r e n t dummy
v a r i a b l e LLzdings. However, a c t u a l arguments t o LAMBDA expressibns are
SAILON 28. '2
handled i n a v a r i e t y of ways. Normally, t h e r e i s a one-to-one c o r r e s pondence between dummy v a r i a b l e s and a c t u a l argumehts., and t h e a c t u a l
arguments a r e e v a l u a t e d b e f o r e t h e y a r e bound. However, t h e r e a r e
t h r e e s p e c i a l forms of f u n c t i o n d e f i n i t i o n which d i f f e r i n t h e i r haridling
of a c t u a l arguments.
An EXPR i s a n i d e n t i f i e r which h a s a LAMBDA e x p r e s s i o n on i t s
EXPRs a r e e v a l u a t e d by b i n d i n g ':
P r o p e r t y l i s t w i t h p r o p e r t y name EXPR.
t h e v a l u e s of t h e a c t u a l arguments t o t h e i r corresponding dummy vari-as
a b l e s . DE ( s e e 11.1) i s u s e f u l f o r d e f i n i n g EXPRs.
Examples :
(DE SQUARE (C) (TIMES X X ) )
(DE ;WAX (X Y) (COND ((GREATERP X Y) X) (T Y ) ) )
6.2
FEXPRs
A FEXPR i s a n i d e n t i f i e r which has a M B D A e x p r e s s i o n of
dummy v a r i a b l e on i t s p r o p e r t y l i s t w i t h p r o p e r t y name FEXPR.
a r e e v a l u a t e d by b i n d i n g t h e a c t u a l argument l i s t t o t h e dummy
w i t h ~ u te v a l u a t i n g any arguments. DF ( s e e 11.1) i s u s e f u l f o r
FEXP R s
.
one
FEXPRs
variable
defining
Examples :
(DF L I S T Q ( L ) L )
( L I S T Q A ( B ) C) = (A (B) C)
(LISTQ) = NIL
( D F DEFINE ( L )
(MAPC (FUNCTION (LAMBDA (X) (PUTPROP (CAR X)
(CADR X)
(QUOTE E x P R ) ) ) )
L) )
( D E F I N E (LEQ (LAMBDA (X Y) (OR ( L E S S P X Y)
(EQUAL X Y)) ) )
(GEQ (LAMBDA (X Y) (OR (GREATERP X Y)
(EQUAL X Y)))))
An LEXFR i s a n EXPR whose LAMBDA e x p r e s s i o n has a n atomic argument
of il;~e f o m :
'Ilist"
,
7
SAILON 28.2
*
.
t
?
I
(LAMBDA "ID"
"FORM")
>.
LEXPRs may take an a r b i t r a r y number of a c t u a l arguments which a r e .evalu-;
ated.and r e f e r r e d t o by t h e s p e c i a l f u n c t i o n ARG.
I D i s bound.t'o'the
n ~ . , ; b e rof arguments which a r e passed.
(ARG N)
---.-
ARG r e t u r n s t h e value of t h e Nth argument t o an LEXPR.
Example :
(DE MAX N
(PROG (M)
(SETQ M (ARG N))
L
(SETQ N (SUB1 N))
(COND ((ZEROP N) (RETURN M ) )
((GREATERP
(ARG N) M) (SETQ M (ARG N ) ) ) )
(GO L ) ) )
(MAX 1 1 . 2 4 3 -50) = 4
f
P
6.4
0
MACROs
A MACRO i s an i d e n t i f i e r which has a LAMBDA expression of one dummy
v a r i a b l e on i t s property l i s t with property name MACRO, WCROs a r e
evaluated by binding t h e l i s t containing t h e macro name and t h e a c t u a l
argument l i s t t o t h e dummy v a r i a b l e . The body i n t h e LAMBDA expression
i s - e v a l u a t e d and should r e s u l t i n another "expanded" form. I n t h e
i n t e r p r e t e r , the expanded form i s evaluated, I n the compiler, the expanded form i s compiled. DM ( s e e 11.1) i s u s e f u l f o r d e f i n i n g MACROS,
Examples :
1)
We could d e f i n e CONS of an a r b i t r a r y number of arguments by:
(DM CONSCONS (L)
(COND ((NULL (CDDR L)) (CADR L ) )
( T (LIST (QUOTE CONS)
(CADR L)
(CONS (QUOTE CONSCONS) (CDDR L ) ) ) ) ) )
.
(CONSCONS A B C) would c a l l CONSCONS w i t h L = (CONSCONS A B C)
CONSCONS then forms the l i s t (CONS A (CONSCONS B c ) )
Evaluating t h i s
will again c a l l CONSCONS with L = (CONSCONS C). CONSCONS w i l l f i t x i l l y
r e t u r n C.
.
The e f f e c t of (CONSCONS A B C) i s then (CONS A (CONS B c ) ) .
.
>
.
2)
We c o u l d d e f i n e a f u n c t i o n *EXPAND w h i c h i s m o r e g e n e r a l l y u s e f u l
f o r MACRO expansion :
(DE *EXPAND (L FN)
(COND ( ( N U L L (CDR L ) ) (CAR L ) )
( T ( L I S T FN (CAR L ) (*EXPAND
(CDR L) F N ) ) ) ) )
T h e n w e c o u l d d e f i n e CDNSCONS:
(DM CONSCONS ( L )
(*EXPAND
(CDR L) (QUOTE CONS)))
I t s h o u l d be noted t h a t MACROs a r e m o r e general than F E X P R s and
LEXPRs.
I n f a c t t h e previ.ous d e f i n i t i o n s can be replaced by t h e
f 01l o w i n g MACROs :
(DM L I S T Q ( L ) (CONS (QUOTE QUOTE) (CDR L ) ) )
(DM MAX (L) (;';EXPAND (CDR L ) (QUOTE *MAX) ) )
(MAX A B C) w o u l d e x p a n d t o :
(*Y;AX A (WQLX B (*MAX C D ) ) )
SAILON No. 28.2
CHAPTER 7.
EVALUATION OF S-EXPRESSIONS
This c h a p t e r d e s c r i b e s t h e h e a r t of t h e LISP i n t e r p r e t e r , t h e
mechanism f o r e v a l u a t i n g S-expressions
.
(*EVAL E)
E)
-(EVAL
--
-
-
5kEVAL and EVAL ( s e e 7.2) e v a l u a t e t h e v a l u e of t h e S-expression e.
Examples :
(EVAL (CONS (QUOTE ADD1) 3 ) ) = 4
The t o p l e v e l of LISP is:
.
(PROG NIL '
L
(PRINT (EVAL (READ))) (TERPRI) (GOL))
,
(APPLY --FN ARGS)
-..".
d
*,
"-
APPLY e v a l u a t e s and b i n d s each S - e x ~ r e s s i o n i n ARGS t o t h e
corresponding arguments of t h e f u n c t i o n FN, and r e t u r n s t h e v a l u e of FN.
See 7.2.
(AP2X (FUNCTION APPEND) ((QUOTE (A B ) )
(QUOTE (C D ) ) ) )
= (A B C D)
( QiSOTE "E ")
-
DUOTE r e t u r n s
-
the S - e x p r e s s i o n ' E w i t h o u t e v a l u a t i n g i t
.
The f o l ~ o w i n gf u n c t i o n d e f i n i t i o n s l a c k some d e t a i l s b u t e x p l a i n
t h e e s s e n c e of EVAL and APPLY. The A-LIST f e a t u r e of t h e s e f u n c t i o n s i s
n o t shown, b u t w i l l be e x p l a i n e d i n 7.2.
r'
. SAILON No.
28.2
(DE EVAL (X)
( R O G (y)
(RE TURN
(COND ( (NUMBERP X) X)
((ATOM X) (COND ( ( S E T Q Y (GET X (QUOTE VALUE)))
(CDR y ) )
( T (ERR (QUOTE (UNBOUND VARIABLE ) ) ) ) )
((ATOM (CAR X ) )
(COND ( ( S E T Q Y (GETL (CAR X) (QUOTE (EXPR FEXPR MACRO))))
(COND ( ( E Q (CAR Y) (qUOTE EXPR) )
(APPLY (CADR Y)
(MAPCAR (FUNCTION EVAL) (CDR X I ) ) )
( (EQ (CAR Y) (QUOTE FEXPR))
(APPLY (CADR Y) ( L I S T (CDR X ) ) ) )
( T (EVAL (APPLY (CADR Y) ( L I S T X ) ) ) ) ) )
( ( S E T Q Y (GET (CAR X) (QUOTE VALUE)))
(EVAL (CONS (CDR Y) (CDR X ) ) ) )
( T (ERR (QUOTE (UNDEFINED FUNCTION ) ) ) ) ) )
(T (APPLY (CAR X) (MAPCAR (FUNCTION 'EVAL) (CDR X) ) ) ) ) ) )
'
(DE APPLY (FN ARGS)
+
(COND ((ATOM FN)
(COND ( ( G E T F N (QUOTE EXPR))
(APPLY (GET F N (QUOTE EXPR)) ARGS))
(T (APPLY (EVAL FN) ARGS) ) ) )
( ( E Q (CAR FN) (QUOTE LAMBDA) )
(PROG (z)
( B I N D (CADX FN) ARGS)
(SETQ Z (EVAL (CADDR F N ) ) )
(UNBIND (CADR F N ) )
(RETURN Z) ) )
(T (APPLY (EVAL FN) ARGS) ) ) )
The f u n c t i o n s B I N D and UNBIND
described i n t h e next s e c t i o n .
7.1
implement v a r i a b l e bindings a s
VARIABLE BINDINGS
This s e c t i o n a t t e m p t s t o e x p l a i n t h e d i f f e r e n t types of v a r i a b l e
binding and t h e d i f f e r e n c e between i n t e r p r e t e r and compiler bindings.
7.1.1
BOUND AND FREE OCCURRENCES
An occurrence of a v a r i a b l e i s a "bound o c c ~
-- r r e n c ei ~f ~t h e v a r i a b l e
i s a v a r i a b l e i n any LAMBDA or . P R E c o n t a i n i ~ gt h e occurrence s o long a s
t h e occurrence i s n o t contained i n a FUNCTIONAL argument which i s contained
The d e f i n i n g UMBDA or ~ R @ i s t h e i n n e r i n t h e d e f i n i n g LAMBDA or P R E .
most IAMBDA or PROG which c o n t a i n s t h e . v a r i a b l e i n i t s parameter l i s t ,
SAILON No. 28.2
Examples :
(LAMBDA (X) (TIMES X Y))
X has a bound occurrence.
Y has a f r e e occurrence.
(LANBM (Y Z) (MAPCAR'(FUNCTION(LAMBDA(X) (CONS X Y)))Z)
X and Y have only bound occurrences.
Y has a f r e e occurrence 'bound by t h e
o u t e r LslMBW.
-
7.1.2
SCOPE OF BINDINGS
A v a r i a b l e bound i n a LAMBDA or PROG i s defined during the dynamic
execution of t h e LAMBDA or ?AOG. Free occurrences of v a r i a b l e s a r e
defined i f and only i f e i t h e r t h e v a r i a b l e i s g l o b a l l y defined or t h e
v a r i a b l e i s bound i n any LAMBDA or PROG which dynamically c o n t a i n s t h e
i r e e occurrence. A v a r i a b l e ,d g l o b a l l y defined i f and only i f i t has
a value a t t h e t o p l e v e l of LISP. Variables can be g l o b a l l y defined by
SETQ a t the fop l e v e l .
4
7.1.3
SPECIAL VARIABLES
I n compiled f u n c t i o n s , any v a r i a b l e which i s bound i n a LAMBDA or
PROG and has a f r e e occurrence elsewhere must be declared SPECIAL
(APPENDIX E )
.
Example :
(LAMBDA (A B)
(MAPCAR (FUNCTION (LANBDA (X)
(CONS A X ) ) )
B))
The v a r i a b l e A which has a f r e e occurrence must be declared SPECIAL
i f the outer LAMBDA expression i s t o be compiled.
7.1.4
B I N D I N G MECHANISMS
,'-
A l l v a r i a b l e s i n i n t e r p r e t e d f u n c t i o n s , and SPECIAL v a r i a b l e s i n
compiled functions s t o r e t h c i r values i n SPECIAL ( o r VALUE) c e l l s .
These v a r i a b l e s a r e bound a t t h e e n t r y t o a LAP1BDA or PROG by saving
t h e i r previous values -on the SPECIAL pushdown l i s t and s t o r i n g t h e i r new
values i n the SPECIAL c e l l s . A l l refkrences t o these v a r i a b l e s a r e
d i r e c t l y t o t h e i r SPECIAL c e l l s . When t h e LAMBDA or PROG i s e x i t e d , the
old values a r e r e s t o r e d from the SPECIAL pushdown l i s t .
I n compiled f u n c t i o n s , a l l v a r i a b l e s n o t d e c l a r e d SECLAL a r e
s t o r e d on the REGULAR pushdown l i s t , and the SPECIAL c e l l s ( i f they
e x i s t ) a r e not referenced.
SAILON No. 28.2
7.2
THE A-LIST
-
The A-LIST which i s used i n some L I S P systems does n o t e x i s t h e r e ,
b u t i t s e f f e c t s a r e implemented through t h e SPECIAL pushdown l i s t , and
some s p e c i a l mechanisms.
The f u n c t i o n s EVAL and APPLY a l l o w a n e x t r a
i a s t argument t o be passed, which i s e i t h e r a l i s t of p a i r e d i d e n t i f i e r s
and v a l u e s ( l i k e a n A-LIST) or some previous s t a t e of t h e SPECIAL pushi , ~ r nl i s t which d e f i n e s t h e c o n t e x t of v a r i a b l e b i n d i n g i n which t o
evaluate S-expressions.
I f a n FEXPR i s d e f i n e d w i t h two arguments, t h e n t h e second argument
w i l l be bound t o t h e c u r r e n t s t a t e of t h e SPECIAL pushdown l i s t , which
i s r e p r e s e n t e d by a number s p e c i f y i n g t h e v a l u e of t h e SPECIAL pushdown
pointer,
Example :
(DF EXCHANGE ( L SPECEDL-).
(PROG(Z) (SETQ Z(EVAL (CAR L) SPECPDL))
(APPLY (FUNCTION SET)
(LIST (CAR L) (EVAL (CADR L) SPECPDL)
T
S PEC PDL)
(APPLY (FUNCTION SET)
(LIST (CADR L) Z)
S PECPDLj ) )
In t h i s example, t h e use of t h e e x t r a argument SPECPDL h a s only one
e f f e c t : t o a v o i d con£ l i c t s between i n t e r n a l and e x t e r n a l v a r i a b l e s
w i t h names L and SPECPDL.
(EXCHANGE L M) w i l l cause t h e v a l u e s of L and M t o be exchanged.
The v a r i a b l e L i n EXCHANGE i s n o t r e f e r e n c e d by t h e c a l l s on SET,
7 3 FUNCTZ ONAL ARGUMENTS
An argument t o a f u n c t i o n which ' i s i t s e l f a f u n c t i o n i s c a l l e d a
f u n c t i o n a l argument. Because most arguments t o f u n c t i o n s a r e e v a l u a t e d
when t h e y a r e passed, t h e s p e c i a l f u n c t i o n s FUNCTZON and *FUNCTION a r e
used t o c o n ~ r o lt h e p a s s i n g of f u n c t i o n a l arguments.
(FUXCTIOX "FX1'). = (QUOTE "FN")
(;kFUnTCTION "FN")
. .
;??~NCTI(?N
c a u s e s t h e c u r r e n t s t a t e of t h e s p e c i a l pushdown:.list t o
be passed i n a l i s t of t h e f o l l o w i n g form:
(FUNARG FN , SPECPDL)
When APPLY s e e s a FUNARG l i s t , APPLY performs e v a l u a t i o n of FN i n t h e
c o n t e x t of t h e S P E C U L pushdown l i s t which was passed i n t h e FUNARG l i s t .
.
SAILON No. 28.2
CHAPTER 8.
.
CONDITIONAL EXPRESSIONS
A conditional expression has the following form:
(COND ( e l i l elY2
where the
... e 1an1 )
e i a J. ' s a r e any S-expresSions.
The e, , ' s
a r e considered t o be p r e d i c a t e s , i - e . , evaluate t o a
A
';ruth value.
The e i , 1' s a r e evaluated s t a r t i n g with e l
, e2 1
ezc., u n t i l the f i r s t ek- 1 i s found whose value i s not AIL.
the
corres?onClng ek, 2 ek, 3
a
r
e
evaluated
r
e
s
p
e
c
t
i
v
e
l
y
and
the
ek,n,
value of
It i s permissible
i s returned a s tffe value of COXD.
fcr nk=l, e iLn w ich case the value of e]i, 1 i s the value of COND. I f
tiis
ei,;
valuate t o ,i:L,
then N I L i s tne value of COND.
...
--i.
-
Examples :
(DE X3T (X) (COND (X NIL) (T)) )
(-3 AND (X Y)
(COND (X (COND (Y T ) ) ) ) )
(2E 02 (X Y) (COND (X T) (Y T) ) )
(DE IMPLIES (X Y)
(C OND (X (COND (Y T) ) )
(T) )
en
,
SAILON No. 28.2
CHAPTER 9.
PREDICATES
Predicates t e s t S-expressions f o r p a r t i c u l a r values, forms, or
ranges of values. A l l predicates described i n t h i s chapter r e t u r n
eLther N I L or T corresponding t o the t r u t h values f a l s e and t r u e , unless
otherwise noted.
Some predicates cause e r r o r messages or undefined r e s u l t s
when applied t o S-expressions of the wrong type, such as (MINUSP (QUOTE FOO)).
(ATOM X)
The value of ATON i s T i f X i s e i t h e r an i d e n t i f i e r or a number;
N I L otherwise.
Asanples :
(ATOX
(ATOX
(ATOM
(ATOM
T)
= T
1.23)
= T
(QUOTE (X Y Z ) ) )
= NIL
(CDR (QUOTE (X))) = T
The value of Q i s T i f f X and Y a r e the same p o i n t e r , i.e., the
same i n t e r n a l address.
I d e n t i f i e r s on the OBLIST have unique addresses
and therefore EQ w i l l be T i f f X and Y a r e t h e same i d e n t i f i e r . EQ w i l l
a l s o r e t u r n T f o r equivalent INUMs, since they a r e represented a s
addresses. However, EQ w i l l not compare equivalent numbers of any other
kind. For non-atomic S-expressions, EQ i s T i f f X and Y a r e t h e same
pointer.
Examples :
(EQ T T)
= T
(EQ T NIL)
= NIL
(EQ (QUOTE
A) (QUOTE
B))
= NIL
(EQ 1 1.0)
= NIL
(EQ 1 1)
= T
(
E
Q
)
=NIL
.
(EQ (QUOTE (A B ) ) (QUOTE (A B ) ) )
(EQUAL XY)
= NIL
.?
The valua of EQUAL i s T i f f X and Y a r e i d e n t i c a l S-expressions.
EqyAL can a l s o t e s t f o r e q u a l i t y of numbers of the sanis type.
To
(ZEROP (DIFFERENCE X Y)). - .
compare numbers of d i f f e r e n t types use:
Far non-numeriea 1 comparisons , EQUAL i s equiva l e n t t o :
(IAMBDA(X Y) (COND ((EQ X Y)T)
((ATOM X) NIL)
((ATOM Y) NIL)
((EQUAL (CAR X) (CAR Y ) )
(EQUAL (CDK X) (CDR Y)))))
SAILON No, 28,2
Examples :
(EQUALTT)
= T
(EQUAL 1 1)
= T
(EQUAL 1 1. @) = N I L
(EQUAL (QUOTE (A B ) ) (QUOTE (A B ) ) )
(EQUAL (QUOTE ( T ) ) T)
=NIL
= T
9. .1 S-EXPRESSION PREDICATES
(NULL
-
L)
= T i f f L i s NIL.
( M E ~ E RL i ~ 2 )
= T
iff L1 is EQUAL to a top level element of L2.
E X B E R is equivalent to:
( U 2 3 D A ( L l L2) (COND ( (ATOM L2) KIL)
((EQUAL LI (CAR L 2 ) ) T )
(T(MEMBER L 1 (CDR ~ 2 ) ) ) ) ) ' .
Examples :
+*44 ,
ii.
4 ~ .
'
+
..
(IGMBER (QUOTE (C D) ) (QUOTE ( (A B) (C D)E) ) )
(P~EMBER' (QUOTE C) (QUOTE ( ( C ) ) ) ) = NIL ..-
= T 3
. .
#f
(MEMQ L1
L2)
-- --
-
T iff L 1 is
3 to a top level elemen.tJ.of L2.
NEMQ is eq.c;:;lalent to.:
%
(LAMBDA ( L 1 L2) (C OND ( (ATOM L2) NIL)
((EQ L 1 (CAR L 2 ) ) T )
(T(MEMQ L 1 (CDR E 2 ) ) ) ) )
Examples :
9.2
NUll/iEL,Zi4L
(NUMBERP X)
(ZERO? X)
( E X Q ( Q U C E (C D))(QUOTE ((A B) (C D) E ) ) )
(XENQ (QUOTE A) (QUOTE (Q A B ) ) ) = T
= NIL
PREDICATES
=
T if X is
=
NIL
2 number of any typeotherwise
=
if X is zero of any numerical type .
if X is a zon-~umericalquantity
N I L otherwise
=
: if X is a negative number of any type
= T
= error
= error if X is
= N I L otherwise
a non-numerical quantity
..
SAILON No. 28.2
i f X and Y a r e numbers of any type and
e r r o r i f e i t h e r X or Y a r e not number
= NIL otherwise
= T
X
> Y.
=
(GREATERP XI X2
Xn)
i f (;'GREAT X1 X2) and
GREAT X, X,) and
("GREAT
e r r o r i f any Xi i s a non-numerical q u a n t i t y
= N I L otherwise
T
XI;-
-...
Other n x z e r i c a l : predicates may be defined a s follows:
(DE FLOATP (x) (EQUAL
x (PLUSx m.m))
(DE F IXP (X) (N OT (F LOATP I() ) )
(DE ONEP (X) (ZEKOP (DIFFERENCE X 1 ) ) )
(DE EVENP (X) (ZEROP (RZMINDER X 2 ) ) )
9.3
BOOLEAN PRZDICATES
The Boolean predicates perform l o g i c a l operations on the t r u t h
values KiL and T.
non-NIL value i s considered equal t o T.
= T
if X i s NIL
= ;,iL otherwise
(N
OT X)
-- ----------
(LSD Xl X,
-
--ce:
,
= T 'if
= NIL
a l l Xi a r e -on-NIL
otherwise
( A = AND evaluates i t s arguments from l e f t t o r i g h t u n t i l
either N I L i s found i n which case the remaining arguments a r e not
e v a l u a t t d , or u n t i l the l a s t argument i s evaluated.
( 3 3 X1 X2
Note:
-
... Xn)
-... Xn)
=
T
=
KIL
i f any Xi i s non-NIL
otherwise
(GK) = NIL.
OR evaluates i t s arguments from l e f t t o r i g h t u n t i l
e i t h e r non-NIL is found i n which case the remaining arguments
a r e not e v ~ : x a t e d , or u n t i l the l a s t argument i s evaluated.
SAILON No. 28.2
0
CWPTER 10.
FUNCTIONS ON S-EXPRESS IONS
This chapter describes functions f o r building, fragmenting,
m o d i f y i n g , t r a n s f o r m i n g , mapping, a n d s e a r c h i n g S - e x p r e s s i o n s , a s w e l l
as some n o n - s t a n d a r d f u n c t i o n s o n S - e x p r e s s i o n s .
9 . 1
S-EXPRESSION BUILDING FUNCTIONS
(CONS
X Y)
-
---.
The ~ d u oe f CONS 02 two S - e x p r e s s i o n s i s t h e d o t t e d p a i r of t h o s e
S - e x p r e s s ic;.;.
(CONS (QUOTE A) (QUOTE B ) ) = (A
Note:
-
. B)
S z e A222ndix B f o r k n f o r m a t i o n o n f u n c t i o n s a s s o c i a t e d w i t h
CONsiilg, s u c h a s SFZAK, GCGAG, a n d GC.
(XCOXS X Y) = (CONS Y X)
.
-
(NCONS X)
= (CONS X NIL)
(LIST Xl X ,
i
... Xn)
=
(CONS XI (CONS X2
... (CONS Xn NIL)...))
L i s t e v a l u a t e s a l l of i t s a r g u m e n t s a n d r e t u r n s a l i s t of t h e i r
-,,iilues.
Examples :
(LIST) = NIL
(LIST (QUOTS A)) = (A)
(LIST (C 2TE A) ) (QUOTE B) ) = (A B)
*APPEK3 f o r m s a l i s t which i s t h e s e c o n d l i s t a p p e n d e d t o t h e f i r s t
according t o t h e following definition:
(DE ;,A,2'251.3(X Y )
(CO;lD ( ( X L S ) Y)
(T (COKS (CAR X) (:';APPEND
(AFPEND X I X2
Example:
... X )
= ("APPEND
-
(CDR X) Y ) ) ) ) )
XI ("APPEND X2
(APPEND)
NIL
(A2PZ:i:
(QUOTE (A B))
(QUOTE (C D ) )
... ("APPEND
NIL).
..) )
(QUOTE (E 3')) ) = (A B C D E F)
SAILON No. 28.2
10.2
S-EXPRESS I O N FRAGMENTING FUNCTIONS
(CAR L)
The
of a non-atomic S-expression i s t h e f i r s t element of t h a t
dotted pair.
CAR of a n atom i s undefined and w i l l u s u a l l y cause a n
i l l e g a l memory r e f e r e n c e .
(CDR L)
The CDR of a non-atomic S-expression i s the second (and l a s t )
T h e CDX of a n i l e r i ~ i i i e ri s i t s property
element of t h a t d o t t e d p a i r .
The CDR
l i s t . The ZDR of an INUM causes a n i l l e g a l memory reference.
of any o t h e r number i s t h e l i s t s t r u c t u r e r e p r e s e n t a t i o n of t h a t number.
Examples :
(CL:
(CAR
(CDR
(CDX
(CCTI
(QUOTE(A B c ) ) ) = A
(QUOTE A ) ) i s i l l e g a l
(qUOTE (A B C))) = (3 C)
(QUOTE A)) i s t h e property l i s t of A
(QUOTE (A))) - N I L
.
CAAR, CLA.DTC,..
-- -..
-- , CDDDDR
-.--
A l l 05 rhe composire CAR-CDX f u n c t i o n s with up t o four A ' s and D ' S
are avsiiable.
Zxamp les :
(CADR X) = (CAR (CDR X) )
(CAADDR X) = (CAR (CAR (CDR (CDR X) ) ) )
LAST r e t u r n s t h e l a s t p a r t of a l i s t according t o t h e following
definition:
(DE LAST (L)
(COND ((ATOM (CDR L ) ) L)
(T (LAST (CDR L) ) ) j )
Examples :
10.3
(LAST (QUOTE (A B C))) * (C) = (C
(LAST (QUOTE (A B
C))) = (B
C)
.
.
. NIL)
S-EXPRESS I O N MODIFYING FUNCTIONS
The following f u n c t i o n s f o r manipulating S-expressions d i f f e r from
a l l o t h e r s i n t h a t they a c t u a l l y modify e x i s t i n g l i s t s t r u c t u r e r a t h e r
than construc;ing new l i s t s t r u c t u r e , These f u n c t i o n s should be used
with c a u t i o n s i n c e i t i s easy t o c r e a t e s t r u c t u r e s which w i l l confuse
o r d e s t r o y she i n t e r p r e t e r .
S A I L O N NO.
28.2
(RPIACA
Y)
l___.___
-.-- X-
_
___I---
Replaces the CAR of X by Y.
modified S-expression X.
Example:
(RPIACA (<?JOTE
The value of
(A B C ) )
-
is the
(QUOTE (C D ) ) )
-
= ( ;C D) B C )
Xepresentation:
B E F OXE
AFTER
RP-UCD r e p l a c e s t h e CDR of X by Yo .The value of RPTACD i s t h e
modified S-expression X.
(NCOXC X1 X2
_ _- - - -
-,bOnTC
p
-,7
__-
Xn)
I
i s s i m i l a r I n e f f e c t t o A P P E N 2 , b u t ISCONC does n o t copy l i s t
s t r u c i ~ : . , NCONC modifies l i s t s t r u c t u r e s by r e p l a c i n g t h e l a s t element
of XI by 5 ? s i n t e r Fo X2, t h e l a s t element of X2 by a p o i n t e r t o X3, e t c .
The v a l u e of XCOn'C 1 s t n e modified l i s t XI, which i s t h e c o n c ~ t e n a t i o nof
Examples :
AFTER
(NCONC) = N I L
(KCONC (QUOTE (A ti)
(QUOTE (C D ) ) )
= (A B C D)
SAILON No. 28.2
LO. 4
S-EXPRESSION TRANSFORMING FUNCTIONS
The f o l l o w i n g f u n c t i o n s t r a n s f o r m S - e x p r e s s i o n s from one form t o
another
.
(LENGTH L)
------- -. --- --
LENGTH r e t u r n s t h e number o f t o p - l e v e l elenlents o f the l i s t L.
LENGTH i s e q u i v a l e n t to.:
(DE LENGTi-l (L)
(C3ND ( (ATOM L) @)
(T ADD^ (LENGTI-I
(CDR ~ 1 ) ) ) ) )
EVERS.:
r e t u r n s t h e r e v e r s e o f t h e t o p l e v e l o f l i s t 1;.
REVERSE
Iu e q u i v a l e n t t o :
(XVERSEI L NIL))
(DE REVERSE1 (L M)
t
(CON9 ( (ATOM L) M)
( T (REVERSEI (CDRL; (CONS (CARL) M) 1)))
(DE
~ ~ vU' z, ,-uj ~c ' (L)
~'
SUBST subsc-L;dtes S - e x p r e s s i o n X f c r a l l EQUAL o c c u r r e n c e s of
S - e x p r e s s i o n Y L n S - e x p r e s s i o n S. SUBST i s e q u i v a l e n t t o :
(DE SUBS'Y ( X Y S )
(CGXD ( (EQUAL Y S) X)
((ATOM S) S)
(T (CONS (SUBST X Y (CAR S ) )
(SUBST x Y (CDR s ) ) ) ) ) )
Note:
(SCBST
Examp 12 :
10.5
0
.
.
(8 X) i s u s e f u l f o r c r e a t i n g a copy o f t h e l i s t X. .
(SUBST 5 (QUOTE FIVE)' (QUOTE (TIVE PLUS FIVE I S TEN)))
= ( 5 PLUS 5 I S TEN)
S-ZXPRESSION MAPTING FUNCTIONS
The f o l i o w i n g Z~~r.ctic3ns
perform meppings o f l i s t s a c c o r d i n g t o t h e '
f u n c t i o n a l arguments s u p p l i e d ' ( s e e 7 2).
SAILOX No. 28.2
(MAP FN - -L::
---
--
a 7 p ; i - e ~ t h z f u n c t i o n FN of one argument t o l i s t L and t o
The v a l u e o f MAP i s
s u c c e s s i v e C;Xs o f L u n t i l L i s reduced t o NIL.
K1L. YAP i s e q u i v a l e x c t o :
(DE Y",r,?(FS L)
(PROG NIL .
Ll
(COND ((NULL L)(RETURN N I L ) ) )
(F'N L)
(SETQ L (CDR L ) )
(GO 3 ) ) )
Example :
(MAP (FUNCTIOH PRINT)
PRINT :
PRINT :
;x Y z)
?RIKr.: .
X2TURlV :
(2)
(y
(QUOTE (X
fl 2 ) ) )
=
z)
NIL
-
YAPC L a L a e n t i c a l t o MAP except t h a t MAPC ~ ? p l i e sf u n c t i o n FN t o
t h e CAR 0 2 =he remaining l i s t a t each s t e p . YAPC is e q u i v a l e n t t o :
(DE YS.TC (FS L)
(PROG N I L
LI
( C O X ((XULL L) (RETURN N I L ) ) )
(FH (CAR L ) )
(S..ZQ L (CDR L) )
(GO L 1 ) ) )
Example :
? RINT :
PRINT :
p RT'\-T .
A&\
E
T
,
" ;.v :
X
Y
z
NIL
XA-PLIS"izp;>If.~s
t h e f u n c t i o n FN of one argument t o l l s t L and t o
s u c c e s s i v e Cs\,;
L;
L - . _ 1 L i s ~ d u c e dt o NIL. The v a l u e of MAPLIST
i s t h e l i s t o f v a l u e s r e t u r n e d by FN. MAPLIST i s e q u i v a l e n t t o :
(DE ;V2iPLIST (FN L)
(COND ((NULL L) NIL)
(T (CONS (FN L) (YAPLIST FN (CDR L ) ) ) ) ) )
SAILON No.
28.2
Examples :
( M A P L I S T (FUNCTIGW C P 2 ) (QUOTE ( A B C D ) ) ) = ( A B C D)
( M A P L I S T (FUNCTION REVERSE) (QUOTE ( A B C D ) ) ) =
( ( D C B A ) ( D C B) ( D C > ( D l )
MAPCAR i s i d e n t i c a l t o Y A P L I S T e x c e p t t h a t MAPCAR a p p l i e s FN : t o
MAPCAR i s e q u i v a l e n t t o :
t h e CAR o f t h e r e m a i n i n g l i s t a t e a c h s t e p .
(3E MAPCAR ( F N L )
(COND ( (NULL L ) N I L )
(T (CONS (FN (CAR L ) ;
(YAPCAR F N ( C D R L ) ) ) ) ) )
(MAPCAR (F'tiNCTTGX NCONS) (QUOTE ( A B C D ) ) ) = ( ( A ) (B) ( C ) ( D ) )
(MAPCAR (FUNCTIOX ATOM) (QUOTE ( ( X ) Y ( Z ) ) ) ) = (NIL T NIL)
(ASSOC
X T,---;
--
-.-.
-
ASSOC ~ ~ a r c h et hse l i s t o f d o t t e d pairs L f o r a p a i r whose CAR i s
EQ t o X, XL such a p a i r i s found i t i s r e t u r n e d a s t h e v a l u e of ASSOC,
otherwls
,
;
I
;
i s returned.
ASSOC i s e q u i v a l e i - ~ tt o :
(DE ASSOC (X L )
(COND ( ( N U L L L ) N I L )
( ( E Q X (CAAR L j j (CAR L ) )
( T (ASSOC X (CDR L ) ) ) ) )
rr
~ x a m p i :e
( A S S O C 1 (QUOTE ( ( I
. ONE)
(2
. 'ZJO))))=
(1
. ONE).
SAZSOC s e a r c h e s t h e l i s t of d o t t e d p a i r s L f o r a p a i r whose CAR
i s E Q t o X.
If s %s h a p a i r i s found -It i s r e t u r n e d a s t h e v a l u e of
ASSOC, ,:herwise
zne v a l u e o f FN, a f u n c t i o n o f no arguments, i s r e t u r n e d .
(DE S A S S O C (X L FN)
( C O X ( (NULL L ) (FS) )
( (EQ X ( C P J G L)) (CAR L ) )
( T ( S A S S O C X (CDR L ) ) ) ) )
Example :
.
.
( S A S S O C @ (QUOTE ( ( 1 ONE) ( 2
TWO))
( F L ~ T C T I O N (LAMBDA N I L (QUOTE L O S E ) ) ) ) = L O S E
10.7
EON-STANDARD S-EXPRESSION FWCTIONS
(EXPLODE
L)
----
EXPLODE t r a n s f o - m s an S-expression i n t o a l i s t o f sir.;le c h a r a c t e r
identifiers i d e n t i c a l t o t h e sequence of c h a r a c t e r s which would be
Exarriples :
(EX?LC,
=
:(QUOTE
(/(OX ,/
(DX
/ / 1-
/ - DY) ) )
/a D ~ ' 1 ) )
EXPLODEC trslnsforms an S-expression i n t o a l i s t of s i n g l e c h a r a c t e r
i d e n t c f i e r s i.den"Lca"xo t h e sequence of c h a r a c t e r s which would be
produced by PZIXC,,
~;cam
le~:
(EXPLOCEC (QCC 2 (DX / - DY)-))
D x / I - ,/ 3 Y 1 ) )
= (
L)- = (LENGTH (EXPLODE L))
(FLATSIZE
- ---- - - --
-YJJ<S.!J:
t-ransforns a l i s t of s i n g l e c h a r a c t e r i d e n t i f i e r s ( a c t u a l l y
t a k e s the 2 I r s . t c h a r a c t e r of each i d e n t i f i e r ) i n t o c S-expression
i d e n t i c a l -20 t h a t which would be produced by EADing t h o s e c h a r a c t e r s .
?riA:<StL.Y k ~ w e v e rdozU n o t I S T E W any of t h e i ~ e n t i f i e r si n t h e S-expression
i t prodcces.
Examples :
( W N L J Y (QUOTE (A P P L E ) ) ) = APPLE
( Y i N m (-.;OTE ( 1 1 ) ) ) ) = 1 )
RZ,-2LIST i s i d e n t i c a l t o YtAKNAY e x c e p t t h a t REkJLTST INTERNS a l l
i d e n t i r L e r s I n t h e S - e x p ~ c s s i o n i t produces.
WADLIST i s t h e l o g i c a l
i n v e r s e of EXPLODE, i . e . ,
(RE"-3LIST (EXTLODE L) ) = L
(EXPLODE ( E i a L Z S T I,):
= L
A
k
a,
*A
vl
d
LF-'
k
a,
*rl
w
?
u
t4
3 X
*&
y
k
F,>
m
a, a
C
r-i
k
*A
aJ
JJ
I=
*d
!
"2
JJ
h
0 0
k
'+l I
a t 4 a,
G a , W
k
4
"20
J-,
W U J - ,
-4
r(
A
A
x G
r?
t-4
,A
\J
H
==C
c4
U H
W
C3
w E-i
25 ix
=> 0-
4
n d u
un-
--
d
/-.
c.2
a
a,aa
5
-,'-d
OUrrt"2
w,c
C
C *?I
UtdJ-,
**
a,
-i40?4J
5
k 5
u u a a
0
4-J
2
a,
cow
2.s
s
u
mr-4
a a
k *A
bDu
5 52
r=
*rl
G
Q)
v-4
0 d
k
W W O
a, .b, 0 - d
4
u e ! - ( a
$4 ' 1 4
*ti
COoa"2
CJY
k a
a n a l 3
Tda,
v,
k c
-.ti
0 !r
L: Ek9P-i
0
.rl $4
L)
0 0
d a
W
d
m 'i-i
3 a,JJ*r(
~4-ldr-l.u
0 3 c
v) a,
OJ
k-t-4
1
1-4
;
'
-A
a,
U
O k G
a a 0
X C
a, JJ c7
A vl
a a a c
:2
'-d
*?I
3
a,
c
a,
U
J
s
ad
:
0
*rl k
U a , U
sea,
C a,
J-,
**
"2
k
a,
*A
w
td
u at3
n r l
c k m
{
a, O H
2
5 5
d .I4
0 s a,
d
"2
s
0 "2 d
*d 0 *rl
4'
!34
4.J
a d
u
v, CO
n
'44
-!Jk
v) a,
5
0 *rl a
S
'44
m 4
!-4
a h B
PA4.J
!-I
a, *A
04 a
0s:
k SJ
>\
0
*A
h
C,
a
0
,d
.;4
v,
s:
s -v
%, 0
a
d a,
v-4
3 .';
n4 3
r-l
c'J 0
4 J
Ill
a .c d
k L J O
5
a
k
a
a,
!4
03
H
,c
0
9-l '-d
s r=
3 a
.I{
)
a
~ - i!
V
V
%
3
a
;
V)
0
SAILON No. 2 0 . 2
(D-E F P ~ -.
O
11111
~ 1 1 V t~
.
--
--
I?1 1 ) = (PUTPROP (QUOTE I) (QUOTE V)
II
-
(QUOTZ P ) )
DEFPROP i s t h e same as PUTPROP e x c e p t t h a t i t d o e s
its a r g u m e n t s .
(DEF?XO? PGSI? (LAYBDA (X)
~ x a m p l e:
.7
(GREATZRP X
0))
nor
evaluate
EXPR)
DE, DF and DX are u s e f u l f o r d e f i n i n g EXPR, FEXPRs, and NACROs.
=
(PF(OG2 (PUTPRO?
I D ( L I S T (QUOTE LAMBDA) ARGS BODY) (QUOTE EXPR))
ID)
= (PBGG2 (FUTPROP I D (LIST(QU0TE LAXBDA) ARGS BODY) (QUOTE FCXPR) )
ID>
= (?KG2
(PVTPRO?
I D (LIST(QU0TE LLYBDA) ARGS BODY) (QUOTE MACRO))
ID)
I.
REX"?
I rc::.oves
---~ ? ? X ~ Arecur-7Z~
t h e p r o p e r t y I? f r o m t h e p r o p e r t y l i s c o f i d e n t i f i e r
T i f t h e r e was sizch a p r o p e r t y , ETIL. o t h e r w i s e .
INT3XY
-
p u t s t h e Idenrifiz~I i n zIi.2 a p p r o p r i a t e b u c k e t o f OBLIST.
a mecber o f the OZLIST, t h e n INTEIUV returns
t o t h e identifier a l r e a d y t h e r e , o t l i e r w i s e INTERii r e t u r n s I.
If the I c z n i l f i e r is a l r e a d y
a pointe:
Note:
IXTERY L L o n l y n e c e s s a r y when an identifier which w a s c r e a t e d by
GENSYN, Y&<NAY, o r A S C I I needs t o be u n i q u e l y s t o r e d .
...
, Xn from t h e
R E X I 3 remove.: a i l of t h e i d e n t i f i e r s XI, X2,
None o f t 4 s Xi's a r e e v a l u a t e d .
OBLIST and r e t u m s NIL.
Example :
(mOB
FOO Bb2)
SAILON No. 28.2
11.3
IDEXTIFIER CREATING FLXCTIONS
The f s i l o w i n g f u n c t i o n s c r e a t e new i d e n t i f i e r s b u t do
them o n t o t h e OBLIST.
not INTERN
G9NT-9 ii-iei .::ter:t s ,?.e ge~rrerated symbol c o u n t e r c o r r e s p o n d i n g
and retu:&-s a new i d e n t i f i e r s p e c i f i e d by t h e cou;-~cer. TheGENSYM
c o u n t e r I s i n i t i a l i z e d t o t h e i d e n t i f i e r : '396. . , ,
L-<z;s?ie:
S.ciL--ssive e x e c u t i o n s o f (GENSl!) w;il
return;
.
CSrW in-i"Lic.clizes g e n e r a = ? s y x b o l c o u x t e r t o t h e i d e n t i f i e r I,
aad r e t u r n s I , .,5\9:: d ~ e sn o t e v a l u a t e i L s argument.
,
- : : ~ p l :~
(csm L:-:~~@G
(GSSSl?Ji )
( GESSTL%
)
etc.
)
= A;,~Y$G
= LJ.Y$~
= ARYG~
(ASCII X)
ASCII c r e a t e s a s i n g l e ck^,cracter identifter wk:lue A S C I I p r i n t
Zzae c ~ k s l sN,
Examp 1e :
(
A 1 )
i s a n i d e n t i f i e r w i t h p r i n t name "A".
CHAPTZR 12.
FUNCTIONS ON NWAERS
There a r e two types of f u n c t i o n s which o p e r a t e on numbers t o c r e a t e
new numbers: a z f t h m e t i c and l o g i c a l ,
Unless oti:erwise nozed, t h e f o l l o w i n g a r i t h m e t i c f u n c t i o n s a r e
d e f i n e d Lc:- boeh i n t e g e r , r e a l and mixed c o ~ 5 i n a t i o n sof argumenLs,
and evalu,;e a;;
heir arglinents.
The r e s u l t is r e a l i f zny argument
is -2- . n i
a n d i r t e g e r i.2 a l l acguments a r e i n t e g e r .
Nost a r i t h m e t i c
, ~ x c i i o n s nay cause over£ low which i s d e s c r i b e d i n Appendix B.
(XINUS X)
=
-x
(>'<PigsX Yj
=
X + Y
=
X1 -+ X2
(?LUS XI :,;2
... Xn)
+
... -,-
Xn
give .the number t h e o r e t i c
Note:
Fox i ; r , - ~ g z rargxments, ;':QUO and Q','aIENT
integer c ; u s i i s ~ z ,
sate:
-
RemLnder is r-- :o r der'ined for r e a l arguxeilts,
( D I V Z D E X Y)
= (CGXS
(QUOTIENT X Y) (XEPL4INEZX X Y ) )
GCD rctuyns zhe g r e a t e s t ccrnmorL divisor of :lie
iXi and i Y t .
( A D D 1 X)
= X + i
(S531 X)
= X - l
-.X
(ABS X)
(FIX X)
integers.'
SAILOX No. 28.2
F T X r e t u r ~ - .che
~
-
t r u n c a t e d 2 ' s complement i ~ z e g e rvalue o f X.
(FIX I) = 1
(FIX 1,1) = 1
(FIX -1.1) = -2
Examples r
2
-1
Other a r i t h m e t i c f u c c t i o n s not defined i n t h e L I S P i n t e r p r e t e r :
(FLOAT
S ) = :I::LUS
..----
(SIC~
x)
- - ---
(COND ((ZEROP X) 6)
( (MIXUSP X) -1)
--- -.- - -
(YAY
..
X
X B.0)
'_':
-- -----. -
=
2 x 2 ~
e s ~: ~
1
A
{ C X D ( (NIXUSP (D';T?ZWNCE
-,
(>;TAUS i)
(XISUS
,2)
X Y) ) Yj (X))
- -1
= ;,2
(?jigs 1 2 3 , ; ) = G , i
(j3JjS 5 3 -2) = 7
;3ITFEmxCz 6 3 1) = 2
-2 2.6) = -4.;
\, '--vvs
Ll lu
(Q~OT?EST5 2 ) = 2
(quoyrEsT 5.0 2) = 2.5
(CJOTIENT -5 2) = 2
(;LYAIXG:,,,
5 2) = 1
(EE?AiX3EX -5 2) = -1
(P?YiAIX3EX 5.g 2) = cndefinad
(ABS -32.5)
=32.5
( i I X 52,5)
= 32.
12.2
LOGICLiL FUNCTIONS
The followlrA&f u n c t i o n s a r e intended t o o p e r a t e on I N U M and FIXUNUM
arguaents, jut t h e i r r e s u l t s a r e n c t d s f i n e d f o r BTZNm o r FLONUM ( r e a l )
argurnen t s
.
:pauygap
(g y
-
C ~ O Q E )5'
qsea '-=U icd
S A I L O N No. 28.2
The "program feature1'zllows one to write ALGOL-like sequences of
statements with program variables and labels.
PROG is r funccLon which t a k s as argucents VAXIST, a list of
2rogra;x vari~biesw 5 . i . c are ;z;.cizlLzed co NIL when the PROG is entered
w~L;h is a list clf l e b z l s which are
(see 7.1), cz.2 a
L d e ~ l t i T i c r szir
~atellieatswhLc;: a;lc: Eor,-atornic S-expressions; YROG
evaluates l " c su;.:;eaents in s e q ~ e n c eu r - t L I eiiher a IIETUXS or GO is
--1st
. G: statements is e ~ L ~ ~ a s t ein
evaluatz2, c r i
d ,which case the
value of ?:is& i s *iL.
,~,'-sic\.
e~.;ses thz P R O G con~aininglc to be exited with the value X.
y 1 ' 7 T T -
C9 c a ~ s ; , ihe se5cence o2 c ~ n . ~ z o~: < t h i na P R O G to be transferred
- - s ZL. ter;isnt f~ l l o w ~t:-~ gl i S L e l I D . In interpreted PIIOGs ,
to
.,L
-.x._,,
.LZ
- -,
ID ia 23:L-.c ~ I
i2c
is r,
e p e 6 ~ e c ~zvaluatei
~y
untLl an atomic value
is found. f - ; o w ~ v e r ,in com2lled PAC,a, -3 is nu 1 evaiu~ced. GO cannot
t-*
~ ~ i - ~ s f; LeLr~ G: o ; ~02 a j?RZC,
rn
o
3 s c - ::TTXY
- ,-.
a -=,\UU,
r
s
:
2
-k x a -~1e :
,../
'
GI
- --
GO s l - . ~ ~ Z occuz
d
elther at the to? l s v e l of
co;;~posLiLcnsof COND, ASD, 02, and NOT which
l e v ~ lof 2 ?;COG.
;nd
", L:
~ h e- 2 ,
The fuzctLon LEECy:L nay be d e y l r i e d as fo;>aws:
(DE L E N G T H (i)
(PZOG (:
(SL Tq N
L1
L) (RETZK, , \ j ) )
(SET? N (ADD1 N);
(SSTQ L (CDX L ) )
(LO
PRCZ' evalus:es
value of X,).
L-
G)
( C O X 3 ((ATOM
Ll)))
all ex~ressiozsXI X2
...
Xi;,
and returns the
SAILON Xo.
28.2
13.1 SET and SETQ
bound
to change the vali;zs of variables w h i c h are
L . L ~ h eLfi,33A
r
or PROG, c r varia3;es which are bound globally.
SLr7 ..:d SETQ 2re used
-J?
(See 7.;,.
L.,:h
-SF"
argd
I?
c.. ...,es ,he vslue 0 2 the Tden~;ifFerID tc, V and returns V.
.&;a L Z Z evaluated.
-,,
?-.,~-.-"-..-id
.\o-~e: I
L \ ....
Z - i - i ~ t E ~ SZ?1
~ s ~can
\-
azi
S Z Y , c:
-
V, but doss
be used only on globally bound
L,bbvsriables.
~i
- ; e s :he vcclce of ID to V
c.va2~steID,
&LC.
rctur-ils V.
SETQ evaluates
SAILGS No. 28.2
C CSTROL
m'
Zunctions s e l e c t a s d c o n t r o l i n ? u t / o u t p u t devices
fo;l~wLi--,
1
'
:
-
~ c fdi l e s ,
-~. -l
i eLU;;;z~ aye specifLc - -sy ci filename Ilsc of t h e following farm:
f
-- .
2 leriame p a t
. .=
.. .=
.
c ~ ~ l-;;
cay,ce
fii e ~ x m e list
device-name
: := fLleaame-;ist filename
is 2 i L h E y eri .L I ; L I ~ LF~= ~- -+- L:GIIGWCCI
~
by colon (:) which
is tl-12 .-,--, GL so2.e i-~?,~;;.
c r o x c L ~ .C
c~
i ~ v i ~ e , i: ,Ls L c o n t a i n i n g a
p r ~ , 2 CC-3i- O:,L'fi---a,u~lex n u ~ - ~ 5 cwkich
x
l:-.-kgiicit
ly s p e c i f i2s t h e d i s k .
"
,-<---A
J O - - ? - ~
- 3
-.J.*&Lb
L
.,,.
A
- ---
.
-.
---.-s;
;;A.: -.--
zx~zi:,-:z,
,Lj-';-Ler
ide----<
~~,,f:er
tJ';lLch s p z e l ; -2s a filename with
o r a dotted p;Ly
of f i i e n a n e a n d cxcension. I n b o t h
"
czscs ~ h e
f;Ler.~zs a ? p l l e s t o t k L s most r e c e n t l y ( t o t h e l e f t ) s p e c i f i e d
Ex_-ril>;ca:
-
:he
foliowll-rg e x ~ r ; . ~ i eshow
s
che c c r r s s ~ o n c k n c ebetween L I S P
z c b P I ? tilensme s p e c l f L c a e i c ~ & s .
LIS P
PIP
<DSI<: F O O (1,FG3)
DSK:- "3,I)SE;:
(3AZ
.
G 3 ) YAZ)
3,~00
3AZ..UX,2/;.2
Channel nznes can optLonzlly be assigc-ed t o f i l e s s e l e c t e d by t h e
f u ; ~ c t i ~ ; - ,X:\T?ST
s
~7.5
OiTTliJT, k dkaiimeZ r.r;..z
is a;
icientlf i e r which i s
nor: f o i ; ~ w s d by r, colon.
I f no ~h.an-r,~.,.;ax2 i s s p c i f i e d t o X P U T o r
OUTPUT then t h e channel nane T i s assumed.
The c h a n r e l name NIL s p e c i f i e s
t h e t e l e t y p e in t h e functions INC azd OUTC.
Up t o 14 channels may be
a c t i v e a t any time.
I>:?L"b12escs
azy file p r e v l c L a i y Initialized on the channel, and
in;
.,,tiaiizcs 2 ~ :2 ~ 2 . ;rlx
~
fFrsr f L I Z s p e c l f i e 2 by tke f i l e n a m e - l i s t .
s p e c i f i e d , T otherwise.
:,S?UT rztr::-_-,s iZ-,e channel i f one w,
r.ot eva
z ~ ;is
.
azgurnents.
I:;(: 5 .
-
-
.
L,,
...
;h;j
~
p
.
-,-.':
~i z d~
INPUT does
c:--2;;~el
i f
fay ini3Ut.
The channel NIL
~=I;~Lc~LL~.I
~ ; I ~ ; I . ~ : C C ~ * L ACTIGK i s not s p e c i f i c d
O- ~
c ~ =x x;~,
~ ~ .2kcn
q
..-'i- .,-,-d ~ F ~ i ; ~ S, yZ ~ C L . .i r~ i ~p ~ tf i i e i s n o t r e l e a s e d ,
r,;,, - ~ z ~ i ry_ ,-u 2L2cc,3de -.l
i ~ C rL; lL- - C ' q = 1 > t::~;; Lhac f i l e i s r e l e a s e d , making
. ,J,kvLu;;iy
s e l Z c r e6 chcar.z 1 s v r i l a b l2
S;*<ct>;
-...* . 2y;.?
L
-
L L . L
i~
:
.
:
Gi.2
L'.LQ
-
7
.
I-
L
n
a
L-L'L
-,.
-
l L 2 7L- c L
.
'
. ::-an
L L ~ ~Ir:?~i.<
?
zhe s e l e c t e d i n p u t
tkA2 Se12CtCzc,zrLL-Lel
.:
..,<-austei, then t h e next
- A..1 &-....-.- - .
--LA" f o r j-:-,e c:;.an:Lel
is
,L;,Ezed
and i n p u t , u n t i l
- .
?
.
-.---...
L.&L i
I.- -is C : ; : ? , ~ . ~tSn 6 , T ; - ~ ~tlqL2
~ ? te iL -LY,I: i s a u t o m a t i c a l l y s e l e c t e d
. .. .
-- - .- . - sL:i
(;;c~:?, @32;7$) ..ts ' ,- --L gi12 -dse of ERRSET around:
. . a c c b 2 t 4A i-- ...
,--zxz
L a - L e .-.--;,r
~GT-C: .. -'-i-j.r.. l;:.-,:~
iLIL:ies LZ possible: t o d e t e c t
..<
- of z- .,
.
,L 2 9 Z ~L, ~L~
S T4 T
- C L ~ ~z , ~ n t y o rl e t u r n s ~3 t h e t o p ?eve l of
.-,-. .
. _ .
L
,IQ
s v a i z a t e s i t s arguxici-i~s, and r e - ~ u r z l s,.;. . ~ r e v i o u s l ys e l e c t e d
.. \-&i-izeL
ri&::.L *
rnl-
-*
-A,-.-
L L. c
c--,
--- i.
.->
7
?-
. '
,.,,
.
,L,
~V;I---C c 23;~s Ln
.-
B il
, ., 7 ,..- J T O
-
2;1,
1
7
0
O;?,
+
A,&L
2 . - -
LI~..~C.~.
.
-,
.
LLL,u-
?
- A -
,
Q
-'
;
~
~
~
AL,<s,
mcl",?Lzs h o u i d 3.2 ;;-~L'riaZizedby IXF,*, ,--channe; t o RZAD iroa.
Ir, or&-:
c a X A D from
.
~z>.cli-L
soaces,
s e p a r a t e channels
IKC c ~ , . -t n s e l e c t the a p p r o p r i a t e
. TLSl)))
2 i i ~SYS: S):ITLE . TLS2 on c k L c , ~ n eTl and
(ISC (T,SFJT SYS: (SXIE
s ~ I i , XEA3 t h e
ti12 t e l e t y p e when t h e 2Fle i s ended.
reselect
(INC (INPL'T FOG DSX: BAZ 2 ~ 3j )
w i l l READ "Llze files DSK: BAZ arid DSK: ZAB on channel F O O
an: ZL .;lect cke teletype ;;L.LcT 30th f i l e s a r e exhausted.
SAILON No. 28.2
14.1.4
OUTPUT
mDUT-.::CzlpN-~x+_:F_I
,~_N!----gs~!'J-
OUTPUT i n i t i a l i z e s f o r o u t p u t on t h e s p e c i f i e d channel t h e s i n g l e
f i l e s p e c i f i e d by t h e f i l e n a m e - l i s t .
OUTPUT does n o t e v a l u a t e i t s
arguments, and r e t u r n s t h e channel name i f s p e c i f i e d , T otherwise.
(OUTC
.CHANNEL
---ACTION)
.
-.--- -.. .
-
OUTC s e l e c t s t h e s p e c i f i e d channel f o r o u t p u t . The c h a n n e l NIL
s e l e c t s t h e t e l e t y p e . The output f ~ n c t i o n si n 14.3 t r a n s f e r o u t p u t
t o t h e s e l e c t e d o u t p u t channel.
I f t h e o p t i o n a l argument ACTION i s u n s p e c i f i e d , o r ACTION = NIL,
then t h e p r e v i o u s l y s e l e c t e d o u t p u t f i l e i s n o t c l o s e d , b u t o n l y
d e s e l e c t e d . I f ACTION = T t h e n t h a t f i l e i s c l o s e d , i . e . , a n end of
f i l e is written.
OUTC e v a l u a t e s i t s arguments and r e t u r n s t h e p r e v i o u s l y
s e l e c t e d channel name.
Examples:
(At t h e t o p l e v e l )
(OUTC (OUTPUT LITT:) T)
(OUTC NIL T)
(OUTPUT FOO DSK: BAZ)
(OUTC (QUOTE FOO) NIL)
(LINE
LENG-TH--.N)
- - - - -
LINELENGTH i s used t o examine or change t h e maximum o u t p u t l i n e l e n g t h
on t h e s e l e c t e d o u t p u t channel. I f N. = NIL t h e n t h e c u r r e n t l i n e l e n g t h i s
r e t u r n e d unchanged, otherwise t h e l i n e l e n g t h i s changed t o t h e v a l u e of N
which i s r e t u r n e d and must be a n i n t e g e r .
CHRCT r e t u r n s t h e number of c h a r a c t e r p o s i t i o n s remaining on t h e
o u t p u t l i n e of t h e s e l e c t e d o u t p u t channel.
INPUT
14.2
(REA
DJ
-----.
-
READ causes t h e n e x t S - e x p r e s s i o n t o be r e a d from t h e s e l e c t e d i n p u t
d e v i c e , and r e t u r n s t h e i n t e r n a l r e p r e s e n t a t i o n of t h e S-expression..
SAILON No. 28.2
READ uses INTERN t o guarantee t h a t r e f e r e n c e s t o t h e same i d e n t i f i e r a r e
EQ*
(READCH)
..------
---.
REAOCH causes t h e next c h a r a c t e r t o be r e a d from t h e s e l e c t e d i n p u t
device and r e t u r n s t h e corresponding s i n g l e c h a r a c t e r i d e n t i f i e r . READCH
a l s o uses INTERN.
-
T Y I causcs t h e next c h a r a c t e r t o be read from t h e s e l e c t e d i n p u t
device and r e t u r n s t h e A S C I I code f o r t h a t c h a r a c t e r .
A f u n c t i o n TEREAD which ignores a11 c h a r a c t e r s u n t i l a l i n e - f e e d i s
seen can be defined:
(DE TEREAD NIL
(PROG NIL
L
(COXD( ( E Q (TYI) 12) (RETURN
NIL)))
(GO L ) ) )
14.2.1
TELETYPE INPUT
Idhen i n p u t i s f r o m t h e t e l e L y p c , REA3is terminated by e i t h e r a n
S-expression followed by altmode.
e n t i r e S-exprzssion or 5y an incol?~~pLete
Altrnode has the e f f e c t of typing a s?ace followed by t h e a p p r o p r i a t e
number of r J g h t parens t o complete t h e S-expression.
This f e a t u r e i s
p a r t i c u l a r l y u s e f u l when an unknown nilrii~er of r i g h t parens? a r e needed or
when i n (DDTIN NIL) mode.
-(DDTIN
-
-
X)
. - -- -. -
DD'TIN i s a f u n c t i o n which s e l c c t s t e l e t y p e i n p u t mode. With (DDTIN NIL),
and typing t o READ, READCH, or TYI, a rubout w i l l d e l e t e t h e l a s t c h a r a c t e r
typed, and c o n t r o l U ( t U ) w i l l deleze the e n t i r e l a s t l i n e typed.
Input
not seen
carriage return
LIS P u n t i l e i t h e r a 1tmode
typed.
With (DDTINT) and typing t o RELiZ, a rubout w i l l d e l e t e the . .-l a s t
S-expression t y p d i f t h e previous ~ l - ~ ~ - : ~ : cwas
r e r a space, r i g h t parens, t a b ,
or conlma, otherwise rubout w i l l d e l e t e t h e l a s t atom fragment typed o r
the l a s t l e f t parens. READ w i l l terminate a s soon a s a complete S e x p r e s s i o n i s typed.
Note:
-
(DDTPN T) i s not recornended when t h e time-sharing system i s
swapping, s i n c e t h e program i s r e a c t i v a t e d (and hence swapped
i n t o core) a f t e r e v e r y c h a r a c t e r typed.
SAZLON No, 28.2
14 . 3
OUTPUT
PRINl causes t h e S-expression S t o be p r i n t e d on t h e s e l e c t e d o u t p u t
device with no preceding or f o l l o w i n g spaces. PRINl a l s o i n s e r t s s l a s h e s
("/I1) b e f o r e any c h a r a c t e r s i n i d e n t i f i e r s which would be s y n t a c t i c a l l y
i n c o r r e c t otherwise ( s e e Chapter 3 ) .
P R I N C i s t h e same a s PRINl e x c e p t t h a t no s l a s h e s are i n s e r t e d .
TERPRI p r i n t s a c a r r i a g e - r e t u r n ,
l i n e - f e e d p a i r and r e t u r n s NIL.
= (PROG~ (TERPRI)
(PRIN1 S)
(WINC (QUOTE
TYO p r i n t s
-
14.3.1
?
1' ) ) )
t h e c h a r a c t e r whose ASCII v a l u e i s N, and r e t u r n s N,
TELETYPE OUTPUT
Output t o t h e t e l e t y p e i s accumulated i n a b u f f e r u n t i l some
c o n d i t i o n causes t h e b u f f e r t o be p r i n t e d (FORCE)
The b u f f e r i s
always p r i n t e d when a t e l e t y p e i n p u t i s r e q u e s t e d o r when t h e b u f f e r
i s f u l l . The f o l l o w i n g f u n c t i o n s determine o t h e r c o n d i t i o n s f o r p r i n t i n g
the buffer.
.
DDTOUT s e l e c t s t h e t e l e t y p e o u t p u t mode.
(DDTOUT T) r e t u r n s T
and causes t h e t e l e t y p e output b u f f e r t o be p r i n t e d a f t e r e v e r y c h a r a c t e r .
(DDTOUT NIL) is t h e normal mode and r e t u r n s NIL. (DDTOUT) r e t u r n s T o r
NIL a c c o r d i n g t o t h e c u r r e n t l y s e l e c t e d mode.
FORCE i s sometimes u s e f u l f o r output t o t h e t e l e t y p e when i n
(DDTOUT NIL) mode. FORCE causes t h e t e l e t y p e o u t p u t b u f f e r t o be p r i n t e d .
This allows one t o s e e o u t p u t d u r i n g long computations which would o t h e r wise be b u f f e r e d u n t i l t h e computation was f i n i s h e d o r u n t i l the b u f f e r
was f u l l .
14-5
-a
SAILON No. 28.2
.
.
.
15.1
.
. .
a
"
EXAMINE AND DEPOSIT
(EXAMINE N)
,-,
-- - -
,
--- --.
EXAMINE r e t u r n s a s a n i n t e g e r t h e c o n t e n t s of memory l o c a t i o n N.
(DEPOSIT N V)
--
-
--
.-" .
DEPOSIT s t o r e s t h e i n t e g e r V i n memory l o c a t i o n N and r e t u r n s V.
..
).
.J
:
/
I
.
.:
v
. , I C , * . .
:
LLI
.
'
,
:
I
-.--.-,r-----.-
-
-
&
a
K; $
f
-
,
Z-
: 1
1.f !I$
-
*
*.
.
- -.
- -
/
a
.
b
-
- ..-*
-- -
"
4
.
- ..
L
.
.
,
"..
I
I
"
'
*
I
"
?.
'
?
4
by ~ n t h o n yC: Hearn
I
, .
i
,
.
!
I
*
g.
I
I
:
.
i
i
*i
*I
. ,
.'
I *..
DIFFERENCES FROM STANDARD LISP
'
I .
'
-,.
. - = I
t
t
.
1
I
:: ..
'
I .
I
I
L
*
1
-- --_- -,.- -...-.------
APPENDIX
A
.L .
I
8
'
O *
~
I
.
'
.
j
.
.
SAILON 28.2
4
.
r
@lJ~i+.ti\i~
.
- ,
-
.
b
;
* -
?
I
1 .
a
I
I
'
'
I
f
_
'
a
s
@ j
i
f
I
'
Standard LISP was developed t o provide f o r t h e easy assembly of
a given LISP program i n more than one LISP system. Its s y n t a c t i c a l form
i s described i n d e t a i l i n a S t a n f o r d A 1 P r o j e c t Memo which a p r o s p e c t i v e , . .
u s e r should c o n s u l t f o r d e t a i l s . We s h a l l not d u p l i c a t e t h e c o n t e n t of j
1
t h i s Memo h e r e , b u t simply p o i n t o u t t h a t t h e t r a n s l a t i o n between a
Standard LISP program and a given LISP system is achieved by a preprocesllot
!
which i s defined f o r a given system and always loaded ahead of any
.
Standard LISP program. This Appendix w i l l t h r r e f o r e l i m i t i t s e l f t o
I
p o i n t i n g o u t t h e e s s e n t i a l d i f f e r e n c e s between Standard LISP a n d .
.
Stanford A 1 LISP 1.6 and t h e procedure f o r loading t h e preprocessor and
running Standard LISP programs i n t h i s sy8tem.
1
- 1
.
!
bY
I
.
I '
I
I
I
I
r)
4
i
!
.
'
0.
i
I
'+
:
I
I
1I
A. 1 WRITING STANDARD LISP PROGRAMS
The major d i f f e r e n c e s between a program w r i t t e n i n Standard LISP as!
,
1
epposed t o one i n Stanford A 1 LISP 1.6 a r e a s follows:
j
I
1I
I
(I)
(if)
I
I
I
I
I
\
I
't
!
Programs a r e w r i t t e n i n EVALQUOTE r a t h e r than EVAL format.
A l l atoms o r c h a r a c t e r s t r i n g s c o n t a i n i n g non-alphameric c h a r - ;
a c t e r s (alphameric c h a r a c t e r s i n t h i s c o n t e x t being t h e
I
I
c a p i t a l i z e d Roman l e t t e r s A through Z and decimal d i g i t s 0
through 9) must be replaced by an alphameric atom. The
1,
'
.
'
..
p a r t i c u l a r v a l u e r e q u i r e d f o r t h e atom i n S t a n f o r d A 1 LISP 1.6:
must then appear i n a c a l l t o t h e preprocessor f u n c t i o n NEWNAM!
d e s c r i b e d i n t h e Standard LISP memo. It i s a d v i s a b l e f o r t h e /
u s e r t o prepare a s p e c i a l f i l e c o n t a i n i n g t h i s c a l l t o NEWNAM,j
I
which can then be loaded w i t h t h e preprocessor.
I
.
1
,
*,
1
(iii)
MACROS, LEXPRS and LSUBRS a r e not d e f i n e d i n Standard LISP.
e
1
(iv)
COND expressions can have only one consequent, and must end
w i t h a p a i r (T FORM)u n l e s s t h e COND occurs w i t h i n -a PROG.
I
i
i
I
I
.d
'
I
I
I
iI . .- -
1
1
I
".
C
I
1
,
,
-
I
j
'
.
I
(v)
The f u n c t i o n s MAP, MAPCAR and MAPLIST a r e d e f i n e d , b u t t h e i r
arguments are i n t h e conventional o r d e r o p p o s i t e t o LISP 1.6.
1
II
i
I
(vi)
--
The following f u n c t i o a s have a l t e r n a t i v e 8names o r fprms i n
Standard LISP. Users should c o n s u l t t h e Standard LISP Memo
f o r t b p a r t i c u l a r d e f i n i t i o n s - o f --the-ftmctiomr- mentioned. ,
.- <\
- -I l -.---.
-AY
,
1
-L -
iI
I
CEId7'ER P A G E P!Lli,iLI<K
BLTWEEN f H E 5 k LINES
a
- --
-
4
--
---
*
\
-
.-*-
a
-
.
Stanford A 1 LISP'k.6 '?un=tibh
!
I
APPEND
1
lit
i
I
.I
I
. , I I.,,,
.,.I
I l l ,
1
1,
a
I
i
I
I # I
1
I
!
,
(*I
I 1
( 1
(
1.
!
l..,..
4
I
8
I
L
l
L
.
1
1
sa&
naxpe, but only two arguments
I
I
I
allc&qd:
[I
4
APPLY
ARRAY
/
CHRCT
I
Same name, but d i f f e r e n t arguments.'
. .-.
. ..
Use POS instead.
!
!
ERR
/ Use
ERRSET
1 ERRORST
EVAL (with one argument)
; *EVAL
GENSYM
1
II Use
I
RDS
1 Same name,
I
I
- --
I
INPUT
I
Use MKSYM (mksym[ ] = i n t e r n [ gensym[ ) ] )
I
INC
ERROR instead.
1
but d i f f e r e n t arguments .i
_-*I
i
I-
*
-
I
I
LINE LENGTH
I
OTLL
LSH
I
MAKNAM
/ U s e COMPRESS instead.
OUT C
/ Use
I
OUTPUT
PUTPROP
WRS
I
1 Same name,
i
I
but d i f f e r e n t arguments.
I
I
: Use PUT (put[u,v,w] = putprop [u,w,v] )
I
Same name, but i s a SUBR taking a
s i n g l e atom -as. argument.
I
1
\
I
I
1
I
;
1
!
I
1
(vii)
The following functions and value c e l l s a r e not defined ir(
Standard LISP. They may be included i n a given program i f
t h e u s e r can provide an eqyivalent d e f i n i t i o n i n h i s preprocessor f o r another LISP; system:
I
I
I
I
I
i
i
Use COMPRESS instead.
READLIST
I
3-
I
1
I
I
I
ALIST
ARG
ASCII
ASSOC
BAKGAG
BASE
BOOLE
BPEND
BPORG
CSYM
DDTIN
DDTaUT
DE
DEFPROP
DEPOSIT
DF
A, 2
DM
ED
EXAMINE
INTERN
LAST
EXARRAY
MAKNUM
MAPC
Lorn
EXCISE
EXPLaDEC
FLATSIZE
FORCE
GC
GCD
GCGAG
GCTIME
.
GETL
GETSYM
IBASE
INITFN
MEMQ
,
NCONS
NOUUO
NSTORE
NUMVAL
OBLIST
PUTSYM
SPEAK
SPECIAL
STORE
TIME
.
*
,'-
TYI
TYO
XCONS
*AMAKE
*APPEND
*DIF
*EVAL
*FUNCTION
WREAT
*LULL
*LESS
*NOPOINT
*PLUS
'
quo
*RSET
*TZMES
RUNNING STANDARD L I SP PROGRAMS
1
.
To f a c i l i t a t e t h e running of Standard LISP programs i n t h e Stanford
I
A 1 LISP 1.6 system, a SYS: f i l e PREP.LSP i s a v a i l a b l e c o n t a i n i n g t h e
Standard LISP preprocessor f o r t h i s system. A LAP v e r s i o n of t h i s f i l e
i s a l s o a v a i l a b l e on SYS: w i t h filename PRI3P.W.
To u s e t h e l a t t e r
f i l e , t h e u s e r must have previously lohded LAP i n t o h i s c o r e p a r t i t i o n .
.
1
I
-**
I
1
,
. .)
I
Both PREP f i l e s a r e i n Stanford, A 1 LISP 1.6 format and can t h e r e f o r a
I n a d d i t i o n t o t h e preprocessor, t h e f i l e s c o n t a i i
be loaded u s i n g I N C .
t h e following f u n c t i o n s t o h e l p w i t h / t h e running of programs:
I
!
,
i
(SINC CHANNEL ACTION)
SINC i s l i k e I N C , except t h a t t h e f i l e s read i n should b e i n
Standard LISP format.
I
(SINC
(INPUT DSK: F1 ( ~ 2 . . L S P ) ) '
1
I
I
w i l l load t h e Standard LISP DSK: f i l e s F l and F2.ESP.
This f u n c t i o n i s used i n conjunction w i t h t h e LISP 1.6 compiler.
CMFILE compiles a l l f u n c t i o n s d e f i n e d i n t h e Standard LISP f i l e s appearing
i n FILENAME-LIST and o u t p u t s t h e LAP o n t o DEVICE-NAME as f i l e s i n S t a n f o r d
A 1 LISP 1.6 format w i t h t h e same name as t h e i n p u t f i l e s and a n e x t e n s i o n
LAP. Any EVAIQUOTE p a i r s .in the f i l e w h i c h - a r e finatffunctim-deft~itione'
it
a r e a l s o output after convetsion to, L I S P - l . 6 format.
--
4.
: i T I . l ? P A G E NUME3i.R
t:,-T WEEN T H E S E LINES
I
/"
----
-.
4 3
I
h
j
i
The standard eofnpiler messages a r e p r i n t e d by CMFILE. I n a d d i t i o n ,
a check i s made f o r t h e e x i s t e n c e of a f u n c t i o n i n d i c a t o r on t h e property
l i s t of any f u n c t i o n being compiled. I f one i s found, a message
i s p r i n t e d , This i s u s e f u l l f o r d e t e c t i n g c o n f l i c t s between system and
I
user-program f u n c t i o n names. F i n a l l y , any s p e c i a l v a r i a b l e d e c l a r a t i o n s '
should be added t o t h e use.r preprocessor f i l e c o n t a i n i n g the c a l l t o NEWl4AM.I
'
7
*
C
*
w i l l produce LAP v e r s i o n s of t h e DSK: f i l e s F1 and F'2,LSP a s DSK: f i l e s ,
w i t h names FloLAP and F2.LAP, r e s p e c t i v e l y .
Y
This f u n c t i o n produces GRINDEF copies i n Standard LISP format of all
Standard LISP f i l e s declared i n FILENAME-LIST. The f i l e s a r e produced
w i t h t h e same name and a n e x t e n s i o n NEW s o t h a t t h e d i s k can be used f o r :
both input and output. A l l t h e new f i l e s can have t h e i r e x t e n s i o n s e a s i l y
changed using PIP. To use GRINFILJ3, t h e SYS: f i l e GRIN o r t h e e d i t o r
1
ALVINE must a l s o be loaded.
n
I
-i -
- .-
'
I
I
Examp l e
LSP))
(GRINFILE DSK: DSK: F1 (F2
I
w i l l produce GRINDEF copies of t h e f i l e s F l and F2.LSP a s DSK: f i l e s with
i
names F1.NEW and F2,NEW, r e s p e c t i v e l y .
i
1
!
( /
i
GETDEF s e a r c h e s t h e Standard LISP f i l e FILENAME f o r t h e f u n c t i o n
I
namesspeyifiedand:bk.dy themwhen ncountered. I f , a n y o f t h e f u n c t i o n j
names a r e not found, a message
i
f
j
1
( FUNCTION-NAME
FUNCT~ON-NAMENOI FOUND)
71
...
&,
i
1
is printed.
ExampPe
(GETDEFDSK: Fl CALLl WLE)
/
w i l l load t h e f u n c t i o n s CALLl - and- -aL12-f C E - - t b ~ ~f isl ~e -:F1,
- -
I
.
:
i
1
\.4t
:
I
0 '
i.
t
r
,
NlJMilJER
q:
LL LINES
-
I
C ,
,
,
?a'
i
----A
i
I
.
.
.
I
'
SAILON No. 28.2
APPENDIX B.
ERROR MESSAGES AND CONTROL
-.
'
.
L
"
;
I
B. 1 ERROR MESSAGES
The LISP i n t e r p r e t e r checks f o r some e r r o r c o n d i t i o n s and , p r i n t s
messages a c c o r d i n g l y . Many'erroneous c o n d i t i o n s a r e n o t ' t e s t e d and
r e s u l t i n e i t h e r t h e wrong e r r o r message a t some l a t e r time, o r no e r r o r
message a t a l l . I n t h e l a t t e r c a s e t h e system has screwed you' ( o r - i t s e l f )
without complaiving.
When e r r o r messages a r e p r i n t e d , i t i s u s u a l l y d i f f i c u l t t o determine
t h e f u n c t i o n which caused t h e e r r o r and t h e f u n c t i o n s which c a l l e d i t . I n
t h i s s i t u a t i o n , (BAKGAG T) w i l l t u r n on t h e BACKTRACE f l a g which c a u s e s
t h e h i e r a r c h y of f u n c t i o n c a l l s t o be p r i n t e d a s d e s c r i b e d i n t h e n e x t
section.
The f o l l o w i n g i s a n a l p h a b e t i c a l l i s t i n g of e r r o r messages, t h e i r
cause, and i n some c a s e s , t h e i r remedy. ,Some e r r o r messages p r i n t two
l i n e s , such a s :
F 00
UNBOUND VARIABLE
- EVAL
These messages a r e d e s c r i b e d l a s t i n t h e l i s t i n g , and are of t h e form:
BINARY PROGRAM SPACE EXCEEDED
6
ARRAY, EXARRAY, or IAP h a s exceeded BINARY PROGRAM SPACE.
more BPS next. time.
ALLOCATE
CANT EXPAND CORE
INPUT, OUTPUT, LQAD; or.-ED f a i l e d . t o e x p a n d ' c o r e .
is too large.
CANT F I N D FILE
Your job
- INPUT
The i n p u t f i l e was n o t found. You probably f o r g o t t o g i v e t h e f i l e
name e x t e n s i o n , or a l e g a l f i l e name List.
..
- .
*
SAILON
NO.
28.2
DEVICE, NOT AVAILABLE
I N P U T or' OUTPUT found t h e s p e c i f i e d device u n a v a i l a b l e .
job i s probably u s i n g it.
Some o t h e r
DIRECTORY. F U L L
The d i r e c t o r y of t h e o u t p u t d e v i c e i s f u l l .
DOT
c ONTEXT ERROR
'
READ dbes n o t l i k e d o t s a d j a c e n t t o parens o r o t h e r d o t s .
F I L E I S WRITE-PROTECTED
OUTPUT found t h a t t h e s p e c i f i e d f i l e is w r i t e - p r o t e c t e d .
F I R S T ARGUMENT NON-ATOMIC
-
PUTPROP
An a t t e m p t was made t o PUTPROP ontq a n o n - i d e n t i f i e r .
'
GARBAGE D OB L I S T
Some member of t h e O B L I S T h a s been garbaged.
You a r e i n t r o u b l e .
I L L E G A L DSVICE
I N P U T or OUTPUT was a t t e m p t e d t o e i t h e r a n o n - e x i s t a n t d e v i c e or
t o a d e v i c e of t h e wrong type. I.e., I N P U T from t h e l i n e p r i n t e r .
I
I L T E G A L OBJECT
- READ
READ o b j e c t s t o s y n t a c t i c a l l y i n c o r r e c t ':S-express i o n s .
I N P U T ERR OR:
Bad d a t a was r e a d from t h e s e l e c t e d device.
SAILON No, 28.2
MORE THAN ONE S-EXPRESSION
- MAKNAM
MAKNAM and READLIST o b j e c t t o a l i s t which c o n s t i t u t e s t h e c h a r a c t e r s
f o r more t h a n one S - e x p r e s s i o n ,
NO FREE STG IEFT
A l l f r e e s t o r a g e i s bound t o t h e OBLIST and p r o t e c t e d c e l l s
(such a s l i s t ARRAY c e l l s ) , and bound v a r i a b l e s on e i t h e r t h e
REGULAR or SPECIAL pushdown l i s t , Unbinding t o t h e t o p , l e v e 1
w i l l u s u a l l y r e l e a s e t h e s t o r a g e . I f you a r e i n a b i n d f o r more
f r e e s t o r a g e , t r y t o REALLOC a s d e s c r i b e d i n APPENDIX C.
N O FULL WORDS LEFT
A l l f u l l words a r e b e i n g used f o r p r i n t names and numbers,
The problem and i t s s o l u t i o n a r e s i m i l a r .to: FREE STG,
'
110 CHANNELS
NO
LEFT
?
INPUT o r OUTPUT f a i l e d t o f i n d a f r e e I / O channel,
a maximum of 14 a c t i v e 110 channels.
There i s
- INC
N O INPUT
An a t t e m p t was made t o s e l e c t a channel f o r i n p u t w i t h I N C wlzich
was n o t i n i t i a l i z e d w i t h INPUT.
. . ,
N O LIST
-
.
k
MAKNAM
.
MAKNAM and READLIST o b j e c t " t o a* empty l i s t ,*
N O OUTPUT
,
-
.-A
*
OUTC
*
. .
An a t t e m p t was made t o s e l e c t a c h a n n e l f o r o u t p u t wLth OUTC whichwas n o t i n i t i a l i z e d w i t h OUTPUT.
&
N O PRINT NAME.
-
.
INTERN
*
,
INTERN found a. member of t h e OBLIST which has no : p r i n t name,
You a r e i n t r o u b l e .
SAILON No. 28.2
OUTPUT ERROR
F
Data was improperly w r i t t e n on t h e s e l e c t e d o u t p u t device.
P o s s i b l y a write-locked DECTAPE.
OVERFLOW
,.
... ,
Some a r i t h m e t i c f u n c t i o n caused overflow
PDL OVERFLOW FROM GC
-
- either
fixed or floating.
CANT CONTINUE
There i s n o t enough r e g u l a r pushdown l i s t t o f i n i s h garbage
c o l l e c t i o n . You l o s e . Try t o REALLOC a s d e s c r i b e d i n
APPENDIX C.
READ UNHAPPY
-
MAKNAM
MAKNAM and READLIST o b j e c t t o a l i s t which i s n o t a n e n t i r e
S-expression.
+
REG PUSHDOWN CAPACITY EXCEEDED
SPEC PUSHDOWN CAPACITY EXCEEDED
A pushdown l i s t has overflowed. This i s u s u a l l y caused by
n o n - t e r m i n a t i o n of r e c u r s i o n . Sometimes you need t o ALLOCATE
o r REALLOC more pushdown l i s t .
-
TOO FEW ARGUMENTS SUPPLIED APPLY
TOO MANY ARGUMENTS SUPPLIED APPLY
-
APPLY checks a l l c a l l s on i n t e r p r e t e d f u n c t i o n s f o r t h e proper
number of arguments.
"
X MADE ILLEGAL MEMORY REFERENCE
The f u n c t i o n x ' r e f e r r e d t o a n i l l e g a l a d d r e s s .
t a k i n g t h e CAR o r CDR of a n atom o r number.
Usually caused by
X NON-NUMERIC ARGUMENT
r
A r i t h m e t i c f u n c t i o n s r e q u i r e t h a t t h e i r arguments be numbers.
X PROGRAM TRAPPED FROM
An
i l l e g a l i n s t r u c t i o n was e x e c u t e d i n function'^.
"
B-k
(
.
.-,
o
..-
,
.
.
.
1
1
.
-.
. .
.
SAILON No. 28.2
X UNBOUND VARIABLE
- EVAL
EVAL t r i e d t o e v a l u a t e a n i d e n t i f i e r and found t h a t i t had no
value. You probably f o r g o t t o QUOTE some atom o r t o i n i t i a l i z e i t .
X UNDEFINED COMPUTED GO TAG I N
A GO i n some compiled f u n c t i o n had a n undefined l a b e l .
X UNDEFINED FUNCTION
X UNDEFINED FUNCTION
-
APPLY
The f u n c t i o n X i s n o t defined.
X UNDEFINED PROG TAG
-
GO
A GO i n some i n t e r p r e t e d f u n c t i o n had a n undefined l a b e l .
B. 2
FUNCTIONS FOR CONTROLLING ERRORS
4
(ERRSET E 'IF 'I)
--... .
A
-
,
.
ERRSET e v a l u a t e s t h e S-expression E and i f no e r r o r occurs during
i t s e v a l u a t i o n , ERRSET r e t u r n s (LIST E)
I f a n e r r o r occurs, t h e n t h e
e r r o r message w i l l be suppressed i f F # N I L , and N I L i s r e t u r n e d a s t h e
v a l u e of ERRSET. I f t h e f u n c t i o n ERR i s c a l l e d during e v a l u a t i o n , t h e n
no message i s p r i n t e d and ERRSET r e t u r n s t h e v a l u e r e t u r n e d by ERR.
.
(ERR E)
-
ERR r e t u r n s t h e v a l u e of E t o t h e most r e c e n t ERRSET,
l e v e l of LISP i f t h e r e is no ERRSET.
Dr
t o the top
;VRSET s e t s a s p e c i a l f l a g i n t h e i n t e r p r e t e r t o t h e v a l u e of X.
Normally, (with (7kRSET NIL)) when a n e r r o r occurs, s p e c i a l v a r i a b l e s
a r e r e s t o r e d t o t h e i r t o p l e v e l v a l u e s from t h e s p e c i a l pushdown l i s t .
With (9:RSET T), t h e s p e c i a l v a r i a b l e s a r e n o t r e s t o r e d and s t i l l c o n t a i n
t h e v a l u e s a t t h e time of t h e e r r o r .
BAKGAG s e t s a s p e c i a l f l a g i n t h e i n t e r p r e t e r t o t h e v a l u e of :-lo
I f t h e f l a g = 'I when a n e r r o r occurs, t h e n a b a c k t r a c e i s p r i n t e d a s a
s e r i e s of f u n c t i o n c a l l s , determined from t h e r e g u l a r pushdown l i s t ,
s t a r t i n g from t h e most r e c e n t c a l l . The format f o r p r i n t i n g is:
SAILON No. 28.2
meaning:
printout
fnl-fn2
fnl
- EVALARGS
fnl
- ENTER
?
-
fnl
Function 1 c a l l e d f u n c t i o n 2.
The arguments t o f n l a r e being
e v a l u a t e d before e n t e r i n g f u n c t i o n 1.
The f u n c t i o n 1 i s e n t e r e d .
Some i n t e r n a l LISP f u n c t i o n c a l l e d
f u n c t i o n 1.
Note:
The BACKTRACE p r i n t o u t i s o f t e n confused by compiled f u n c t i o n c a l l s
of t h e form (RETURN (FOO X ) ) which i s compiled a s (JCALL (E FOO)) which
can be changed t o (JRST e n t r a n c e t o FOO ) which w i l l n o t show up i n
t h e BACKTRACE.
,
9
INITFN s e l e c t s t h e f u n c t i o n of no arguments FN a s a n i n i t i a l i z a t i o n
f u n c t i o n which is e v a l u a t e d a f t e r a LISP e r r o r r e t u r n t o t h e t o p l e v e l
(INITFN) r e t u r n s t h e c u r r e n t l y
has occurred or whenever a BELL is typed.
selected i n i t i a l i z a t i o n function.
I n i t i a l i z a t i o n f u n c t i o n s a r e u s e f u l when i t i s d e s i r a b l e t o change
t h e t o p l e v e l of LISP. For i n s t a n c e ,
(INITFN (FUNCTION EVALQUmE) )
causes t h e t o p l e v e l of LISP t o become EVALQUOTE i n s t e a d of EVAL.
SAILON 28. '2
APPENDIX C
MEMORY ALLOCATION
5
The LISP 1.6 s y s t e m h a s many d i f f e r - n t a r e a s o f memory f o r r
s t o r i n g d a t a which c a n i n d e p e n d e n t l y v a r y i n s i z e . ~om'e LISP a p p l i c a To a l l o w
t i o n s demand l a r g e r a l l o c a t i o n s f o r t h e s e a r e a s t h a n o t h e r s .
u s e r s t o a d j u s t t h e s i z e s o f t h e s e a r e a s t o t h e i r own n e e d s , a memory
a l l o c a t i o n procedure e x i s t s .
C. 1 ALLOC
When t h e LISP s y s t e m i s i n i t i a l l y s t a r t e d , i t t y p e s "ALLOC?".
I f you t y p e "N" o r s p a c e ( f o r no) t h e n t h e s y s t e m u s e s t h e s t a n d a r d
a l l o c a t i o n s . If you t y p e "Y" ( f o r y e s ) t h e n t h e s y s t e m a l l o w s you t o
s p e c i f y f o r e a c h a r e a e i t h e r a n o c t a l number d e s i g n a t i n g t h e number o f
words for - c h a t a r e a , .or a s p a c e d e s i g n a t i n g t h e s t a n d a r d a l l o c a t i o n
f o r t h a t a r e a . While t y p i n g a n o c t a l number, r u b o u t w i l l d e l e t e t h e
e n t i r e number typed.
$
standard a l l o c a t i o n
ALLOC? Y
FULL WORDS =
BIN.PROG.SP =
SPEC.PDL =
REG. PDL =
HASH =
alternative
type Y o r space
o c t a l number o r s p a c e
II
Any r e m a i n i n g s t o r a g e i s d i v i d e d between t h e s p a c e s a s f o l l o w s :
1 / 1 6 f o r f u l l word s p a c e ,
1 / 6 4 f o r e a c h pushdown l i s t ,
t h e r e m e i n d e r t o f r e e s t o r a g e and b i t t a b l e s .
HASH d e t e r m i n e s t h e number o f b u c k e t s on t h e OBLIST;
C.2
REALLOC
I f you have a n e x i s t i n g LISP c o r e image b u t have e x h a u s t e d one of t h e
s t o r a g e a r e a s , it i s p o s s i b l e t o i n c r e a s e t h e s i z e of t h a t a r e a
F i r s t , expand c o r e w i t h t h e time
using t h e r e a l l o c a t i o n procedure.
s h a r i n g s y s t e m command CORE (c) and t h e n r e e n t e r t h e L I S P c o r e image w i t h
t h e REE command. For example, i f t h e o r i g i n a l c o r e s i z e was 2 6 ~ , y?u
c o u l d i n c r e a s e i t by 4 K a s f o l l o w s :
r -
SAILON 28.2
tC
-
* C 24
-REE
c:'
-
When you r e e n t e r a c o r e image, a l l a d d i t i o n a l c o r e i s a l l o c a t e d a s
follows :
114 f o r f u l l word space
1/64 f o r each pushdown l i s t ,
t h e remainder t o f r e e s t o r a g e and b i t t a b l e s .
C.3
BINARY PROGRAM SPACE
The r e a l l o c a t i o n procedure does n o t i n c r e a s e t h e s i z e of b i n a r y
program space. However, i t i s p o s s i b l e t o i n c r e a s e b i n a r y program
space by expanding c o r e w i t h t h e CORE (C) command and s e t t i n g BPORG
and BPEND t o t h e beginning and end of t h e expanded a r e a of core.
For example, i f you now have 32K of c o r e and want 4K more BPS, do t h e
£01 lowing :
9
tC
. C 36
-.S
?(SETQ BPORG (TIMES 32. 1024.))
"(SETQ BPEND (PLUS BPORG 489.5. ) )
-
Note:
I f you use t h e r e a l l o c a t i o n procedure a f t e r having expanded c o r e
f o r any purpose, i t w i l l r e a l l o c a t e t h i s a d d i t i o n a l c o r e f o r i t s
own purposes, t h u s d e s t r o y i n g t h e c o n t e n t s of t h e expanded c o r c .
The f o l l o w i n g a r e t h e s t a n d a r d causes f o r expansion of c o r e :
1)
2)
3)
4)
C.4
n
,
using J / ochannels.
u s i n g t h e LOADER
(LOAD)
.
,
expanding c o r e f o r more b i n a r y program space.
u s i n g (ED)
-
.
6
"
.
SUMMARY OF STORAGE ALLOCATION AREAS
BINARY PROGRALY SPACE
FREE STORAGE
FULL WORD SPACE
B I T TABLES
REGULAR PUSHDOWN LIST
Area f o r compiled f u n c t i o n s and a r r a y s .
Area f o r L I S P nodes.
Area f o r p r i n t names and numbers.
Area f o r t h e garbage c o l l e c t o r .
Area f o r a l l f u n c t i o n c a l l s and n o n - s p e c i a l
v a r i a b l e s i n compiled f u n c t i o n s .
SAILON 28.2
Area f o r i n t e r p r e t e d v a r i a b l e s and s p e c i a l
special variables.
A r e a f o r I / O b u f f e r s , ALVINE, LOADER, and any
l o a d e d programs.
SPECIAL PUSHDQWN LIST
EXPANDED CORE
TOP OF CORE
3
i--
1
EXPANDED CORE
i
Z
I
-
--
1
I
#
i
I
SPECIAL PUSHDOWN LIST
i
Z
1
--
G
u
u
R PUSHDOWN LIST
I
I
'
I
t
i
t
J
1
i
t
BIT TABLES
FULL WORD SPACE
!
i
1
i
FREE STORAGE
E
Ii
BINARY PROGRAM SPACE
LISP INTERPRETER
1
I
I
BOTTOM OF COW
Memory map f o r t h e LISP 1.6 s y s t e m .
SAILON No. 28.2
APPENDIX D
GARBAGE COLLECTION
A l l LISP systems have a f u n c t i o n known a s t h e garbage c o l l e c t o r .
T h i s f u n c t i o n a n a l y z e s t h e e n t i r e s t a t e of l i s t s t r u c t u r e which i s
p o i n t e d t o by e i t h e r t h e OBLIST, t h e r e g u l a r pushdown l i s t , t h e s p e c i a l
pushdown list, list arrays, and a few other s p e c i a l cells. By recursively
marking a l l words i n f r e e and f u l l word s p a c e s which a r e p o i n t e d t o i n
t h i s manner, i t i s p o s s i b l e t o d e t e r m i n e which words a r e n o t p o i n t e d t o
and a r e t h e r e f o r e garbage. Such words a r e c o l l e c t e d t o g e t h e r on t h e i r
respective free storage lists.
GC c a u s e s a garbage collection t o occur and r e t u r n s NIL. Normally,
a garbage c o l l e c t i o n occurs o n l y when e i t h e r f r e e o r f u l l word s p a c e h a s
been e x h a u s t e d .
GCGAG s e e s a s p e c i a l f l a g i n t h e i n t e r p r e t e r t o t h e value of X.
When any garbage c o l l e c t i o n o c c u r s , i f t h e f l a g # NIL, t h e n t h e
following is printed:
either
or
or
FREE ST ORAGE EXHAUSTED
FULL WORD SPACE EXHAUSTED
nothing
followedby
x F R E E STORAGE, yFULLWG3DSAVAILABLE
where x and y a r e numbers i n r a d i x BASE.
LS PEAK)
SPEAK r e t u r n s t h e t o t a l number of CONSes which 'have been e x e c u t e d
i n t h i s LISP c o r e image.
GCTIME r e t u r n s t h e number of m i l l i s e c o i l d s LISP h a s s p e n t garbage
c o l l e c t i n g i n t h i s c o r e image.
-
TI# r e t u r n s t h e number of m i l l i s e c o n d s your :ob h a s computed
s i n c e you logged i n t o ' t h e system.
SAILON No. 28.2
It i s p o s s i b l e t o d e t e r m i n e t h e l e n g t h s of t h e f r e e and f u l l word
f r e e s t o r a g e l i s t s by:
(LENGTH (NUMVAL 158))
(LENGTH (NUMVAL 168))
= l e n g t h of f r e e s t o r a g e l i s t
= l e n g t h of f u l l word l i s t
SAILON No. 28.2
AP'PENDIX E
COMPILED FUNCTION LINKAGE AND ACCUMULATOR USAGE
This appendix i s i n t e n d e d t o e x p l a i n t h e s t r u c t s r e of compiled
f u n c t i o n s , f u n c t i o n c a l l s , and accumulator usage. This d i s c u s s i o n i s
r e l e v a n t o n l y i f one i n t e n d s t o i n t e r f a c e hand coded f u n c t i o n s o r
p o s s i b l y f u n c t i o n s g e n e r a t e d by a n o t h e r s y s t e m (such a s FORTRAN) w i t h
I n such a c a s e , i t i s h i g h l y recommended t h a t one'.
t h e LISP system.
examine t h e LAP code g e n e r a t e d by t h e LISP c o m p i l e r f o r some f a m i l i a r
functions.
ACCUMUUTOR USAGE TABLE
"sacred"
the i n t e r p r e t e r
p means " p r o t e c t e d " d u r i n g garbage c o l l e c t i o n
NII,
A
B
C
AR1
AR2A
T
TT
T~QI
S
D
R
P
=
=
=
=
=
=
=
=
QI
Header f o r t h e atoin NIL.
R e s u l t s from f u n c t i o n s , 1st a r g t o f u n c t i o n s
2nd a r g
3rd a r g
4th arg
5th arg
used f o r LSUBR l i n k a g e
1
2
3
4
5
6
7
r a r e l y used i n t h e i n t e r p r e t e r
r a r e l y used i n t h e i n t e r p r e t e r
= 1Qj
= 11
= 12
= 13
= 14
F
r-
FF
SP
=
15
= 16
17
S,P
S YP
S,P
SSP
r e g u l a r pushdown l i s t p o i n t e r
free storage l i s t pointer
f u l l word l i s t p o i n t e r
s p e c i a l pushdown l i s t p o i n t z r .
TEMPORARY STORAGE
Whenever a LISP f u n c t i o n i s c a l l e d - from a compiled f u n c t i o n , i t i s
assumed t h a t a l l a c c u m u l a t o r s from 2 through 13 a r e d e s t r o y e d by t h e
f u n c t i o n u n l e s s i t i s o t h e r w i s e known. Theref o r e , l o c a 1 v a r i a b l e s and
parameters i n a compiled f u n c t i o n s h o u l d be s a v e d i n some p r o t e c t e d c e l l s
such a s t h e r e g u l a r pushdown l i s t . The PUSH and POP i n s t r u c t i o n s a r e
c o n v e n i e n t f o r t h i s purpose.
SAILON No, 28.2
SPECIAL VARIABLE B I N D I N G S
S p e c i a l v a r i a b l e s i n compiled £unctions a r e bound t o s p e c i a l c e l l s
by:
PUSHJ P,S PECBIND
...
s t a r t of f u n c t i o n codc,
SPECBIND saves the previous values of v a r i on t h e s p e c i a l pushdown l i s t
and binds the contents of accumulator n; t o e a c h v a r i . The v a r i must
be p o i n t e r s t o s p e c i a l c e l l s of idengifzei-s. k;iy ni=@ causes the v a r i
t o be bound t o NIL,
S p e c i a l v a r i a b l e s a r e r e s t o r e d t o t h e i r previous values by:
PUSH J P, S PECSTR
which s t o r e s t h e values previously saved e c t h e s p e c i a l pushdown l i s t i n
the a p p r o p r i a t e s p e c i a l c e l l s .
To convert the number i n A f r o = 5"s LISP r e p r e s e n t a t i o n t o machine
r e p r e s e n t a t i o n use:
PUSHJ P , N W A L
which r e t u r n s t h e value of the nuxtbe~i n A , and i t s type ( e i t h e r FIXNUM'
or FLONUM) i n B.
To convert t h e number i n A from i t s ntachine r e p r e s e n t a t i o n t o LISP
r e p r e s e n t a t i o n use e i t h e r :
or
PUSHJ P,FIXlA
PUSHJ P,MAKNUk1
f o r FIXNW'S
w i t h type i n 3 .
Both of the above functions r e t u r n t h e LISP number i n A.
FUNCTION CALLING UUOS
To allow ease i n l i n k i n g , debugging, and modifLcating of compiled
f u n c t i o n s , a l l compiled functions c a l l o t h e r functions with s p e c i a l
opcodes c a l l e d UUOs. Several c a t e g o r i e s of f u n c t i o n c a l l s a r e d i s tinguished:
1)
C a l l s of t h e form (RETURN (FOO X)) a r e c a l l ~ dt e r m i n a l c a l l s
and e s s e n t i a l l y "jump" t o FOO.
SAILON No. -28.2
2)
C a l l s of t h e form (F X) where F i s a computed f u n c t i o n name o r
f u n c t i o n a l argument i s c a l l e d a f u n c t i o n a l c a l l .
The f u n c t i o n c a l l i n g UUOs a r e :
non- termina l
non-functionai
functional
terrnina 1
JCALL n , f
JCALLF n , f
CALL n , f
CALW . ~ , f
where f i s e i t h e r t h e a d d r e s s of a compiled f u n c t i o n o r a p o i n t e r t o t h e
i d e n t i f i e r f o r t h e f u n c t i o n , and n s p e c i z i e s t h e type of f u n c t i o n being
c a l l e d a s follows:
s p e c i f i e s a SUBR c a l l w i t h n arguments
s p e c i f i e s zn LSUBR c a l l
s p e c i f i e s an FSUBR c a l l .
n = @ t o 5
n = 16
n = 17
The f u ~ z t l o nc a l l i n g UUOs a r e d e f i n e d
i?; :,',CRO
by:
OPDEF CALL [34~81
OPDEF JCALL F 3 5 ~ 8
OlDEF CALLF i 3 6 ~ ? ]
OPDEF JCALLF
:37~@.
X)
-(NOUUO
-I
.-_
_
NOUU0.sets a s p e c i a l f l a g i n t h e 'JUO c a l l i n g mechanisn: t o t h e v a l u e
of x. When a CALL or JCALL t o ano31er cornpiled f u ~ c t i o ni s executed, ifthe flag
N I L t h e n t h e CALL o r JCALL i s changed t o a PUSHJ o r TI-ST
respectively.
I f t h e f l a g # N I L t h e n no change i s made. CALLF and
JCALLF a r e never changed.
-
NOTE:
For debugging compiled f u n c t i o n s , (NOUUO T) i s recorrznended.
For running debugged compiled f u n c t i o n s , (NOUUO NIL) i s more
efficient.
SUBRs a r e compiled EXPRs which a r e t h e most corimon type of f u n c t i o n .
Consequentiy, c o n s i d e r a b l e e f f o r t has been rriade t o rwke linkage t o SUBRs
efficient.
Arguments t o SUBRs a r e s u p p l i e d i n accumulators 1 through n , t h e
f i r s t argument i n 1. There i s a maximum of 5 arguments t o SUBRs.
-
To c a l l a SUBR from compiled code, u s e c a l l n,FUNC, where n i s t h e
number of arguments, and c a l l i s t h e a p p r o p r i a t e UUO.
-
The r e s u l t from a SUBR i s r e t u r n e d i n A ( = 1).
SAILON No. 28.2
FSUBR LINKAGE
FSUBRs r e c e i v e one argument i n A and r e t u r n t h e i r r e s u l t i n A.
FSUBRs which use t h e A-LIST f e a t u r e c a l l :
PUSHJ P,~:AMAI(E
which generates i n B a number encoding t h e s t a t e of t h e s p e c i ~ lpushdown
p o i c t e r . T o call an FSUBR, use . c a l l 1 7 , . . F U N C , hege c a l l i s . the. ':
a p p r o p i a t e UUO.
LSUBR LINKAGE
LSUBRs a r e s i m i l a r t o SUBRs except that they allow an a r b i t r a r y
number of arguments t o be passed. To c d 1 an LSUBR, t h e following
sequence i s used:
PUSH P, [ r e g
PUSH P , a r g l
...
PUSH P,argn
M O W 1 T,n
c a l i 16,func
ret:
;return address
; 1 s t argument
;nth and l a s r *.zgurnent
;mizus number of arguments
;t k e a p p r o p r i a t e 3 U O
; r h e LSUER r e t u r n s n s r e
When an LSUBL I s e n t e r e d , i t exec;,es:
JSP 3,;kLCALL
which initializes t h e LSUBR.
be referenced by:
A
- w i ; ~c o n t a i n a.
MOVE A,-i-1(F)
E x i t from an LSUBR with
POPJ P,
which r e t u r n s t o fcLCALL t o r e s t o r e t h e s t a c k .
The i t h argument can
-
SAILON 28.2
APPENDIX F
,THE LISP COMPILER
The LISP c o m p i l e r i s a LISP program which t r a n s f o r m s L I S P f u n c t i o n s
d e f i n e d by S - e x p r e s s i o n s i n t o U P code. T h i s code can b e loaded into
b i n a r y program space by LAP which produces a c t x l machine code.
Compiled f u n c t i o n s a r e apprcxlx-ately cec t i m e s e s fast a s I n t e r p r e Compiled f u n c t i o n s a l s o t s k e l e s s memory s p a c e , and r e l i e v e
t h e garbage c o l l e c t o r from marking f u n c t i o n d e f l c l t i o r ~ s . I n a v e r y
l a r g e s y s t e n of f u n c t i o n s , t h i s l a s t p0in-L i s p a r t i c u l a r l y sigLiflcant.
To u s e t h e LISP c o m p i l e r , t h e f02i0wing procedure I s recommended:
t e d functions.
1.
Ir; -
--:L
your f u n c t i o ~ sis an I/O f i l e (disk, d e c t a p e , e t c . )
in LJEFPROP format such as p~oduceclby GRINDEF. (See DSKOUT and
GXINL i n SMILE O p e r a t i n g Note Xo. 41).
-
2.
a.
It i s a l s o permitted £G: t h i s file t o contain g l o b a l v a r i a b l e
d e f i n i t i o n s , FlACRSs, and SFECTIAL v a r i a b l e d e f i n i t i o n s .
b.
SPECIAL v a r i a b l e de2iL21tions muzt o c c ~ : b e f o r e t h e f u n c t i o n s
which bind t h e s e v a r i a b l e s ,
PROP FOO T SPECIAL) will
d e c l a r e t h e v a r i a b l e FOO t o be SPECIAL, V a r i a b l e s which
a r e used i n a f u n c r i o n z l c o n t e x t xust be d e c l a r e d SPECIAL
o r e l s e t h e compiler will m i s t r k e them f o r undefined EXPRs.
c,
FEXPR d e f i n i t i o n s s h o u l d o c c ~ r& ? o r e f u n c t i o n s which c a l l
them, I f t h i s cannot be a r r a n g e d , a FZ3PR f o ~ w a r dr e f e r e n c e
FOO "I'cE'EYPR)
c a n be d e c l a r e d t o t h e c o m p l i e r by (ZEFP;.
where FOO i s t h e name of t h s FES?R.
T h e c o m 2 i l e r assumes
t h a t u n d e f i n e d f ~ : ~ c t i o n sare E X P h u n l e s s o t h e r w i s e d ~ c l a r e d .
d.
MACROS must o c c u r b e f o r e t h e f u n c t i o n s which use them.
e.
Global v a r i a b l e d e f i n i t i o n s are r e q u i r e d Co be I n DEFPRGP
format.
START t h e LISP c o m p i l e r by t y p i n g t o t h e system:
.R
L
a.
COMPLR
D e c l a r e any FEXPR forward r e E z r e n c e s , Ei4CTCOs, o r SPECIAL
va;:iables which a r e n o t d e f i n e d in y a u r I / O iFLe.
b.
The g l o b a l v a r i a b l e s I F L and OFL d e s i g n a t e t o t h e c o m ~ l l e r
t h e names of t h e i n p u t and o u t p u t d e v i c e s f o r compilation.
These a r e both i n i t i a l i z e d t o DSK:.
c.
Compile your f u n c t i o n d e f i n i t i o n f i l e s w i t h :
(COMPL f n l
...fnn)
where each f n , d z s l g n a t e s a f l l e name on d e v i c e IFL.
Each fni i s e i t h e r zn atom d e s i g n a t i n g a f i l e name, o r
a d o t t e d p a i r d e s i g n a c i n g f i l e name and e x t e n s i o n .
COMPL
produces LAP o u t p u t on dc-.;Lce OFL on f i l e s with t h e same
r i l e names b u t w i t h
excznsions.
COMPL a l s o t r a n s f e r s
through u n a l t e r e d any GEF2XOPs w i t h p r o p e r t i e s o t h e r t h a n
EXPR, FEXPR, YACRO, and SPECIAL.
6.
COMPL w i l l type o u t :
;:i
UTLiDZFIsED) f o r undefined f u n c t i o n r e f e r e n c e s . . The compiler
assumes t h a t ;; Ls d n ~ ~ X Y I I . i i x is z c ~ u a l l yan FEXPR,
you must recompile and z a c i a r e x as a n FEXPR by (DEFPROP
x T ;';FEXPR).
(x UNDECLARED) f o r undeclarsd global v a r i a b l e r e f e r e n c e s .
You need n o t worry about t h f i message u n l e s s x i s
SPECIAL a d you f o r g o t t o d e c l a r e i t .
e.
When COMPL i s done, i t r e t u r n s :
(n PROGRAM BREAK)
where n i s t h e l e n g t h of t h e
3.
code produced.
Load LAP i n t o your c o r e Lczge, then load t h e compiled f u n c t i o n s .
For example : ( I N C (INPUT SYS : -LAP DSR: (3'00
LAP)))
52 s u r e t o a l l o c a t e s u f f i c i e n t b i n a r y program space f o r t h e
f u n c t i o n s . The proper s i z e i s t h e sum ~f t h e program breaks
p l u s t h e l e n g t h of LAP which i s zbout 4008 words.
.
APPENDIX G
THE LISP ASSEXBLER
-
LAP
LAP i s a p r i m i t i v e a s s e x j l e r designe; t o load t h e o u t p u t of t h e
compiler. ; < o m a l l y , i t i s n o t n e c e s s a r y t o use LAP f o r any o t h e r purpose.
The format of: a c o m p i k d f u n c t i o n i n LAP i s :
(L4P name t y p e )
<sequence of U P i n s t r u c t i o n s )
NIL
where nam2 i s t h e name o f t h e Zunctlon, 2nd ty2.- I s e i t h e r SUBR, LSUBR,
o r FSUZR.
A LA2 i n s t r u c t i o n i s e i t h e r :
1.
A Zabei which i s a non-NIL i d e n t i f i e r ,
2.
A l i s t o f t h e form
(OPCODE AC ADDR INDEX )
a.
The i n d e x f i e l d 5s o p t i o n a l .
b.
The opcode i s e L t h e r a P D P - ~ / ~ iOn s t r u c t i o n
which i s d e f i n e d t o LAP and o p t i ~ ~ a l lsy~ i f i x e dby @
which d e s i g n a t e s l n d i r e c t addressing, o r a number which
s p e c i f i e s a n a m e r i c a i opcode.
c.
The AC and INDEX f i e l d s s h o u l d contain a number from
t o 17, o r P which d e s i g n a c e s r e g i s t e r 14.
d.
The ADDR f i e l d may be a nunber,
of one o-the
following f o r n s :
L.
l ~ b e l ,o r a l i s t
(QUOTE S - e x p r e s s i o n )
t o r e f e r e n c e list s t r u c t u r e .
(SPECIAL x)
t o r e f e r e n c e &E v a l u e of i d e n t i f i e r x .
(E f )
t o rezerence t h e f u n c t i o n f ,
( C OPCODE AC ADDX
INDEX) t o r e f e r e n c z a l i t e r a l c o n s t a n t .
SAILON N o .
28.2
7.
F o r example, t h e function ABS c o u l d b e defined:
(LAP ABS SUBR)
(CALL 1 (E NUMVL4L))
(MOWS (ii I)
(JCALL 2 (E x4i(;u'31))
NIL
-
SAILON No. 28.2
APPENDIX H
A m o d i f i e d v e r s i o n o f t h e s t a n d a r d ~ ~ ~ - 6 YiACRO-FAIL-FORTMN
/ 1 0
l o a d e r i s a v a i l a b l e f o r u s e i n LISP.
One c a n c a l l t h e l o a d e r i n t o a
LISP c o r e image a t a n y t i m e b y e x e c u t i n g :
( LOAD)
When a k; i s t y p e d , y o u a r e i n t h e l o a d e r , and l o a d e r cornand strings a r e
e x p e c t e d . As s o o n a s an altrnode i s t y ~ e d , the l o a d e r f i n i s h c s a n d e x i t s
b a c k t o LISP.
Both t h e l o a d e r and the programs l o a d e d s r e p l a c e d i n e x p a n d e d c o r e .
TI-e l o a d e r removes i t s e l f a n d c o n t r a c t s c o r e when i t i s f i n i s h e d .
In
the f o l l o w i n g d i s c u s s i o n , a "RELOC" p l - o g r m w i l l r e f e r t o a n y program
The o u t p u t of FOXTRAN
which i s s u i t a b l e f o r l o a d i n g wiziz t h e l o a d e r .
or MACRO i s a RELOC program.
(EXCISE)
-- - .. .
.
/4
EXCISE u n e x p a n d s core t o i t s length a 2 i z r ALL% or the l a s t REE.
This removes I / O b u f f e r s , AZVINE, a z d a l l R E L E programs.
GETSYM s e a r c h e s the DDT symbol t a b l e fo:- aach o f the s y n b o l s Si and
p l a c e s t h e value o n t h e p r o p e r t y l i s t o f S i under p r o p e r t y P.
T h i s c a u s e s DDT t o be d e f i n e d as a SUBR l o c a t e d a t t h e value o f ths
symbol DnT.
Note:
-
I n o r d e r t o l o a d t h e syn;5ol t a b l e , ei-;her / S o r /S must be t y p e d
t o t h e l o a d e r . Synbois w h i c h a r e d e c l a x e d INTEXXAL a r e always i n
t h e symbol t a b l e w i t h o u t t h e / S oii /D. I n t h e case of m u l t i p l y
d e f i n e d s y m b o l s , i . e . , a symbol used In more xhzn one &EL=
prosram, a symbol d e c l a r e d INTERNAL t z k e s p r e c e d e n c e , t h e l a s t
syriLiol o c c u r r e n c e o t h e r w i s e .
(PUTSYM "Xlf: ' 1 X 2 1 1
---..-------.*---.-
..
I
X
I"
-1;-
PUTSYM i s u s ~ dt o p l a c e s y d ! c ' L n "2 DZT s)- 3 1 t a b l e . If Xi
i s a n a t w t h e n the s y m ~ o lX *p l z c c d in the syx;ai r a b l e w i t h its
SAILON No. 28.2
v a l u e p o i q t i n g t o t h e a t o m Xi. I f Xi i s a l i s r , t h e s y m b o l i n (CAR Xi)
i s p l a c e d i n t h e s y m b o l t a b l e w i t h i t s v a i u e (EVAL (CAE3 Xi)).
PUTSYM
l a u s e f u l f o r making LISP atoms, f u n c t i o n s , a n d v a r i a b l - s a v a i l a b l e t o
RELOC p r o g r a m s .
S y m b o l s m u s t b e d e f i n e d w i t h ?UTSYX b e f o r e t h e LOADER
is used.
Zxamples :
(PUTSYM BPORG (VBPGRG (GET (QUOTE SPORG) (QUOTE VALUE) ) ) )
D e f i n e s t h e i d e n t i f i e r BPORG a n d i t s v a l u e c e l l VBTCZZ.
c a n reference t h e
- l u e o f BPORG by:
A RELE pograrn
MCVE X,VBi?GXG
( PUTSYM (IUPLST (QUOTE NAPLIST) ) ( X L W X P (QUG'X NUX3ER'P) ) )
( PUTSYM (MEMQ (GZT (QUOTE E 2 , j ) (c(UC2E S'L-3X) ) ) )
A RELOC p r o g r a m w o u l d c a l l t h e s e f u n c t i o n s a s f o l l o w s :
CALL 2,M,4PLST
CALL 1,NUi"lBRP
PUSXJ P,NEMQ o r
CALL 2,PXKQ
An e x a m p l e o f a s i m p l e L I S P c o m p a t i b l e YIICRO progi-arn t o c c i n p u t e s q u a r e
r o o t s u s i n g t h e FORTEN l i b r a r y .
TITLE TEST
2014
A=l
~ = 2
EXTERN PAI(NUM,NWALy SQRT,FLGNWi
LS QRT :
CALL 1, N'uTWAL
EOVEM A,AR1
?,3VE A, IXWD 0, BLT~: SAVE T9E AC ' S
BLT A , B L ~ l t 1 7
JSA 16,SQR'i'
JLJHP 2 , A R I ;SOP TO FORTMY
MGVE @ , A R ~
MOVE A, ~LWDBLTL
BLT A,17
MOW A,AR1
MOVE1 B,FLONUX
JCALL 2 , MAKNTSM
,@I
END
SAILON No. 28.2
APPENDIX I
A new L I S P e d i t o r , Alvine i s now avaLic.Sle, S i g n i f i c a n t
improvemsnts have been made i n the c o m a n ~s t r u e c u r e and s p ~ e dof
Alvine. The major addition t o ALvirze is a pointer which can be zoved
through t h e e d i t o r ' s s t r i n g ; the editing f e a t u r . a f f e c t only t h e area
t o the r i g h t - o f t h i s pointer.
mca can izsert azi: delete a r b i t r a r y
c h a r a c t e r s t r i n g s ; and f i l e and d e f i l e these s t r i n g s on vazious 1-0
devices.
The d a t a f o r Alvine are a r i b c z ~ r ysttri;;zs sf LISP a t o m s , numbers3
parens &nd d o t s . 3 e ~iviz,zz:.z.an<s L-.L.t
C . ~ ~ L & ; . C J G i r ic a i c t n c s e s z r i n g s
i n t o LISP S-ex?ressior,s w i t h 2 n i r ~ i w lanount of f u s s , . The c d i t o r i s
i n i t i a l l y e q u i p p e d t o h a n d l e t h e s p e c i a l indicators, FZXPR, EXPX and
VALUE.
This l i s t may be ar~lnendedby the p r o g r a x ~ l e r (see the Oescriptj.03
of " G " )
.
Each corrmnd t o ~ l v i n ecor,sfsxs of z s i n g k e - - , l r ~ c t e r fol-lotged by
a s t r i c , of arguments. These coritnzi-.?~ ~ ~ . o c ; t~h ye t a r s c r i n g presently
. occupying ~ i v i n e ' s b u f f e r .
it:z.~r,texc i s Introduce6 t o ~ 1 v L r . ea p o i n t e r
i s a t t a c h e d preceediog the first o b j e c t in t h d S u f f e r . Alvine's
Aivine ' s
c o m n d s allow the us2r ts
v
+".; o p o i n 2 e r :hr ough t h e b u f f e r
t e x t modifying corzdrL2s only z f f e c t t k s t r i z g t o :he r i g h t of this
pointer.
3
w3---n
.A\-
-A&
.A
.
-
.
The modif i c ~ i.~,::
t c s c m ~ n d sI c c l ~ d eiaserrlon 2nd dz l e t ion of r r t~e r i a 1:
" p o i r t e r string'' refers t o the s ~ r i n gt o tY;li3 ri.0;;~
O
of t h & p o i ~ l t e r .
Ba lanced?
.
Exa;niz?,es eke nrrrhel- OE pctreils Fn t-,h u f c e r string,
x.;; the c w n t of
l e f t ,n2 r i g h t p z r s n s 5-2 unbalanced;
O ~ ; I C Z ~ J ~ ExCe p l i , ,
"BA'L",
.*3h
'L.
I
,-
SAILON Lo. 28.2
p r i c t 2 2 i ~ : : ; :. a ~ segi;r'enL o f t h e
?c;ifi2+r bilEfez,
" n ~ "sets the
? e c g t h cf t h i s ? r i n t i n g s~gi-i-~eat
t o
'4
11
ob-jects.,
-
t h e first S - e x p r e s s L o n
p o i n t e r buffex
i n the
Expunge
E:cpucgc
File
GX?,TNl)EFS ~ L . G ma%e;~ialr e f e r r e d t o by "XI'
on ddevics "y" sing " z " z s a z i l e
narc;*
LL- 0 1x I $ is a lise thcn ea,-h
I t fl
2
x is f i l e d rrn6er "2"; j-f
1 ) 11
'
x 2s is :::oi~ then "x" is ~ s s a n e dto
'52 SZTQed
t o a l i s t o f nnares to
-
-be
Get
2ileLe
-,
--
6: w l i - rc.i^.r~vetLi! S-expression wich
nz.;r-z 'r..,
lE-2o Eti.,e Silvine ii~~;--,-,.
.t;i
. . . . ~i~~
li-Ai--La
.-LA,
:>,z
: ~ ~ i n t etor the 1.ef.c.P-
LA.;.
harid e.L7,daf
+'--:
L
'i-,%
i
If 'the
'--
iL--:;idizz t c r
"v~,
- -$2
-r
?I
ass oc i Lc-d tJich
. -'-. -- ' ivll-~e
*
szes :
- .I:
is
'IX"
->
&A
(SETQ
, 2 271 n-m
;>v
Ol
.x- (
<
.-,
---., *
))
-,-T J J S ~
0j-p.
LC.
~f_vLce
s
on the l i s t
.
I
a
: 11
wiiLLn
.,ZAP.
is r i ; ? i t i ~ l i z e dt o
; I,\;.snii~
. { Y ~ ----., ~ 3 ~
-p.c ~
V<
A ~ ~ '\
E ) x%"/,%L
m y be
1oo.lc-
)
.ilke 2-, , 2, l 'c a t o r s
f
A,.
O-U
77,7
exb,2;;-e<*
abo-de L
neededo
GS
G
~ ~ functions
b ~ d
and wiii e d l t
+-.c-,..-
-Li&e?&l
.Gy (-JpeyLy
?.
-.
ccxes in two F ~ ~ v c ) ; .:s
,nse-r;
1,
x ? ~ ? , c r i s e y ~u-;gl
s~mga~.az?!.y
-.
to
'
-
2.
: + i ~ - h 32
t
-
7-
.ilA,
?OS~~;.~X.
-0
a f TS-z
f T:-- 3 t
szz~::re~:ce (h Che p o i n t e ~s t r i s g )
~f ~ l s~t y e
i n g '');''.
l'X1' ;..zYb e a
calTipiecz s t--lno0 0% d e s c x i l > s d 5 y
elarps;s as i r tJ * a Z t i D L X xy f l
is 72 ,::s~ "y" i s i n e r o d . ~ c z ds o
~3~~e d i c ~ r ,s r h e c u ~ r e n ts t r i n g .
=',-'-'-,TS
J
I
*
I
-jp&e;'E
*s
lilJf1
L
y r -
--' . -':xL
Ls LO S U C
sior&
.,---,2 - - ; 1 a ~mved
.,. -a
L&.L
<-.-2.--- *
2JVaILIu,,5,
7,-.-,
-J
b z l l is
2
SSL:-*~-~*
L A .
:f
~S-expxes-.
and t h e
SAILON No, 28.2
Put
Returns t h e e d i t o r s t r i n g t o &
Lh~otighEVAL. Thus, f o r
example, D Z F X O P and SETQ are h a n d l e d
by t h e editor.
Replace
Replace t h e f i r s t occurrence of "x"
-by H ~ I I . As W i ~ h~
I
1 1 ~~ 1 1 mI y be
~
~
d e s c r r b e d e i i l ? t i c a l l y ; and if "yl' i s
%, t h e first occurrence of "xtl i s deleted.
Search
Search f a r the n L n occzzrence of t h e .
string wXw (in --=-c
L L i L
pointer s t r i n g ) ,
19 r"O U l l G , t h e p o i n t e r i s moved t o t h e
begin~ing 02 tke string f o l l o w i n g t h a t
--ir l e s s t h z n n occurrences
occzrrence.
a r e loca-ixd, the 2~interi s p o s i t i o n e d
a f t e r Zhc l a s t such occurrence.
I f none
- - - -- foilad t h e :min';er i s n o t moved.
If
Ii-/iI
i s n o t gllvm, 5 . e , I1nS$", t h e n t h e
l a s e g l v z n s c a ~ c 2 i - s t r i n g i s used.
L1
C
.
u
he fu.=,criolzs s p e c i f i e d by "xu
device f l y f l L=;iz,~
Hz"
f i l e r,ame,
'b
If l l x l ! i s an a c c a ~ ~ x si s nasscmed
c o be SZTQ t o a Irst of nanes t o be READ,
REACS
x-y:
fray:
Vomit
p - ~ i"
;
~;
z. ~25rs.: Ba lanced paren s e c t i o n
.-I+
LI.G
,-. - -~ g L t02 t h e p o i n t e r
i n pseudo
:
I
-a
.
e2TN3ZS far---+
LAG
b
7>--"
--
- -. ~5ne ~~,innTngof t h e p o i n t e r
A - L---3
L
f
,
,
-
0.
n) and n
<
,nzsz coszz-~:-;da 2-2 d u a l ; t h e y move
.,-kc s.Lying poi~zerl ~ o~b j ei c t~s t~ o t h e
r i g 5 2 6~ le-:.~respzc:ively,
I f !In1!
is s i ~ t::;a: e i t h e r t h e l e f t or r i g h t
end of t h c s t r i n g would be e x c e e d e d ,
.the p o i z z e z i s s e e t o t h a z extreme
":d~
- 7
1s C > J ? Z ~ *
To y e s e t t o t h e extrezz l e f t of
~ > ' e s +--;
c ~ L ll$c'
~ g n a y be u s e i ,
r-,
-1
'-
L-"
:
1i~r.S
Y Z ~ L-1-&Sc o n t x o l t o LISP.
buzfar is i" - e. c ,. ~~~ X C Z C ~and
,
rc:urr,lrtg to Alvine, r k e t s e r wll:
,-.2 n dt3Ae ?-~oi~-jzcx
~
a r the I z z t hzr,c! end
02 Chz o l d s t r i n g .
nt.
Aivine
t s
A
-
,11 a r ~ y5e r-ised dmin:;
G n y ccnxx-ind ?lo
r c t i i x c o z ~ r o lt o ALvine ' 2 corin~3nd-listenloop.
SAILON No. 28.2
AN EXAMPIE OF ALVZhJ
Note:
1.
A l l typeout is underlined.
2.
S e l l , spacc and alt-mode are r e p r e s e n t x d by
respectively.
c , and
~
$
-*
.R LIS? 1 2 ~
_LISP 73-&~g-6&
ALLGC?
rU .1
N,k
-T -d.
( E3)
-1,
I % $ ( D E F ~ O PTEST(~?/'IBD,;
e ; rhz striz, ZD:,:,C~;,G
>.y "$"
is i : = ; z o d c c ~ i
to k-LVIX5
.I-
A&1
(D",E!XOP
T'ST(xi;q;Z",B3_b, ; p r i r - t zi-.e e n z i z k ,,>'JI>Tz
"
jLsffe;-
-
a
'
.
Bu
2LPS
$3 R i a
-1 I & ~ E A
"
.I,
-..-.-.i;g
$ (X) (CAX Y ) E X R ~ )$; z;>pz~.L
5 ~ ~ 1 i dby~ ''$Is
b
tpAe "-." - - --
to
7
UUL&C;r.
-1.
Bu
4 LPS
3 R E
9;
1 CAR Y $ j $ ; add t h e d e f i c h x t r l g ~ 2t ~ 2 ~ 1 :
-/c
- ;colii)'i.~rzgcon:?znds 7:o;ild a l s o
; c;,e
,LLV2 ,La
s~:^ne c i f z c t :
c
7q
2
7
; 2,
VY
(DEFPROP ST (LAMBDA
-
(x)
-
Ll-
?lil<ffJ
q
"sY$",
x
(CAR Y))Ex=)
i'c
P TESTU; c o n v e r t ALVINE s t r i n g to LySp 2d-'c
. '"--
2'c
$)$'I,>
$)$,
; e x i t ALVIhJ
T~ ; now tallting to LISP
T
(TEST ( Q ~ ~ T E ( B
A)))
'
; r e e n t e r ALVIhZ,
(E D)
.L
W u
( D E F ~ O PST ; "G" need n o t be execc;sd
.si;.ca
--,LC -
-1.
the buf fez is always
LLLGCZ.
R X $ Y $
*
-1
; f l u s h i n c o r r e c r "put" c c ~ c r - ~b yd ty2i.22 'sell. (E)
P TSn
J-
? ~ S T W -; redefize TZSST
-1-
4
('LSNQUOIX (A 1 3 ) ) ) ~
't
Ir
; Cry
; tslc
E;~::-
(ED)
.I-
5>u
(U>
J-
-
; c!;.a.;-,ge
5c
.
print
cOu2"i
Ir
P1 L,
(Cha y ) )
-
>I<
C
U
-1.
c i < d
v(DEFWOP !EST(
-1.
R TEST
-'r'C
.
0 )
$%$
A 0
JDEF?;~OP)",P~)
; some e i ' f e c i by :
1. " S D ~ F P ~$",< O ~
'
f
;
~
"
SAILON No. 28.2
LISP nur~3ezsnave always b z 2 n szcond c l z s s c i C i . z c i . ~ , i n the s e n s e
length.
t h a t un2i;ic strii~gs ( p - r i n . ~n ~ r n e ~l')xr~bers have b a d a ~;iaxL.:i-~um
I n t h e P ; 3 ~ - 5 / 1 @L I S P syszem c'ilezz is ail o~";ionz> arbitrary p r e c i s t o n
i n t e g e r packsge which exceeds the l e n g t h o, LISP iztegers from 3 6 - b l t s
to any l ~ i . g t h .
To load :';c BIGEL% systt::.;
of LIS P:
e x z c ~ t zL;.L fo 2. ;O~~:L;-~;z t :he
--el
top leve 1
-.
ar,d then I.s-ar c G T e Linage wLlZ per2o:r-x a z b = _ t ~ - & rpyr e c i s i o ~ lLnteger
0 2 e r a ~ i o n sasing :he s r a n d a r d L I S P G ~ i t h r .. z cI E~T ~~C L L G A S winich were
r e d ? £ ined by A,jSXXIT,
C
It LA possible t o load :he 3TGSLX pacLizge z c zily t L i i i 2 uilic!zs you
h ~ v eali-ebLy executed compLled f-iii~cCionsw L ~ h(NG'ilGO XIL)> in which c a s e
ycu n u s t Yccdnstruct your core ixige.
S A I L O N No
.
28.2
SUBR
SUBR
A BS
;
.l.21
ALIST
AK3
APPEND
A2PLY
A X
AT U Y
m C - T
2uuZli
.S C I I
..5 S G Z
'5 TG3f
SU3Y
32.K GXG
SU3R
'U"i<
u
d
SUBR
5.'.SE
31G N W
BOOLE
BPEND
uses . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . .3.1
A
F -,- a O... .-L . ~ ns p a c e .
inic--,1 ........2d z O
C
. . . . . . . . . .
7DG-..i i
i
~ .>.t
r
i
b<rLtizyA, ~ ~o~-oU- L
.-,>--~~
*
a!?.R
CDR
c u 4
10-6
3.1
C-3
O:
. . . . . .
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . .
C- 3
lG-2
10-2
. . . . . . . . . . . . . . . . . . .
allows maze thzn one cons2. 4srLc
. . . . . . . . . . . . . . . . . . .
............. . . . . .
14-3
5-1
13-1.
. . . . . . . . . . . . . . . . . . .
. . . . . . . . . ... . . . . . . . . . .
3-5
I?
CDDDD'I
CERCT
ZOXD
COXS
CSYN
.. .
! -a2
- A
DDTIK
DDTGUT
DE
DEFPYOP
DEPOSIT
DF
DIFFEYENCE
DIVLDZ
DY
.
ZD
EQ
EQUAL
E
ERXSET
EVAL
second zrgL;r;c!r, ; ~ , L z / T . c L
.......
15-5
7-2
EXAMINE
EXA W4Y
EXCISE
EX1LODE
EXPLODEC
ZXP 7
FEXP R
FILENALHES
FIX
YLXEA
&'TXNTJi'l
FLATS l Z E
FLOX UN
FO RCE
FSUB 2
SZB?
FSUBR
FSUBR
SUB3
SUBR
SUBR
SUBR
SUBR
FSXARG
FLY CT1OX
FSU3R
FLTCT I ORAL A ?GUI"IEST S
CC
GCD
G CZAG
G CT I X E
GEESW*
GET
GETL
GET S191
GO
GRL44T1.:
IBASE
IDESTIYIE'I
INC
I:<iT FK
I:i?UT
ZNTEGER
...
1LqTE &I
LSiBEE
LQJ;
BDA
TUST
LENGTH
-2SSP
LZX?L>R
LISZZZXGTH
LIST
0~49
LSH
LSUBR
?A C RO
TJIk;<N AM
SGBR
S U I
SUB?
ST;^; c
SU2.i
~7 , j'3
SL'32
~ L . J-,~ . I
.
,
.
?
T
17SILT
T,
-,
L
V
~1
L>d3?
r
J.3 L ci c
4 -
TT-7
FSUZY
FSUZ'EI
FSUBX
SZBR
SiiJ ;',
SUZX
LSUBR
SVBZ
FSUEZ
SUB3
SUE3
SUB;<
. . . . . . . . . . .. . . . . . . . .
.......
r e t u r n s end ~f
a-
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
a
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
. . . . . . . . . . . . .
.............
SAILON N o .
28.2
FA 1 . m
'.N p
YAPC
PCARD
m-liPLIST
xzx 3E3
NEXq
PiIKUS
1II?<US2
;L COXC
N CONS
LYL
NOT
XOUU3
XSTOT
XULL
KLWBZ TI
5L?6 i3E ?j3
SLMVAL
CSLIST
SVB3
SU3R
SUE,;
b
SVBR
SUS;i
SUBR
SL(LX
SUBX
S'J'BA
LSUBR
S 3 R
V-\>gE
SLiBR
1i
11
11
4 -I
11
II
11
II
1f
<
s3-32
~
S
SG33
O?
,'TC
GUTPUT
PiYS
INrLYE
?XSl
PYINC
PUNT
..............
differen: argucent order .
.
.
.
SUB?
su3x
SUEZ
rbLBR
PXaG
3-7 1
PR9C-2
Py3PERTY LIST
PU;P?oP
PUTS 1%
SUBX
T
SU3X
FSU'SR
FSUY R
LSUBR
S33R
Eb!D
XEADCK
XEADLI ST
REX.AIK3ER
S262
SUBR
mPIO3
FS23?
=Ti;?$
YG,VE PS E
riPLACA
SUEZ
%?LACD
SA3SOC
SU3P
ST32
SUCX
SUSR
SU3R
SET
s:;;;
SXTO
S-EXPPSSSION
FS'U'i3TI
~
~
*
~
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
, , ,
SAILON No. 28.2
SUER
SPEAK
SPECBIXD
SYX
SPSCIAL
SPZCIAL VARIABLES
S3:; ZST R
SYX
STORE
FS'iiBX
SiJSI
SU3X
SUBR
SGBST
...
STB?
V1-LTI.UE
Sud:<
SUB3
LS'UiZR
Ti i
rl'2n3
L?;s
i 7-
r-3
TEES
TY -i
TY'3
VJALUZ
v; \, T'"-\,L:3LE
I
SUBX
SUBR
BISDINC-
-,; ;-\,r 4 77. A , dL\L
;':-A;12~yr~
'
DL "
P
"j7Vi\* L
:;'
L
>'f-yL-,C T I o s
;
I
c
, ' -,
L
7
9;
L,.LAT
-7
; -.;-3
SUE:<
SUS?
1; .< '.
I ,
S'L'B'i
CALL
;'cLE S S
?
;
'ZO-JNT
s-223
;':&as
>':Qu0
SSZX
S'J'S?
ycRSET
SUBX
TI^^^
SUi3X

Similar documents

sailon 28.1 - Software Preservation Group

sailon 28.1 - Software Preservation Group a s s u r e a proper end of f i l e . Now "1NC"O~-"IMPUT" t o t h e LAP-able f i l e w i l l begin i n p u t a t t h e c u r r e n t value of BPORG. I f one i s f i n i s h e d w i t h J t h e comp...

More information