aboutsummaryrefslogtreecommitdiff
path: root/src/interp/bookvol5.pamphlet
blob: 5a7bd281db1f9f871abd816b3e40d30b2419bf73 (plain)
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
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
\documentclass{book}
\usepackage{axiom}
\usepackage{graphicx}
% struggle with latex figure-floating behavior
\renewcommand\floatpagefraction{.9}
\renewcommand\topfraction{.9}
\renewcommand\bottomfraction{.9}
\renewcommand\textfraction{.1}
\setcounter{totalnumber}{50}
\setcounter{topnumber}{50}
\setcounter{bottomnumber}{50}

\begin{document}
\begin{titlepage}
\center{\includegraphics{ps/axiomFront.ps}}
\vskip 0.1in
\includegraphics{ps/bluebayou.ps}\\
\vskip 0.1in
{\Huge{The 30 Year Horizon}}
\vskip 0.1in
$$
\begin{array}{lll}
Manuel\ Bronstein      & William\ Burge   & Timothy\ Daly \\
James\ Davenport       & Michael\ Dewar   & Martin\ Dunstan \\
Albrecht\ Fortenbacher & Patrizia\ Gianni & Johannes\ Grabmeier \\
Jocelyn\ Guidry        & Richard\ Jenks   & Larry\ Lambe \\
Michael\ Monagan       & Scott\ Morrison  & William\ Sit \\
Jonathan\ Steinbach    & Robert\ Sutor    & Barry\ Trager \\
Stephen\ Watt          & Jim\ Wen         & Clifton\ Williamson
\end{array}
$$
\center{\large{VOLUME 5: THE AXIOM INTERPRETER}}
\end{titlepage}
\pagenumbering{roman}
\begin{verbatim}
The Blue Bayou image Copyright (c) 2004 Jocelyn Guidry

Portions Copyright (c) 2004 Martin Dunstan

Portions Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
All rights reserved.

This book and the Axiom software is licensed as follows:

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

    - Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    - Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in
      the documentation and/or other materials provided with the
      distribution.

    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

\end{verbatim}
\tableofcontents
\vfill
\eject
\setlength{\parindent}{0em}
\setlength{\parskip}{1ex}
{\Large{\bf New Foreword}}
\vskip .25in

On October 1, 2001 Axiom was withdrawn from the market and ended
life as a commercial product.
On September 3, 2002 Axiom was released under the Modified BSD
license, including this document.
On August 27, 2003 Axiom was released as free and open source
software available for download from the Free Software Foundation's
website, Savannah.

Work on Axiom has had the generous support of the Center for 
Algorithms and Interactive Scientific Computation (CAISS) at
City College of New York. Special thanks go to Dr. Gilbert 
Baumslag for his support of the long term goal.

The online version of this documentation is roughly 1000 pages.
In order to make printed versions we've broken it up into three
volumes. The first volume is tutorial in nature. The second volume
is for programmers. The third volume is reference material. We've
also added a fourth volume for developers. All of these changes
represent an experiment in print-on-demand delivery of documentation.
Time will tell whether the experiment succeeded.

Axiom has been in existence for over thirty years. It is estimated to
contain about three hundred man-years of research and has, as of
September 3, 2003, 143 people listed in the credits. All of these
people have contributed directly or indirectly to making Axiom
available.  Axiom is being passed to the next generation. I'm looking
forward to future milestones.

With that in mind I've introduced the theme of the ``30 year horizon''.
We must invent the tools that support the Computational Mathematician
working 30 years from now. How will research be done when every bit of
mathematical knowledge is online and instantly available? What happens
when we scale Axiom by a factor of 100, giving us 1.1 million domains?
How can we integrate theory with code? How will we integrate theorems
and proofs of the mathematics with space-time complexity proofs and
running code? What visualization tools are needed? How do we support
the conceptual structures and semantics of mathematics in effective
ways? How do we support results from the sciences? How do we teach
the next generation to be effective Computational Mathematicians?

The ``30 year horizon'' is much nearer than it appears.

\vskip .25in
%\noindent
Tim Daly\\
CAISS, City College of New York\\
November 10, 2003 ((iHy))
\vfill
\eject
\pagenumbering{arabic}
\setcounter{chapter}{0} % Chapter 1
\chapter{The Interpreter}
\section{Star Global Variables}
\begin{tabular}{lll}
NAME                        & SET              & USE \\
*eof*                       & ncTopLevel       & \\
*features*                  &                  & restart \\
*package*                   &                  & restart \\
*standard-input*            &                  & ncIntLoop \\
*standard-output*           &                  & ncIntLoop \\
*top-level-hook*            & set-restart-hook & \\
\end{tabular}

\subsection{*eof*}
The [[*eof*]] variable is set to [[NIL]] in [[ncTopLevel]].
\subsection{*features*}
The [[*features*]] variable from common lisp is tested for the presence
of the [[:unix]] keyword. Apparently this controls the use of Saturn,
a previous Axiom frontend. The Saturn frontend was never released as
open source and so this test and the associated variables are probably
not used.

\subsection{*package*}
The [[*package*]] variable, from common lisp, is set in [[restart]]
to the [[BOOT]] package where the intepreter lives.
\subsection{*standard-input*}
The [[*standard-input*]] common lisp variable is used to set the 
[[curinstream]] variable in [[ncIntLoop]]. 

This variable is an argument to [[serverReadLine]] in
the [[intloopReadConsole]] function.

\subsection{*standard-output*}
The [[*standard-output*]] common lisp variable is used to set the 
[[curoutstream]] variable in [[ncIntLoop]].

\subsection{*top-level-hook*}
The [[*top-level-hook*]] common lisp variable contains the name of
a function to invoke when an image is started. In our case it is
called [[restart]]. This is the entry point to the Axiom interpreter.

\section{Dollar Global Variables}
\begin{tabular}{lll}
NAME                         & SET                 & USE \\
\$boot                       & ncTopLevel          & \\
coerceFailure                &                     & runspad \\
curinstream                  & ncIntLoop           & \\
curoutstream                 & ncIntLoop           & \\
vmlisp::\$current-directory  & restart             & \\
                             & reroot              & \\
\$currentLine                & restart             & removeUndoLines \\
\$dalymode                   &                     & intloopReadConsole \\
\$defaultMsgDatabaseName     & reroot              & \\
\$directory-list             & reroot              & \\
\$displayStartMsgs           &                     & restart \\
\$e                          & ncTopLevel          & \\
\$erMsgToss                  & SpadInterpretStream & \\
\$fn                         & SpadInterpretStream & \\
\$frameRecord                & initvars            & \\
                             & clearFrame          & \\
                             & undoSteps           & undoSteps \\
                             & recordFrame         & recordFrame \\
\$HiFiAccess                 & initHist            & historySpad2Cmd \\
                             & historySpad2Cmd     & \\
                             &                     & setHistoryCore \\
\$HistList                   & initHist            & \\
\$HistListAct                & initHist            & \\
\$HistListLen                & initHistList        & \\
\$HistRecord                 & initHistList        & \\
\$historyDirectory           &                     & makeHistFileName \\
                             &                     & makeHistFileName \\
\$historyFileType            & initvars           & histInputFileName \\
\$inclAssertions             & SpadInterpretStream & \\
\$inLispVM                   & spad                & \\
\$InteractiveFrame           & restart             & ncTopLevel \\
                             & undo                & recordFrame \\
                             & undoSteps           & undoSteps \\
                             &                     & reportUndo \\
