forked from blakemcbride/LISPF4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
654 lines (481 loc) · 14 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
8/23/00 (revised 5/28/10)
Blake McBride
blake@mcbride.name
http://blake.mcbride.name
This is an Interlisp interpreter originally written in Fortran but
converted to C via the F2C Fortran to C converter. This release has
been tested under Windows, Linux, and Mac and no longer requires F2C
or its associated runtime library.
I had used a slightly older version of this system back in the early
80's and found it very portable, reliable, functional, and fast enough.
I learned Lisp with it and spent quite a bit of time with it back then.
The author (back in 1983) is Mats Nordstrom from Uppsala, Sweden. I
kept it around, ported it, enhanced some lisp code, and converted it
into C. Sometime in the late 90's Mats was kind enough to give me a
copy of the latest version he had (8/22/83). He also gave me
permission to release it so long as I retained his credits.
Interlisp is a dynamically scoped lisp system. It has no macro facility
but supports LAMBDA (evaluates function arguments), NLAMBDA (doesn't
evaluate its arguments), and variable number of arguments. Macros are
not hard to simulate.
The system contains no special optimizations such as P-code but has some
good debugging and editing facilities. It also contains all the basics
such as floating point numbers, arrays, and property lists.
In all the time I've used it I have never found a bug in the base
system (the part written in Fortran) and it has never crashed on me.
The conversion steps I performed are as follows:
1. Convert the system to C and got it running via the F2C program.
2. Replace the Fortran calls to equivalent C calls to get rid of the
need for the Fortran support library.
3. Enabled the use of command line arguments to control startup
options.
4. Changed memory usage to allow runtime capacity specifications.
5. Changed some code to make it a little more portable. (The system
should be highly portable in general though.)
Since I have modified the converted C code you should not attempt to
go from the Fortran code to C without loosing all of my changes.
The Fortran code as-is will not run with F2C without a few tweaks.
I have found that the system doesn't work when compiled for a 64 bit
machine. I therefore changed the compile options to force 32 bit
executables.
The following files are included:
README this file
lispf41.f Fortran source - part 1 of 2
lispf42.f Fortran source - part 2 of 2
f4com.for the Fortran common declarations
SYSATOMS system atoms needed when generating a new system
Makefile makefile for Windows NT using NMAKE
Makefile.unx makefile for linux or Mac
Manual.txt User manual and Implementation guide
*.l Lisp source files
script.? scripts to build the image files
f2c.h used by the .c files
lisf4.orig the entire original system
1974_InterlispRefMan.pdf the Interlisp manual
Pre-built executables are located under the Windows, Linux & Mac
directories.
You can find an Interlisp reference manual at:
http://www.bitsavers.org/pdf/xerox/interlisp/1974_InterlispRefMan.pdf
F2C (the Fortran to C converter) can be obtained at:
http://netlib.bell-labs.com/netlib/master/index.html
ftp://ftp.netlib.org/f2c
ftp://netlib.bell-labs.com/netlib/f2c
Building the system
-------------------
Make lispf4.exe and the two image files by typing:
Window/MSVC: nmake
Linux or Mac: make -f Makefile.unx
Running the system
------------------
In addition to loading lisp source files, lispf4 has the ability to
save/load binary images of a running system. This enables you to load
an entire pre-loaded image in a short time. Initially, if no image
file is being loaded, the system requires the SYSATOMS file in order
to builds its internal system. If an image file is being loaded the
SYSATOMS file is not needed or used. Typically, one builds an image
which contains the common lisp functions and uses that as the base
system.
The makefile builds two image files. BARE.IMG contains only SYSATOMS.
BASIC.IMG contains SYSATOMS and most of the common lisp files. These
common lisp files flesh out the system and would normally be used.
The command line options are as follows:
lispf4 [-cN] [-aN] [-sN] [-pN] [FILE.IMG]
N = a number (no space between the option and N)
c = car/cdr cells (default 100000)
a = atoms (default 3000)
s = stack space (default 1500)
p = print names / strings / reals / arrays (default 5000)
FILE.IMG = an image file name
For example Lispf4 can be started in the following ways:
lispf4
This causes a bare system to startup and SYSATOMS will be loaded.
lispf4 BASIC.IMG
This causes lispf4 to startup and load FILE.IMG. SYSATOMS is not used.
lispf4 -c200000 BASIC.IMG
This causes lispf4 to set the number of cons cells to 200000 and load
BASIC.IMG.
I'm not sure if you can mix different startup parameters with
different image files. In other words, I don't think you can run the
system with one configuration, save an image, and then load it with a
lispf4 which was started with a different set of parameters. Someone
should look into this.
----------------------------------------------------------------------
The raw system is case sensitive and all the built in functions are in
upper case. BASIC.IMG has a lisp file loaded which sets an option to
cause lispf4 to up shift all input so the system becomes case
insensitive.
To exit the system just type: (EXIT)
Once the system is built you can save and load images as follows:
(Note that this will only work if the proper lisp packages which
perform these operations are loaded. These files are loaded in
BASIC.IMG.)
(SYSOUT "file.img")
(SYSIN "file.img")
You can also use the makefile lisp package (in MAKEF.L) to load and
save groups of lisp functions in ASCII format as follows:
(CURFILE name) ; names the group - all functions defined from that point
are part of that named group
(MAKEFILE name file T) ; saves all the functions associated with name to file
(LOAD file) ; loads the file
----------------------------------------------------------------------
XCALL
-----
Opening files:
(XCALL 1 '(lfn file status form))
lfn = logical file number
file = file name
status = OLD or NEW
form = FORMATTED or UNFORMATTED
FORMATTED = ASCII files
UNFORMATTED = binary or sysout files
Closing files:
(XCALL 2 lfn)
----------------------------------------------------------------------
Supported Interlisp Functions
-----------------------------
primitive functions
-------------------
CAR
CDR
CAR & CDR 3 deep
CONS
RPLACD
RPLACA
QUOTE
COND
SELECTQ
PROG1
PROGN
PROG
GO
RETURN
SET
SETQ
SETQQ
GETTOPVAL
SETTOPVAL
Function Definition
-------------------
GETD
PUTD
PUTDQ
GETDQ
DEFINEQ
SAVEDEF
UNSAVEDEF
EVAL
BOUNDP
APPLY
EVALA
RPT
RPTQ
DE (DL)
DF (DN)
List Manipulation
-----------------
LIST
APPEND
NCONC
NCONC1
TCONC
LCONC
COPY
REVERSE
DREVERSE
SUBPAIR
SUBST
SUBLIS
LAST
NTH
LENGTH
DSORT
ALPHORDER
REMOVE
DREMOVE
Predicates and logical connectives
----------------------------------
ATOM
LITATOM
NUMBERP
STRINGP
LISTP
NLISTP
EQ
NEQ
NULL
EQUAL
AND
OR
MEMB
MEMBER
EVERY
SOME
ASSOC
SASSOC
PUTASSOC
Property Lists
--------------
GETPROPLIST
SETPROPLIST
GETPROP
PUTPROP
PUTPROPS
ADDPROP
REMPROP
REMPROPLIST
CHANGEPROP
PROPNAMES
SYSPROPS is a variable which contains a list of all the system
properties.
Math Functions
--------------
ADD1
SUB1
ZEROP
MINUSP
PLUS
MINUS
DIFFERENCE
TIMES
QUOTIENT
REMIANDER
GREATERP
LESSP
GEQ
LEQ
MIN
MAX
ABS
Print Names & Strings
---------------------
PACK
UNPACK
NCHARS
GENSYM
STRINGP
STREQUAL
MKSTRING
SUBSTRING
CONCAT
RPLSTRING
MKATOM
Map Functions
-------------
FUNCTION
MAP
MAPC
MAPLIST
MAPCAR
Terminal IO
-----------
READ
RATOM
RSTRING
READC
PRIN1
PRIN2
PRINT
SPACES
TERPRI
PRINTLEVEL
PP
PRINTPOS
File IO
-------
OPEN
MAKEFILE
READFILE
LOAD
CLOSE
CURFILE
PP
IOTAB
System
-------
ROLLIN
ROLLOUT
SYSIN
SYSOUT
GCGAG
RECLAIM
Debugging
---------
BREAK0
BREAK1
BREAK11
UNBREAK
REBREAK
TRACE
UNTRACE
VIRGINFN
ADVISE
UNADVISE
READVISE
----------------------------------------------------------------------
Conditional (IF) package (IFDO.L)
------------------------
Requires MATCH.L
This function is compatible with both the MIT version and the keyword
version at UCB.
simple summary:
non-keyword use:
(IF a b) ==> (COND (a b))
(IF a b c d e ...) ==> (COND (a b) (t c d e ...))
with keywords:
(IF a THEN b) ==> (COND (a b))
(IF a THENRET) ==> (COND (a))
(IF a THEN b c d e) ==> (COND (a b c d e))
(IF a THEN b c ELSE d) ==> (COND (a b c) (t d))
(IF a THEN b c ELSEIF d THENRET ELSE g)
==> (COND (a b c) (d) (t g))
In the syntax description below,
optional parts are surrounded by [ and ],
+ means one or more instances.
| means 'or'
<expr> is an lisp expression which isn't a keyword
The keywords are: THEN, THENRET, ELSE, ELSEIF.
<pred> is also a lisp expression which isn't a keyword.
<if-stmt> ::= <simple-if-stmt>
| <keyword-if-stmt>
<simple-if-stmt> ::= (IF <pred> <expr>)
| (IF <pred> <expr> <expr>)
<keyword-if-stmt> ::= (IF <pred> <then-clause> [ <else-clause> ] )
<then-clause> ::= THEN <expr>+
| THENRET
<else-clause> ::= ELSE <expr>+
| ELSEIF <pred> <then-clause> [ <else-clause> ]
----------------------------------------------------------------------
DO WHILE/UNTIL Package (IFDO.L)
----------------------
Requires MATCH.L
(DO WHILE expr <OPTION EXPR> DO <BODY>)
UNTIL
RETURN or RET
LAST = return the result of the last iteration of BODY
LIST = return a list of all results from each iteration of BODY
expr = return the result of expr after the last itteration, default NIL
RETURNV or RETV
litatom = variable name used to store result of BODY (only needed if
RET is LAST or LIST) default=(GENSYM)
LVARS = List of local variables and optionall initial values. RETV is
automatically added to this list. LVARS is in PROG variable list
format.
AFTER expr
expr = an expression which is executed after each iteration of BODY
DO exp1 exp2 exp3 ...
The expressions to be evaluated at each iteration (the DO is optional)
BODY =
expr = any expression
label = any label (atom) other than LOOP, AFTER, END, or NIL
(GO label) = branch to label
(RETURN expr) = leave DO and return expr
(GO LOOP) = restart the presetn iteration
(GO AFTER) = end the present iteration
(GO END) = end the DO
----------------------------------------------------------------------
DO FOR Package (IFDO.L)
--------------
Requires MATCH.L
(DO FOR <OPTIONAL EXPRS> DO <BODY>)
BEGINNING or BEG
expr = indicates the beginning value of the DO variable, default=1
ENDING or END
expr = indicating the ending value of the DO variable, default=1
INCREMENT or INC
expr = indicates the value added to the DO variable after each
iteration, default=1. If DIR is DOWN value is subtracted.
COUNTV or VAR
litatom = the DO variable name, default=(GENSYM). This value is added
to LVARS.
DIRECTION or DIR
UP = DO variable is incremented (default)
DOWN = Do variable is decremented
All DO WHILE options are also valid.
----------------------------------------------------------------------
Other DO forms
--------------
(DO expr1 expr2 expr3 ...)
same as (PROGN expr1 expr2 expr3 ...)
(DOWHILE test-expr return-type-or-expr return-var local-vars after-expr
BODY)
return-type-or-expr = LAST, LIST, or an expression
return-var = variable to use for LAST or LIST
after-expr = executed after each expression
----------------------------------------------------------------------
MATCH package (MATCH.L)
-------------
(MATCH e1 e2)
returns T if match and NIL otherwise
e2 = the expression to matched
e1 = an expression consisting of the following:
atom
expr
*
**
(? (from <to or T> <diminish match list> variable ALL/BUT) L1)
(?? (from to <diminish match list> variable ALL/BUT/(NOT) AND/OR)
L2)
L1 = match list, atom-var, or atom-list
L2 = atom-var or predicate-list
(LMATCH M L F)
M = match list
L = a list of the items to be matched
F = flag
NIL = stop trying match and return T after first match
T = continue match to the end of the list
(Don't ask me what all this means. I wrote it many years ago and have
virtually no idea what my notes mean. B.M.)
----------------------------------------------------------------------
Structures package (STRUCT.L)
------------------
Requires MATCH.L
This package enables one to create nested, named data structures.
(SPUT A K V F)
A = the litatom which will represent the data structure
K = the key.
NIL = A will be set to V. Any other structure of A will be
overwritten
atom = the same as (atom)
list = each element of the list will specify the key of sucessive
levels of the data structure A
V = the value. Any lisp object which will be placed at position K
F = flag
NIL = value V overwrites any previous value for key K
T = value V is CONS'ed to any previous value at K
The value returned is the entire structure A
(SMEMBER A K V)
A = the litatom which will represent the data structure
K = the key.
NIL = Top level.
atom = the same as (atom)
list = each element of the list will specify the key of sucessive
levels of the data structure A
V = matching value
NIL = return T if key K exists, NIL otherwise
other = return T if V matches or is an element of the value at K
(SNEXT A)
Returns the first key/value list and drops it from A
(SCHANGE A K S)
A = the structure
K = key
S = the new name of the final level indicated by K
Returns NIL if the change is unsuccessful.
(SGETNAMES A K)
A = the structure
K = key
NIL = all keys
atom = same as (atom)
list = return names at level specified by K
(SREMOVE A K V)
A = the structure
K = same as above K
V = value
NIL = remove entire level indicated by K
atom or list = remove the atom or list from the value at level K
(SGET A K)
same arguments
(SCLAMP A K A2 K2 V F F2)
Sets A at K and A2 at K2 to V and adds them depending on F and F2
(SATTACH A K A2 K2 F)
Sets A at K to point to the value of A2 at K2.
The value is added if F is T.