216 lines
94 KiB
Plaintext
216 lines
94 KiB
Plaintext
1
|
||
|
||
LISP RELEASE NOTES, MEDLEY RELEASE, THE EXEC
|
||
1
|
||
|
||
LISP RELEASE NOTES, MEDLEY RELEASE, THE EXEC
|
||
APPENDIX A - THE EXEC
|
||
1
|
||
|
||
APPENDIX A - THE EXEC
|
||
1
|
||
|
||
|
||
|
||
|
||
APPENDIX A. THE EXEC
|
||
6
|
||
|
||
In most Common Lisp implementations, there is a "top-level read-eval-print (READ-EVAL-PRINT% NIL read-eval-print% NIL (A) 1)loop," which reads an expression, evaluates it, and prints the results. In Xerox Common Lisp, the Exec acts as the top-level loop, but in addition to read-eval-print, it also performs a number of other tasks, and allows a much greater range of inputs. This appendix contains information from the Lyric and Medley releases. Medley additions are indicated with revision bars in the right margin.
|
||
The Exec is based on concepts from the Interlisp Programmer's Assistant (see the Interlisp-D Reference Manual).
|
||
The Exec traps all throws, and recovers gracefully. It prints all values resulting from evaluation, on separate lines. When zero values are returned, nothing is printed.
|
||
The Exec keeps track of your previous input, in a structure called the history list. A history list is a list of the information associated with each of the individual events that have occurred, where each event corresponds to one input. Associated with each event on the history list is the input, its values, plus other optional information such as side-effects, formatting information, etc.
|
||
The following dialogue contains illustrative examples and gives the flavor of the use of the Exec. Be sure to type these examples to an Exec whose *PACKAGE*(*PACKAGE* (Variable) NIL NIL (A) 1) is set to the XCL-USER package. The Exec that Lisp starts up with is set to the XCL-USER package. Each prompt consists of an event number and a prompt character (">").
|
||
12>(setq foo 5)
|
||
5
|
||
13>(setq foo 10)
|
||
10
|
||
14>undocr
|
||
SETQ undone.
|
||
15>foocr
|
||
5
|
||
This is an example of direct communication with the Exec. You have instructed the Exec to undo the previous event.
|
||
. . .
|
||
25>set(lst1 (a b c))
|
||
(A B C)
|
||
26>(setq lst2 '(d e f))
|
||
(D E F)
|
||
27>(mapc #'(lambda (x) (setf (get x 'myprop) t)) lst1)
|
||
(A B C)
|
||
The Exec accepts input both in APPLY format (the SET) and EVAL format (the SETQ.) In event 27, the user adds a property MYPROP to the symbols A, B, and C.
|
||
28>use lst2 for lst1 in 27cr
|
||
NIL
|
||
You just instructed the Exec to go back to event number 27, substitute LST2 for LST1, and then re-execute the expression. You could have also used -2 instead of 27, specifying a relative address.
|
||
.
|
||
.
|
||
.
|
||
46>(setf my-hash-table (make-hash-table))
|
||
#<Hash-Table @ 66,114034>
|
||
47>(setf (gethash 'foo my-hash-table) (string 'foo))
|
||
"FOO"
|
||
If STRING were computationally expensive (which it is not), then you might be caching its value for later use.
|
||
48>use fie for foo in stringcr
|
||
"FIE"
|
||
You now decide you would like to redo the SETF with a different value. You specify the event using "IN STRING" rather than SETF.
|
||
49>?? usecr
|
||
|
||
USE FIE FOR FOO IN STRING
|
||
48> (SETF (GETHASH 'FIE MY-HASH-TABLE)
|
||
(STRING 'FIE))
|
||
"FIE"
|
||
Here you ask the Exec (using the ?? command) what it has on its history list for the last input. Since the event corresponds to a command, the Exec displays both the original command and the generated input.
|
||
The most common interaction with the Exec occurs at the top level or in the debugger, where you type in expressions for evaluation, and see the values printed out. In this mode, the Exec acts much like a standard Common Lisp top-level loop, except that before attempting to evaluate an input, the Exec first stores it in a new entry on the history list. Thus if the operation is aborted or causes an error, the input is still saved and available for modification and/or re-execution. The Exec also notes new functions and variables to be added to its spelling lists to enable future corrections.
|
||
After updating the history list, the Exec executes the computation (i.e., evaluates the form or applies the function to its arguments), saves the value in the entry on the history list corresponding to the input, and prints the result. Finally the Exec displays a prompt to indicate it is again ready for input.
|
||
Input Formats
|
||
1
|
||
|
||
The Exec accepts three forms of input: an expression to be evaluated (EVAL-format), a function-name and arguments to apply it to (APPLY-format), and Exec commands, as follows:
|
||
EVAL-format input(EVAL-FORMAT% INPUT NIL EVAL-format% input NIL (A) 2) If you type a single expression, either followed by a carriage-return, or, in the case of a list, terminated with balanced parenthesis, the expression is evaluated and the value is returned. For example, if the value of the variable FOO is the list (A B C):
|
||
32>FOOcr
|
||
(A B C)
|
||
Similarly, if you type a Lisp expression, beginning with a left parenthesis and terminated by a matching right parenthesis, the form is simply passed to EVAL for evaluation. Notice that it is not necessary to type a carriage return at the end of such a form; the reader will supply one automatically. If a carriage-return is typed before the final matching right parenthesis or bracket, it is treated the same as a space, and input continues. The following examples are interpreted identically:
|
||
123> (+ 1 (* 2 3))
|
||
7
|
||
124> (+ 1 (*cr
|
||
2 3))
|
||
7
|
||
APPLY-format input (APPLY-FORMAT% INPUT% NIL APPLY-format% input% NIL (A) 3) Often, when typing at the keyboard, you call functions with constant argument values, which would have to be quoted if you typed them in "EVAL-format." For convenience, if you type a symbol immediately followed by a list form, the symbol is APPLYed to the elements within the list, unevaluated. The input is terminated by the matching right parenthesis. For example, typing LOAD(FOO) is equivalent to typing (LOAD 'FOO), and GET(X COLOR) is equivalent to (GET 'X 'COLOR). As a simple special case, a single right parenthesis is treated as a balanced set of parentheses, e.g.
|
||
125>UNBREAK)
|
||
is equivalent to
|
||
125>UNBREAK()
|
||
The reader will only supply the "carriage return" automatically if no space appears between the initial symbol and the list that follows; if there is a space after the initial symbol on the line and the list that follows, the input is not terminated until a carriage return is explicitly typed.
|
||
Note that APPLY-format input cannot be used for macros or special forms.
|
||
Exec commands The Exec recognizes a number of commands, which usually refer to past events on the history list. These commands are treated specially; for example, they may not be put on the history list. The format of a command is always a line beginning with the command name. (The Exec looks up the command name independent of package, so that Exec commands are package independent.) The remainder of the line, if any, is treated as "arguments" to the command. For example,
|
||
128>UNDOcr
|
||
mapc undone
|
||
129>UNDO (FOO --)cr
|
||
foo undone
|
||
are all valid command inputs.
|
||
Multiple Execs and the Exec's Type
|
||
1
|
||
|
||
Multiple Execs(MULTIPLE% EXECS NIL Multiple% Execs NIL (A) 4) More than one Exec can be active at any one time. New Execs can be created by selecting the Exec menu item in the background pop-up menu. When a prompt is printed for an event in other than the first Exec, the prompt is preceded with the Exec number; for example:
|
||
2/50>
|
||
might be a prompt in Exec 2. All Execs share the same history list, but each event records which Exec it goes with. That is, although a single global list exists, the Xerox Lisp history system maintains the separate threads of control within each Exec.
|
||
Exec type(EXEC% TYPE NIL Exec% type NIL (A) 4) Several variables are very important to an Exec since they control the format of reading and printing. Together these variables describe a type of exec. Put another way, this is the Exec's mode. To allow easier setting of these modes some standard bindings for the variables have been named. The names provide the user an Exec of the Common Lisp (CL), Interlisp (IL) or Xerox Extended Common Lisp (XCL) type. An Exec's type is usually displayed in the title bar of its window in parentheses:
|
||
|