\$InteractiveMode            & ncTopLevel          & \\
\$internalHistoryTable       & initvars            & \\
\$interpreterFrameName       & initializeInterpreterFrameRing & \\
\$interpreterFrameRing       & initializeInterpreterFrameRing & \\
\$InitialModemapFrame        &                     & makeInitialModemapFrame \\
\$intRestart                 &                     & intloop \\
\$intTopLevel                & intloop             & \\
\$IOindex                    & restart             & historySpad2Cmd \\
                             & removeUndoLines     & undoCount \\
\$lastPos                    & SpadInterpretStream & \\
\$libQuiet                   & SpadInterpretStream & \\
\$library-directory-list     & reroot              & \\
\$msgDatabaseName            & reroot              * \\
\$ncMsgList                  & SpadInterpretStream & \\
\$newcompErrorCount          & SpadInterpretStream & \\
\$newcompMode                & SpadInterpretStream & \\
\$newspad                    & ncTopLevel          & \\
\$nopos                      &                     & SpadInterpretStream \\
\$okToExecuteMachineCode     & SpadInterpretStream & \\
\$oldHistoryFileName         & initvars            & oldHistFileName \\
\$openServerIfTrue           & restart             & restart \\
                             & spad-save           & \\
                             & initvars            & \\
\$options                    &                     & history \\
                             & historySpad2Cmd     & historySpad2Cmd \\
                             &                     & undo \\
\$previousBindings           & initvars            & \\
                             & clearFrame          & \\
                             & recordFrame         & recordFrame \\
\$printLoadMsgs              & restart             & \\
\$PrintCompilerMessageIfTrue & spad                & \\
\$promptMsg                  & SpadInterpretStream & \\
\$relative-directory-list    &                     & reroot \\
\$relative-library-directory-list &                & reroot \\
\$reportUndo                 & initvars            & diffAlist \\
\$shoeReadLineFunction       & SpadInterpretStream & \\
\$spad                       & ncTopLevel          & \\
\$spadroot                   & reroot              & initroot \\
                             &                     & make-absolute-filename \\
                             &                     & reroot \\
\$SpadServer                 & restart             & \\
\$SpadServerName             & initvars            & restart \\
\$systemCommandFunction      & SpadInterpretStream & \\
top\_level                   &                     & runspad \\
\$quitTag                    &                     & runspad \\
\$useInternalHistoryTable    & initvars            & initHist \\
                             & setHistoryCore      & setHistoryCore \\
\$undoFlag                   & initvars            & recordFrame \\
\end{tabular}

\subsection{\$boot}
The [[$boot]] variable is set to [[NIL]] in [[ncTopLevel]].

\subsection{coerceFailure}
The [[coerceFailure]] symbol is a catch tag used in [[runspad]]
to catch an exit from [[ncTopLevel]].

\subsection{curinstream}
The [[curinstream]] variable is set to the value of the 
[[*standard-input*]] common lisp
variable in [[ncIntLoop]]. While not using the
``dollar'' convention this variable is still ``global''.

\subsection{curinstream}
The [[curoutstream]] variable is set to the value of the 
[[*standard-output*]] common lisp variable in [[ncIntLoop]].
While not using the ``dollar'' convention this variable is still ``global''.

\subsection{vmlisp::\$current-directory}
When running in Lucid Common Lisp ([[:lucid]]) on an IBM/370 mainframe
([[:ibm/370]]) this variable is used in place of the 
[[*default-pathname-defaults*]] common lisp variable. 
Otherwise this variable is
set to the empty string in [[restart]]. 

Notice that the variable [[*default-pathname-defaults*]] is a Common
Lisp standard variable with implementation defined meaning.
Typically, its value is an object that represents the directory from
where the Lisp image has been started.

The [[reroot]] function sets this variable to the value of
[[$spadroot]] which itself has the value of the argument to the
[[reroot]] function. Since the argument to the [[reroot]] function is
an string which represents an absolute pathname pointing to AXIOM the
net result is that the [[$current-directory]] is set to point to the
shell [[AXIOM]] variable.

So during execute both [[$current-directory]] and [[$spadroot]] reflect
the value of the [[AXIOM]] shell variable.

\subsection{\$currentLine}
The [[$currentLine]] line is set to [[NIL]] in [[restart]].
It is used in [[removeUndoLines]] in the undo mechanism.

\subsection{\$dalymode}
The [[$dalymode]] variable is used in a case statement in 
[[intloopReadConsole]]. This variable can be set to any non-nil
value. When not nil the interpreter will send any line that begins
with an ``[[(]]'' to be sent to the underlying lisp. This is useful
for debugging Axiom. The normal value of this variable is [[NIL]].

This variable was created as an alternative to prefixing every lisp
command with [[)lisp]]. When doing a lot of debugging this is tedious
and error prone. This variable was created to shortcut that process.
Clearly it breaks some semantics of the language accepted by the
interpreter as parens are used for grouping expressions.

\subsection{\$defaultMsgDatabaseName}
The [[$defaultMsgDatabaseName]] is the absolute path to the 
[[s2-us.msgs]] file which contains all of the english language
messages output by the system.

\subsection{\$directory-list}
The [[$directory-list]] is a list of absolute directory names.
These names are made absolute by mapping the [[make-absolute-filename]]
over the variable [[$relative-directory-list]].

\subsection{\$displayStartMsgs}
The [[$displayStartMsgs]] variable is used in [[restart]] but is not
set so this is likely a bug.

\subsection{\$e}
The [[$e]] variable is set to the value of
[[$InteractiveFrame]] which is set in [[restart]] to the value of the
call to the [[makeInitialModemapFrame]] function. This function simply
returns a copy of the variable [[$InitialModemapFrame]].

Thus [[$e]] is a copy of the variable [[$InitialModemapFrame]].

This variable is used in the undo mechanism.

\subsection{\$erMsgToss}
The [[$erMsgToss]] variable is set to [[NIL]] in [[SpadInterpretStream]].

\subsection{\$fn}
The [[$fn]] variable is set in [[SpadInterpretStream]]. It is set to
the second argument which is a list. It appears that this list has the
same structure as an argument to the LispVM [[rdefiostream]] function.

\subsection{\$frameRecord}
[[$frameRecord = [delta1, delta2,... ] ]] where
[[delta(i)]] contains changes in the ``backwards'' direction.
Each [[delta(i)]] has the form [[((var . proplist)...)]] where
proplist denotes an ordinary proplist. For example, an entry
of the form [[((x (value) (mode (Integer)))...)]] indicates that
to undo 1 step, [[x]]'s value is cleared and its mode should be set
to [[(Integer)]].

A [[delta(i)]] of the form [[(systemCommand . delta)]] is a special
delta indicating changes due to system commands executed between
the last command and the current command. By recording these deltas
separately, it is possible to undo to either BEFORE or AFTER
the command. These special [[delta(i)]]s are given ONLY when a
a system command is given which alters the environment.

Note: [[recordFrame('system)]] is called before a command is executed, and
[[recordFrame('normal)]] is called after (see processInteractive1).
If no changes are found for former, no special entry is given.

This is part of the undo mechanism.

\subsection{\$HiFiAccess}
The [[$HiFiAccess]] is set by [[initHist]] to [[T]]. It is a flag
used by the history mechanism to record whether the history function
is currently on. It can be reset by using the axiom
command
\begin{verbatim}
  )history off
\end{verbatim}
It appears that the name means ``History File Access''.

The [[$HiFiAccess]] variable is used by [[historySpad2Cmd]] to check
whether history is turned on. [[T]] means it is, [[NIL]] means it is not.

\subsection{\$HistList}
Thie [[$HistList]] variable is set by [[initHistList]] to an initial
value of [[NIL]] elements. The last element of the list is smashed to
point to the first element to make the list circular.
This is a circular list of length [[$HistListLen]].

\subsection{\$HistListAct}
The [[$HistListAct]] variable is set by [[initHistList]] to [[0]].
This variable holds the actual number of elements in the history list.
This is the number of ``undoable'' steps.

\subsection{\$HistListLen}
The [[$HistListLen]] variable is set by [[initHistList]] to [[20]].
This is the length of a circular list maintained in the variable
[[$HistList]].

\subsection{\$HistRecord}
The [[$HistRecord]] variable is set by [[initHistList]] to [[NIL]].
[[$HistRecord]] collects the input line, all variable bindings
and the output of a step, before it is written to the file named by
the function [[histFileName]].

\subsection{\$historyFileType}
The [[$historyFileType]] is set at load time by a call to 
[[initvars]] to a value of ``[[axh]]''. It appears that this
is intended to be used as a filetype extension.
It is part of the history mechanism. It is used in [[makeHistFileName]]
as part of the history file name.

\subsection{\$inclAssertions}
The [[$inclAssertions]] is set 
in the function [[SpadInterpretStream]] to the list [[(aix |CommonLisp|)]]

\subsection{\$internalHistoryTable}
The [[$internalHistoryTable]] variable is set at load time by a call to
[[initvars]] to a value of [[NIL]].
It is part of the history mechanism.

\subsection{\$interpreterFrameName}
The [[$interpreterFrameName]] variable, set in 
[[initializeInterpreterFrameRing]] to the constant
[[initial]] to indicate that this is the initial (default) frame.

Frames are structures that capture all of the variables defined in a
session. There can be multiple frames and the user can freely switch
between them. Frames are kept in a ring data structure so you can 
move around the ring.

\subsection{\$interpreterFrameRing}
The [[$interpreterFrameRing]] is set to a pair whose car is set to
the result of [[emptyInterpreterFrame]]

\subsection{\$InitialModemapFrame}
This variable is copied and returned by the function 
[[makeInitialModemapFrame]]. There is no initial value so this
is probably a bug.

\subsection{\$inLispVM}
The [[$inLispVM]] is set to [[NIL]] in [[spad]]. LispVM is a
non-common lisp that runs on IBM/370 mainframes. This is probably dead
code.  It appears that this list has the same structure as an argument
to the LispVM [[rdefiostream]] function.

\subsection{\$InteractiveFrame}
The [[$InteractiveFrame]] is set in [[restart]] to the value of the
call to the [[makeInitialModemapFrame]] function. This function simply
returns a copy of the variable [[$InitialModemapFrame]]

\subsection{\$InteractiveMode}
The [[$InteractiveMode]] is set to [[T]] in [[ncTopLevel]].

\subsection{\$intRestart}
The [[$intRestart]] variable is used in [[intloop]] but has no value.
This is probably a bug. While the variable's value is unchanged the
system will continually reenter the [[SpadInterpretStream]] function.

\subsection{\$intTopLevel}
The [[$intTopLevel]] is a catch tag. Throwing to this tags which is
caught in the [[intloop]] will 
restart the [[SpadInterpretStream]] function.

\subsection{\$IOindex}
The [[$IOindex]] index variable is set to [[1]] in [[restart]].
This variable is used in the [[historySpad2Cmd]] function in the
history mechanism. It is set in the [[removeUndoLines]] function
in the undo mechanism.

This is used in the undo mechanism in function [[undoCount]]
to compute the number of undos. You can't undo more actions then
have already happened.

\subsection{\$lastPos}
The [[$lastPos]] variable is set in [[SpadInterpretStream]]
to the value of the [[$nopos]] variable.
Since [[$nopos]] appears to have no value
this is likely a bug.

\subsection{\$libQuiet}
The [[$libQuiet]] variable is set to the third argument of the
[[SpadInterpretStream]] function. This is passed from [[intloop]]
with the value of [[T]]. This variable appears to be intended to
control the printing of library loading messages which would need
to be suppressed if input was coming from a file.

\subsection{\$library-directory-list}
The [[$library-directory-list]] variable is set by [[reroot]] by
mapping the function [[make-absolute-filename]] across the 
[[$relative-library-directory-list]] variable which is not yet set so this
is probably a bug.

\subsection{\$msgDatabaseName}
The [[$msgDatabaseName]] is set to [[NIL]] in [[reroot]].

\subsection{\$ncMsgList}
The [[$ncMsgList]] is set to [[NIL]] in [[SpadInterpretStream]].

\subsection{\$newcompErrorCount}
The [[$newcompErrorCount]] is set to [[0]] in [[SpadInterpretStream]].

\subsection{\$newcompMode}
The [[$newcompMode]] is set to [[NIL]] in [[SpadInterpretStream]].

\subsection{\$newspad}
The [[$newspad]] is set to [[T]] in [[ncTopLevel]].

\subsection{\$nopos}
The [[$nopos]] variable is used in [[SpadInterpretStream]] but does
not appear to have a value and is likely a bug.

\subsection{\$oldHistoryFileName}
The [[$oldHistoryFileName]] is set at load time by a call to 
[[initvars]] to a value of ``[[last]]''. 
It is part of the history mechanism. It is used in the function
[[oldHistFileName]] and [[restoreHistory]].

\subsection{\$okToExecuteMachineCode}
The [[$okToExecuteMachineCode]] is set to [[T]] in [[SpadInterpretStream]].

\subsection{\$options}
The [[$options]] variable is tested by the [[history]] function.
If it is [[NIL]] then output the message 
\begin{verbatim}
  You have not used the correct syntax for the history command.
  Issue )help history for more information.
\end{verbatim}

The [[$options]] variable is tested in the [[historySpad2Cmd]] function.
It appears to record the options that were given to a spad command on
the input line. The function [[selectOptionLC]] appears to take a list
off options to scan.

This variable is not yet set and is probably a bug.

\subsection{\$previousBindings}
The [[$previousBindings]] is a copy of the 
[[CAAR $InteractiveFrame]]. This is used to
compute the [[delta(i)]]s stored in [[$frameRecord]].
This is part of the undo mechanism.

\subsection{\$printLoadMsgs}
The [[$printLoadMsgs]] variable is set to [[T]] in [[restart]].

\subsection{\$PrintCompilerMessageIfTrue}
The [[$PrintCompilerMessageIfTrue]] variable is set to [[NIL]] in [[spad]].

\subsection{\$openServerIfTrue}
The [[$openServerIfTrue]] is tested in [[restart]] before it has been
set (and is thus a bug). It appears to control whether the interpreter
will be used as an open server, probably for OpenMath use.

If an open server is not requested then this variable to [[NIL]]

\subsection{\$promptMsg}
The [[$promptMsg]] variable is set to the constant [[S2CTP023]]. This 
constant points to a message in [[src/doc/msgs/s2-us.msgs]]. This message
does nothing but print the argument value.

\subsection{\$relative-directory-list}
The [[$relative-directory-list]] is used in [[reroot]] to create 
[[$directory-list]] which is a list of absolute directory names.
It is not yet set and is probably a bug.

\subsection{\$relative-library-directory-list}
The [[$relative-library-directory-list]] is used in [[reroot]] to create
a list of absolute directory names from [[$library-directory-list]] (which is 
It is not yet set and is probably a bug).

\subsection{\$reportUndo}
The [[$reportUndo]] variable is used in [[diffAlist]]. It was not normally
bound but has been set to [[T]] in [[initvars]]. If the variable is set
to [[T]] then we call [[reportUndo]].

It is part of the undo mechanism.

\subsection{\$shoeReadLineFunction}
The [[$shoeReadLineFunction]] is set in [[SpadInterpretStream]]
to point to the 
[[serverReadLine]] 

\subsection{\$spadroot}
The [[$spadroot]] variable is the internal name for the [[AXIOM]]
shell variable. 

The [[$spadroot]] variable is set in [[reroot]] to the value of the
argument. The argument is expected to be a directory name. 

The [[$spadroot]] variable is tested in [[initroot]].

The [[$spadroot]] variable is used by the function 
[[make-absolute-filename]]. It concatenates this variable to the 
front of a relative pathname to make it absolute.
\subsection{\$spad}
The [[$spad]] variable is set to [[T]] in [[ncTopLevel]].

\subsection{\$SpadServer}
If an open server is not requested then this variable to [[T]].
It has no value before this time (and is thus a bug).

\subsection{\$SpadServerName}
The [[$SpadServerName]] is passed to the [[openServer]] function, if the
function exists. 

\subsection{\$systemCommandFunction}
The [[$systemCommandFunction]] is set in [[SpadInterpretStream]]
to point to the function
[[InterpExecuteSpadSystemCommand]].

\subsection{top\_level}
The [[top\_level]] symbol is a catch tag used in [[runspad]]
to catch an exit from [[ncTopLevel]].

\subsection{\$quitTag}
The [[$quitTag]] is used as a variable in a [[catch]] block. 
It appears that it can be thrown somewhere below [[ncTopLevel]].

\subsection{\$useInternalHistoryTable}
The [[$useInternalHistoryTable]] variable is set at load time by a call to
[[initvars]] to a value of [[NIL]]. It is part of the history mechanism.

\subsection{\$undoFlag}
The [[$undoFlag]] is used in [[recordFrame]] to decide whether to do
undo recording. It is initially set to [[T]] in [[initvars]].
This is part of the undo mechanism.

\chapter{Starting Axiom}
Axiom starts by invoking a function value of the lisp symbol
[[*top-level-hook*]]. The function invocation path to from this
point until the prompt is approximates (skipping initializations):
\begin{verbatim}
  lisp -> restart
       -> |spad|
       -> |runspad|
       -> |ncTopLevel|
       -> |ncIntLoop|
       -> |intloop|
       -> |SpadInterpretStream|
       -> |intloopReadConsole|
\end{verbatim}
The [[|intloopReadConsole|]] function does tail-recursive calls to
itself (don't break this) and never exits.
\section{Variables Used}
\section{Data Structures}
\section{Functions}
\subsection{defun set-restart-hook}
When a lisp image containing code is reloaded there is a hook to
allow a function to be called. In our case it is the [[restart]]
function which is the entry to the Axiom interpreter.
<<defun set-restart-hook>>=
(defun set-restart-hook ()
  #+KCL (setq system::*top-level-hook* 'restart)
  #+Lucid (setq boot::restart-hook 'restart)
  'restart
 )

@
\subsection{defun restart}
The restart function is the real root of the world. It sets up memory
if we are working in a GCL/akcl version of the system. It sets the
current package to be the ``BOOT'' package which is the standard
package in which the interpreter runs. It calls initroot \cite{1}
to set the \$spadroot variable (usually the \$AXIOM variable).

The [[compiler::*compile-verbose*]] flag has been set to nil globally.
We do not want to know about the microsteps of GCL's compile facility.

The [[compiler::*suppress-compiler-warnings*]] flag has been set to t.
We do not care that certain generated variables are not used.

The [[compiler::*suppress-compiler-notes*]] flag has been set to t.
We do not care that tail recursion occurs.
<<defun restart>>=
(defun restart ()
#+:akcl
  (init-memory-config :cons 500 :fixnum 200 :symbol 500 :package 8
    :array 400 :string 500 :cfun 100 :cpages 3000 :rpages 1000 :hole 2000)
#+:akcl (setq compiler::*compile-verbose* nil)
#+:akcl (setq compiler::*suppress-compiler-warnings* t)
#+:akcl (setq compiler::*suppress-compiler-notes* t)
#-:CCL
  (in-package "BOOT")
#+:CCL
  (setq *package* (find-package "BOOT"))
#+:CCL (setpchar "") ;; Turn off CCL read prompts
#+(OR :akcl :CCL) (initroot)
#+:akcl (system:gbc-time 0)
#+:akcl
  (when (and $openServerIfTrue (fboundp '|openServer|))
   (prog (os)
    (setq os (|openServer| $SpadServerName))
    (if (zerop os) 
     (progn 
      (setq $openServerIfTrue nil) 
      (setq |$SpadServer| t)))))
;; We do the following test at runtime to allow us to use the same images
;; with Saturn and Sman.  MCD 30-11-95
#+:CCL
  (when 
     (and (memq :unix *features*) $openServerIfTrue (fboundp '|openServer|))
   (prog (os)
    (setq os (|openServer| $SpadServerName))
    (if (zerop os) 
     (progn 
      (setq $openServerIfTrue nil) 
      (setq |$SpadServer| t)))))
  (setq |$IOindex| 1)
  (setq |$InteractiveFrame| (|makeInitialModemapFrame|))
  (setq |$printLoadMsgs| t)
#+(and :lucid :ibm/370)
  (setq vmlisp::$current-directory "")
#-(and :lucid :ibm/370)
  (setq vmlisp::$current-directory
     (make-directory *default-pathname-defaults*))
  (|loadExposureGroupData|)
  (|statisticsInitialization|)
  (|initHist|)
  (|initializeInterpreterFrameRing|)

  (when |$displayStartMsgs| 
   (|spadStartUpMsgs|))
  (setq |$currentLine| nil)
  (restart0)
  (|readSpadProfileIfThere|)
  (|spad|))

@

\subsection{defun SpadInterpretStream}
The [[SpadInterpretStream]] function takes three arguments
\begin{list}{}
\item [[str]] This is passed as an argument to [[intloopReadConsole]]
\item [[source]] This is the name of a source file but appears not
to be used. It is set to the list [[(tim daly ?)]].
\item [[interactive?]] If this is false then various messages are 
suppressed and input does not use piles. If this is true then the
library loading routines might output messages and piles are expected
on input (as from a file).
\end{list}


\section{Helper Functions}
\subsection{defun reclaim}
Call the garbage collector on various platforms.
<<defun reclaim>>=
#+abcl 
(defun reclaim () (ext::gc))
#+:allegro
(defun reclaim () (excl::gc t))
#+:CCL
(defun reclaim () (gc))
#+clisp
(defun reclaim () (#+lisp=cl ext::gc #-lisp=cl lisp::gc))
#+(or :cmulisp :cmu)
(defun reclaim () (ext:gc))
#+cormanlisp
(defun reclaim () (cl::gc))
#+(OR IBCL KCL GCL)
(defun reclaim () (si::gbc t))
#+lispworks 
(defun reclaim () (hcl::normal-gc))
#+Lucid
(defun reclaim () (lcl::gc))
#+sbcl
(defun reclaim () (sb-ext::gc))
@
\subsection{defun getenviron}
<<defun getenviron>>=
(defun getenviron (shellvar)
 #+allegro (sys::getenv (string var))
 #+clisp (ext:getenv (string var))
 #+(or cmu scl)
  (cdr 
   (assoc (string var) ext:*environment-list* :test #'equalp :key #'string))
 #+(or kcl akcl gcl) (si::getenv (string var))
 #+lispworks (lw:environment-variable (string var))
 #+lucid (lcl:environment-variable (string var))
 #+mcl (ccl::getenv var)
 #+sbcl (sb-ext:posix-getenv var)
 )
@
\subsection{defun init-memory-config}
Austin-Kyoto Common Lisp (AKCL), now known as Gnu Common Lisp (GCL)
requires some changes to the default memory setup to run Axiom efficently.
This function performs those setup commands. 
<<defun init-memory-config>>=
(defun init-memory-config (&key
			   (cons 500)
			   (fixnum 200)
			   (symbol 500)
			   (package 8)
			   (array 400)
			   (string 500)
			   (cfun 100)
			   (cpages 3000)
			   (rpages 1000)
			   (hole 2000) )
  ;; initialize AKCL memory allocation parameters
  #+:AKCL
  (progn
    (system:allocate 'cons cons)
    (system:allocate 'fixnum fixnum)
    (system:allocate 'symbol symbol)
    (system:allocate 'package package)
    (system:allocate 'array array)
    (system:allocate 'string string)
    (system:allocate 'cfun cfun)
    (system:allocate-contiguous-pages cpages)
    (system:allocate-relocatable-pages rpages)
    (system:set-hole-size hole))
  #-:AKCL
  nil)

@
\subsection{defun initroot}
Sets up the system to use the {\bf AXIOM} shell variable if we can
and default to the {\bf \$spadroot} variable (which was the value
of the {\bf AXIOM} shell variable at build time) if we can't.
<<defun initroot>>=
(defun initroot (&optional (newroot (BOOT::|getEnv| "AXIOM")))
  (reroot (or newroot $spadroot (error "setenv AXIOM or (setq $spadroot)"))))

@
\subsection{defun loadExposureGroupData}
<<defun loadExposureGroupData>>=
#+:AKCL
(defun |loadExposureGroupData| ()
 (cond
  ((load "./exposed" :verbose nil :if-does-not-exist nil)
    '|done|)
  ((load (concat (system:getenv "AXIOM") "/algebra/exposed")
     :verbose nil :if-does-not-exist nil)
   '|done|)
  (t '|failed|) ))

#+:CCL
(defun |loadExposureGroupData| ()
 (cond
  ((load "./exposed.lsp" :verbose NIL :if-does-not-exist NIL) '|done|)
  ((load (concat (BOOT::|getEnv| "AXIOM") "/../../src/algebra/exposed.lsp") 
    :verbose nil :if-does-not-exist nil) '|done|)
  (t nil) ))

@
\subsection{make-absolute-filename}
Prefix a filename with the {\bf AXIOM} shell variable.
<<defun make-absolute-filename>>=
(defun make-absolute-filename (name)
 (concatenate 'string $spadroot name))

@

\subsection{defun reroot}
The reroot function is used to reset the important variables used by
the system. In particular, these variables are sensitive to the
{\bf AXIOM} shell variable. That variable is renamed internally to
be {\bf \$spadroot}. The {\bf reroot} function will change the
system to use a new root directory and will have the same effect
as changing the {\bf AXIOM} shell variable and rerunning the system
from scratch. Note that we have changed from the
NAG distribution back to the original form. If you need the NAG
version you can push {\bf :tpd} on the {\bf *features*} variable
before compiling this file. A correct call looks like:
\begin{verbatim}
(in-package "BOOT")
(reroot "/spad/mnt/${SYS}")
\end{verbatim}
where the [[${SYS}]] variable is the same one set at build time.
<<defun reroot>>=
(defun reroot (dir)
  (setq $spadroot dir)
  (setq $directory-list
   (mapcar #'make-absolute-filename $relative-directory-list))
  (setq $library-directory-list
   (mapcar #'make-absolute-filename $relative-library-directory-list))
  (setq |$defaultMsgDatabaseName|
	(pathname (make-absolute-filename "/share/msgs/s2-us.msgs")))
  (setq |$msgDatabaseName| ())
  (setq $current-directory $spadroot))

@
\subsection{defun statisticsInitialization}
<<defun statisticsInitialization>>=
(defun |statisticsInitialization| () 
 "initialize the garbage collection timer"
 #+:akcl (system:gbc-time 0)
 nil)

@
\chapter{The History Mechanism}
\section{)history}
\index{ugSysCmdhistory}

\index{history}


\par\noindent{\bf User Level Required:} interpreter

\par\noindent{\bf Command Syntax:}
\begin{list}{}
\item{\tt )history )on}
\item{\tt )history )off}
\item{\tt )history )write} {\it historyInputFileName}
\item{\tt )history )show [{\it n}] [both]}
\item{\tt )history )save} {\it savedHistoryName}
\item{\tt )history )restore} [{\it savedHistoryName}]
\item{\tt )history )reset}
\item{\tt )history )change} {\it n}
\item{\tt )history )memory}
\item{\tt )history )file}
\item{\tt \%}
\item{\tt \%\%({\it n})}
\item{\tt )set history on | off}
\end{list}

\par\noindent{\bf Command Description:}

The {\it history} facility within Axiom allows you to restore your
environment to that of another session and recall previous
computational results.
Additional commands allow you to review previous
input lines and to create an {\bf .input} file of the lines typed to
\index{file!input}
Axiom.

Axiom saves your input and output if the history facility is
turned on (which is the default).
This information is saved if either of
\begin{verbatim}
)set history on
)history )on
\end{verbatim}
has been issued.
Issuing either
\begin{verbatim}
)set history off
)history )off
\end{verbatim}
will discontinue the recording of information.
\index{history )on}
\index{set history on}
\index{set history off}
\index{history )off}

Whether the facility is disabled or not,
the value of {\tt \%} in Axiom always
refers to the result of the last computation.
If you have not yet entered anything,
{\tt \%} evaluates to an object of type
{\tt Variable('\%)}.
The function {\tt \%\%} may be  used to refer
to other previous results if the history facility is enabled.
In that case,
{\tt \%\%(n)} is  the output from step {\tt n} if {\tt n > 0}.
If {\tt n < 0}, the step is computed relative to the current step.
Thus {\tt \%\%(-1)} is also the previous step,
{\tt \%\%(-2)}, is the  step before that, and so on.
If an invalid step number is given, Axiom will signal an error.

The {\it environment} information can either be saved in a file or entirely in
memory (the default).
Each frame 
(\ref{ugSysCmdframe} on page~\pageref{ugSysCmdframe})
has its own history database.
When it is kept in a file, some of it may also be kept in memory for
efficiency.
When the information is saved in a file, the name of the file is
of the form {\bf FRAME.axh} where ``{\bf FRAME}'' is the name of the
current frame.
The history file is placed in the current working directory
(see \ref{ugSysCmdcd} on page~\pageref{ugSysCmdcd}).
Note that these history database files are not text files (in fact,
they are directories themselves), and so are not in human-readable
format.

The options to the {\tt )history} command are as follows:

\begin{description}
\item[{\tt )change} {\it n}]
will set the number of steps that are saved in memory to {\it n}.
This option only has effect when the history data is maintained in a
file.
If you have issued {\tt )history )memory} (or not changed the default)
there is no need to use {\tt )history )change}.
\index{history )change}

\item[{\tt )on}]
will start the recording of information.
If the workspace is not empty, you will be asked to confirm this
request.
If you do so, the workspace will be cleared and history data will begin
being saved.
You can also turn the facility on by issuing {\tt )set history on}.

\item[{\tt )off}]
will stop the recording of information.
The {\tt )history )show} command will not work after issuing this
command.
Note that this command may be issued to save time, as there is some
performance penalty paid for saving the environment data.
You can also turn the facility off by issuing {\tt )set history off}.

\item[{\tt )file}]
indicates that history data should be saved in an external file on disk.

\item[{\tt )memory}]
indicates that all history data should be kept in memory rather than
saved in a file.
Note that if you are computing with very large objects it may not be
practical to kept this data in memory.

\item[{\tt )reset}]
will flush the internal list of the most recent workspace calculations
so that the data structures may be garbage collected by the underlying
Common Lisp system.
Like {\tt )history )change}, this option only has real effect when
history data is being saved in a file.

\item[{\tt )restore} [{\it savedHistoryName}]]
completely clears the environment and restores it to a saved session, if
possible.
The {\tt )save} option below allows you to save a session to a file
with a given name. If you had issued
{\tt )history )save jacobi}
the command
{\tt )history )restore jacobi}
would clear the current workspace and load the contents of the named
saved session. If no saved session name is specified, the system looks
for a file called {\bf last.axh}.

\item[{\tt )save} {\it savedHistoryName}]
is used to save  a snapshot of the environment in a file.
This file is placed in the current working directory
(see \ref{ugSysCmdcd} on page~\pageref{ugSysCmdcd}).
Use {\tt )history )restore} to restore the environment to the state
preserved in the file.
This option also creates an input file containing all the lines of input
since you created the workspace frame (for example, by starting your
Axiom session) or last did a {\tt )clear all} or
{\tt )clear completely}.

\item[{\tt )show} [{\it n}] [{\tt both}]]
can show previous input lines and output results.
{\tt )show} will display up to twenty of the last input lines
(fewer if you haven't typed in twenty lines).
{\tt )show} {\it n} will display up to {\it n} of the last input lines.
{\tt )show both} will display up to five of the last input lines and
output results.
{\tt )show} {\it n} {\tt both} will display up to {\it n} of the last
input lines and output results.

\item[{\tt )write} {\it historyInputFile}]
creates an {\bf .input} file with the input lines typed since the start
of the session/frame or the last {\tt )clear all} or {\tt )clear
completely}.
If {\it historyInputFileName} does not contain a period (``.'') in the filename,
{\bf .input} is appended to it.
For example,
{\tt )history )write chaos}
and
{\tt )history )write chaos.input}
both write the input lines to a file called {\bf chaos.input} in your
current working directory.
If you issued one or more {\tt )undo} commands,
{\tt )history )write}
eliminates all
input lines backtracked over as a result of {\tt )undo}.
You can edit this file and then use {\tt )read} to have Axiom process
the contents.
\end{description}

\par\noindent{\bf Also See:}
{\tt )frame} \index{ugSysCmdframe},
{\tt )read} \index{ugSysCmdread},
{\tt )set} \index{ugSysCmdset}, and
{\tt )undo} \index{ugSysCmdundo}.


History recording is done in two different ways:
\begin{itemize}
\item all changes in variable bindings (i.e. previous values) are
    written to [[$HistList]], which is a circular list
\item all new bindings (including the binding to [[%]]) are written to a
    file called [[histFileName()]]
    one older session is accessible via the file [[$oldHistFileName()]]
\end{itemize}

\section{Variables Used}
The following global variables are used:
\begin{list}{}
\item [[$HistList]], [[$HistListLen]] and [[$HistListAct]] which is the
       actual number of ``undoable'' steps)
\item [[$HistRecord]] collects the input line, all variable bindings
      and the output of a step, before it is written to the file
      [[histFileName()]].
\item [[$HiFiAccess]] is a flag, which is reset by [[)history )off]]
\end{list}
The result of step n can be accessed by [[%n]], which is translated
into a call of [[fetchOutput(n)]]. The 
[[updateHist]] is called after every interpreter step. The 
[[putHist]] function records all changes in the environment to [[$HistList]]
  and [[$HistRecord]]
 
\subsection{Initialized history variables}
\begin{verbatim}
\end{verbatim}
 
<<initvars>>=
(defvar |$historyDirectory| 'A        "vm/370 filename disk component")
(defvar |$HiFiAccess| t               "t means turn on history mechanism")
@

\section{Data Structures}
\section{Functions}

\subsection{defun setHistoryCore}
We [[case]] on the [[inCore]] argument value
\begin{list}{}
\item If history is already on and is kept in the same location as requested
(file or memory) then complain.
\item If history is not in use then start using the file or memory as 
requested. This is done by simply setting the [[$useInternalHistoryTable]] 
to the requested value, where [[T]] means use memory and [[NIL]] means
use a file. We tell the user.
\item If history should be in memory, that is [[inCore]] is not [[NIL]],
and the history file already contains information we read the information
from the file, store it in memory, and erase the history file. We modify
[[$useInternalHistoryTable]] to [[T]] to indicate that we're maintining
the history in memory and tell the user.
\item Otherwise history must be on and in memory. We erase any old history
file and then write the in-memory history to a new file
\end{list}


\section{History File Messages}
<<History File Messages>>=
S2IH0001
 You have not reached step %1b yet, and so its value cannot be
 supplied.
S2IH0002
 Cannot supply value for step %1b because 1 is the first step.
S2IH0003
 Step %1b has no value.
S2IH0004
 The history facility is not on, so you cannot use %b %% %d .
S2IH0006
 You have not used the correct syntax for the %b history %d command.
 Issue %b )help history %d for more information.
S2IH0007
 The history facility is already on.
S2IH0008
 The history facility is now on.
S2IH0009
 Turning on the history facility will clear the contents of the
 workspace.
 Please enter %b y %d or %b yes %d if you really want to do this:
S2IH0010
 The history facility is still off.
S2IH0011
 The history facility is already off.
S2IH0012
 The history facility is now off.
S2IH0013
 The history facility is not on, so the .input file containing your user input
 cannot be created.
S2IH0014
 Edit %b %1 %d to see the saved input lines.
S2IH0015
 The argument %b n %d for %b )history )change n must be a nonnegative
 integer and your argument, %1b , is not one.
S2IH0016
 The history facility is not on, so no information can be saved.
S2IH0018
 The saved history file is %1b .
S2IH0019
 There is no history file, so value of step %1b is
 undefined.
S2IH0022
 No history information had been saved yet.
S2IH0023
 %1b is not a valid filename for the history file.
S2IH0024
 History information cannot be restored from %1b because the file does
 not exist.
S2IH0025
 The workspace has been successfully restored from the history file
 %1b .
S2IH0026
 The history facility command %1b cannot be performed because the
 history facility is not on.
S2IH0027
 A value containing a %1b is being saved in a history file or a
 compiled input file INLIB. This type
 is not yet usable in other history operations.  You might want to issue
 %b )history )off %d
S2IH0029
 History information is already being maintained in an external file
 (and not in memory).
S2IH0030
 History information is already being maintained in memory (and not
 in an external file).
S2IH0031
 When the history facility is active, history information will be
 maintained in a file (and not in an internal table).
S2IH0032
 When the history facility is active, history information will be
 maintained in memory (and not in an external file).
S2IH0034
 Missing element in internal history table.
S2IH0035
 Can't save the value of step number %1b.  You can re-generate this value
 by running the input file %2b.
S2IH0036
 The value specified cannot be saved to a file.
S2IH0037
 You must specify a file name to the history save command
S2IH0038
 You must specify a file name to the history write command
@

\chapter{The Frame Mechanism}
\section{)frame}
%\label{ugSysCmdframe}
%\index{frame}
\par\noindent{\bf Command Syntax:}
\begin{list}{}
\item{\tt )frame  new  {\it frameName}}
\item{\tt )frame  drop  {\it [frameName]}}
\item{\tt )frame  next}
\item{\tt )frame  last}
\item{\tt )frame  names}
\item{\tt )frame  import {\it frameName} {\it [objectName1 [objectName2 ...]]}}
\item{\tt )set message frame on | off}
\item{\tt )set message prompt frame}
\end{list}

\par\noindent{\bf Command Description:}

A {\it frame} can be thought of as a logical session within the
physical session that you get when you start the system.  You can
have as many frames as you want, within the limits of your computer's
storage, paging space, and so on.
Each frame has its own {\it step number}, {\it environment} and {\it history.}
You can have a variable named {\tt a} in one frame and it will
have nothing to do with anything that might be called {\tt a} in
any other frame.

Some frames are created by the HyperDoc program and these can
have pretty strange names, since they are generated automatically.
\index{frame names}
To find out the names
of all frames, issue
\begin{verbatim}
)frame names
\end{verbatim}
It will indicate the name of the current frame.

You create a new frame
\index{frame new}
``{\bf quark}'' by issuing
\begin{verbatim}
)frame new quark
\end{verbatim}
The history facility can be turned on by issuing either
{\tt )set history on} or {\tt )history )on}.
If the history facility is on and you are saving history information
in a file rather than in the Axiom environment
then a history file with filename {\bf quark.axh} will
be created as you enter commands.
If you wish to go back to what
you were doing in the
\index{frame next}
``{\bf initial}'' frame, use
\index{frame last}
\begin{verbatim}
)frame next
\end{verbatim}
or
\begin{verbatim}
)frame last
\end{verbatim}
to cycle through the ring of available frames to get back to
``{\bf initial}''.

If you want to throw
away a frame (say ``{\bf quark}''), issue
\begin{verbatim}
)frame drop quark
\end{verbatim}
If you omit the name, the current frame is dropped.
\index{frame drop}

If you do use frames with the history facility on and writing to a file,
you may want to delete some of the older history files.
\index{file!history}
These are directories, so you may want to issue a command like
{\tt rm -r quark.axh} to the operating system.

You can bring things from another frame by using
\index{frame import}
{\tt )frame import}.
For example, to bring the {\tt f} and {\tt g} from the frame ``{\bf quark}''
to the current frame, issue
\begin{verbatim}
)frame import quark f g
\end{verbatim}
If you want everything from the frame ``{\bf quark}'', issue
\begin{verbatim}
)frame import quark
\end{verbatim}
You will be asked to verify that you really want everything.

There are two {\tt )set} flags
\index{set message frame}
to make it easier to tell where you are.
\begin{verbatim}
)set message frame on | off
\end{verbatim}
will print more messages about frames when it is set on.
By default, it is off.
\begin{verbatim}
)set message prompt frame
\end{verbatim}
will give a prompt
\index{set message prompt frame}
that looks like
\begin{verbatim}
initial (1) ->
\end{verbatim}
\index{prompt!with frame name}
when you start up. In this case, the frame name and step make up the
prompt.

\par\noindent{\bf Also See:}
{\tt )history} \index{ugSysCmdhistory} and
{\tt )set} \index{ugSysCmdset}.


@
\section{Variables Used}
\section{Data Structures}
\section{Functions}


\section{Frame File Messages}
<<Frame File Messages>>=
S2IZ0016
 The %1b system command takes arguments but no options.
S2IZ0017
 %1b is not a valid frame name
S2IZ0018
 You must provide a name for the new frame.
S2IZ0019
 You cannot use the name %1b for a new frame because an existing
 frame already has that name.
S2IZ0020
 There is only one frame active and therefore that cannot be closed.
 Furthermore, the frame name you gave is not the name of the current frame.
 The current frame is called %1b .
S2IZ0021
 The current frame is the only active one.  Issue %b )clear all %d to
 clear its contents.
S2IZ0022
 There is no frame called %1b and so your command cannot be
 processed.
S2IZ0024
 The names of the existing frames are: %1 %l
 The current frame is the first one listed.
S2IZ0073
 %b )frame import %d must be followed by the frame name. The names
 of objects in that frame can then optionally follow the frame name.
 For example,
 %ceon %b )frame import calculus %d %ceoff
 imports all objects in the %b calculus %d frame, and
 %ceon %b )frame import calculus epsilon delta %d %ceoff
 imports the objects named %b epsilon %d and %b delta %d from the
 frame %b calculus %d .
 Please note that if the current frame contained any information
 about objects with these names, then that information would be
 cleared before the import took place.
S2IZ0074
 You cannot import anything from the frame %1b because that is not
 the name of an existing frame.
S2IZ0075
 You cannot import from the current frame (nor is there a need!).
S2IZ0076
 User verification required:
 do you really want to import everything from the frame %1b ?
 If so, please enter %b y %d or %b yes %d :
S2IZ0077
 On your request, AXIOM will not import everything from frame %1b.
S2IZ0078
 Import from frame %1b is complete. Please issue %b )display all %d
 if you wish to see the contents of the current frame.
S2IZ0079
 AXIOM cannot import %1b from frame %2b because it cannot be found.
@
\chapter{The Undo Mechanism}
\section{)undo}
\index{ugSysCmdundo}

\index{undo}


\par\noindent{\bf User Level Required:} interpreter

\par\noindent{\bf Command Syntax:}
\begin{list}{}
\item{\tt )undo}
\item{\tt )undo} {\it integer}
\item{\tt )undo} {\it integer [option]}
\item{\tt )undo} {\tt )redo}
\end{list}
%
where {\it option} is one of
%
\begin{list}{}
\item{\tt )after}
\item{\tt )before}
\end{list}

\par\noindent{\bf Command Description:}

This command is used to
restore the state of the user environment to an earlier
point in the interactive session.
The argument of an {\tt )undo} is an integer which must designate some
step number in the interactive session.

\begin{verbatim}
)undo n
)undo n )after
\end{verbatim}
These commands return the state of the interactive
environment to that immediately after step {\tt n}.
If {\tt n} is a positive number, then {\tt n} refers to step nummber
{\tt n}. If {\tt n} is a negative number, it refers to the \tt n-th
previous command (that is, undoes the effects of the last $-n$
commands).

A {\tt )clear all} resets the {\tt )undo} facility.
Otherwise, an {\tt )undo} undoes the effect of {\tt )clear} with
options {\tt properties}, {\tt value}, and {\tt mode}, and
that of a previous {\tt undo}.
If any such system commands are given between steps $n$ and
$n + 1$ ($n > 0$), their effect is undone
for {\tt )undo m} for any $0 < m \leq n$..

The command {\tt )undo} is equivalent to {\tt )undo -1} (it undoes
the effect of the previous user expression).
The command {\tt )undo 0} undoes any of the above system commands
issued since the last user expression.

\begin{verbatim}
)undo n )before
\end{verbatim}
This command returns the state of the interactive
environment to that immediately before step {\tt n}.
Any {\tt )undo} or {\tt )clear} system commands
given before step {\tt n} will not be undone.

\begin{verbatim}
)undo )redo
\end{verbatim}
This command reads the file {\tt redo.input}.
created by the last {\tt )undo} command.
This file consists of all user input lines, excluding those
backtracked over due to a previous {\tt )undo}.

\par\noindent{\bf Also See:}
{\tt )history} \index{ugSysCmdhistory}.
The command {\tt )history )write} will eliminate the ``undone'' command
lines of your program.
\section{Variables Used}
\section{Data Structures}
[[$frameRecord = [delta1, delta2,... ] ]] where
[[delta(i)]] contains changes in the ``backwards'' direction.
Each [[delta(i)]] has the form [[((var . proplist)...)]] where
proplist denotes an ordinary proplist. For example, an entry
of the form [[((x (value) (mode (Integer)))...)]] indicates that
to undo 1 step, [[x]]'s value is cleared and its mode should be set
to [[(Integer)]].

A [[delta(i)]] of the form [[(systemCommand . delta)]] is a special
delta indicating changes due to system commands executed between
the last command and the current command. By recording these deltas
separately, it is possible to undo to either BEFORE or AFTER
the command. These special [[delta(i)]]s are given ONLY when a
a system command is given which alters the environment.

Note: [[recordFrame('system)]] is called before a command is executed, and
[[recordFrame('normal)]] is called after (see processInteractive1).
If no changes are found for former, no special entry is given.

The [[$previousBindings]] is a copy of the 
[[CAAR $InteractiveFrame]]. This is used to
compute the [[delta(i)]]s stored in [[$frameRecord]].
\section{Functions}
\subsection{Initial Undo Variables}
\begin{verbatim}
\end{verbatim}
<<initvars>>=
(defvar |$reportUndo| nil "t means we report the steps undo takes")
@


\subsection{defun reportUndo}
This function is enabled by setting [[|$reportUndo]] to a non-nil value.
An example of the output generated is:
\begin{verbatim}
r := binary(22/7)
 

           ___
   (1)  11.001
                                                        Type: BinaryExpansion
Properties of % ::
  value was: NIL
  value is:  ((|BinaryExpansion|) WRAPPED . #(1 (1 1) NIL (0 0 1)))
Properties of r ::
  value was: NIL
  value is:  ((|BinaryExpansion|) WRAPPED . #(1 (1 1) NIL (0 0 1)))

\end{verbatim}


\chapter{The Spad Server Mechanism}
<<initvars>>=
(defvar $openServerIfTrue t "t means try starting an open server")
(defconstant $SpadServerName "/tmp/.d" "the name of the spad server socket")
(defvar |$SpadServer| nil "t means Scratchpad acts as a remote server")

@

\chapter{Axiom Build-time Functions}
\subsection{defun spad-save}
The {\bf spad-save} function is just a cover function for more
lisp system specific save functions. There is no standard name
for saving a lisp image so we make one and conditionalize it
at compile time.

This function is passed the name of an image that will be saved.
The saved image contains all of the loaded functions.

This is used in the [[src/interp/Makefile.pamphlet]] in three places:
\begin{list}{}
\item creating depsys, an image for compiling axiom.

Some of the Common Lisp code we compile uses macros which
are assumed to be available at compile time. The {\bf DEPSYS}
image is created to contain the compile time environment
and saved. We pipe compile commands into this environment
to compile from Common Lisp to machine dependent code.
\begin{verbatim}
DEPSYS=	${OBJ}/${SYS}/bin/depsys
\end{verbatim}

\item creating savesys, an image for running axiom.

Once we've compile all of the Common Lisp files we fire up
a clean lisp image called {\bf LOADSYS}, load all of the
final executable code and save it out as {\bf SAVESYS}.
The {\bf SAVESYS} image is copied to the [[${MNT}/${SYS}/bin]]
subdirectory and becomes the axiom executable image.
\begin{verbatim}
LOADSYS= ${OBJ}/${SYS}/bin/lisp
SAVESYS= ${OBJ}/${SYS}/bin/interpsys
AXIOMSYS= ${MNT}/${SYS}/bin/AXIOMsys
\end{verbatim}


\item creating debugsys, an image with all interpreted functions loaded.

Occasionally we need to really get into the system internals.
The best way to do this is to run almost all of the lisp code
interpreted rather than compiled (note that cfuns.lisp and sockio.lisp
still need to be loaded in compiled form as they depend on the 
loader to link with lisp internals). This image is nothing more
than a load of the file src/interp/debugsys.lisp.pamphlet. If
you need to make test modifications you can add code to that
file and it will show up here.
\begin{verbatim}
DEBUGSYS=${OBJ}/${SYS}/bin/debugsys
\end{verbatim}
\end{list}
<<defun spad-save>>=
(defun spad-save (save-file)
  (setq |$SpadServer| nil)
  (setq $openServerIfTrue t)
#+:AKCL
  (system::save-system save-file)
#+:allegro
  (if (fboundp 'boot::restart)
   (excl::dumplisp :name save-file :restart-function #'boot::restart)
   (excl::dumplisp :name save-file))
#+Lucid
  (if (fboundp 'boot::restart)
   (sys::disksave save-file :restart-function #'boot::restart)
   (sys::disksave save-file))
#+:CCL
  (preserve)
)

@

\chapter{The Interpreter}
<<Interpreter>>=
(IMPORT-MODULE "vmlisp")
(in-package "BOOT")
<<initvars>>


<<defun getenviron>>

<<defun init-memory-config>>
<<defun initroot>>

<<defun loadExposureGroupData>>

<<defun make-absolute-filename>>

<<defun reclaim>>

<<defun reroot>>
<<defun restart>>

<<defun set-restart-hook>>
<<defun spad-save>>
<<defun statisticsInitialization>>

@
\chapter{Makefile.bookvol5}
<<*>>=
LATEX=/usr/bin/latex
LISP=${AXIOM}/obj/linux/bin/lisp
TANGLE=/usr/local/bin/NOTANGLE
WEAVE=/usr/local/bin/NOWEAVE -delay

all: bookvol5
	@echo 0 done

bookvol5: bookvol5.pamphlet
	@echo 1 extracting the bookvol5reter
	${WEAVE} bookvol5.pamphlet >bookvol5.tex
	${LATEX} bookvol5.tex
	${LATEX} bookvol5.tex
	${TANGLE} -R"Interpreter" bookvol5.pamphlet >bookvol5.lisp

remake:	
	@echo 2 rebuilding the makefile
	@${TANGLE} bookvol5.pamphlet >Makefile.bookvol5

@
\eject
\begin{thebibliography}{99}
\bibitem nothing
\end{thebibliography}
\end{document}