Interlisp Example Session on TWENEX

The following is an annotated transcript of an Interlisp session run on TWENEX. It is adapted from the example session in Interlisp Reference Manual* pages 2.5-2.9.

User input is shown in WHITE.

@INTERLISP:LISP
INTERLISP-10  31-Dec-84 ...
Hello.
      
The user calls Interlisp from EXEC. Interlisp prints a date, and a greeting. The prompt character "_" indicates the user is at the top level of Interlisp.
3_DEFINEQ((FACT (LAMBDDA (N) (IF N=0 THEN NIL ELSE N*(FACTT N-1]
(FACT)
      
The user defines the function, fact, for computing the factorial of n. The function definition uses CLISP (Conversational Lisp; IF N=0 THEN NIL ELSE...). The CLISP will automatically be converted to Lisp when the function is run. The function definition contains three errors.
4_(GETD 'FACT)
(LAMBDDA (N) (IF N=0 THEN NIL ELSE N* (FACTT N-1)))
      
The user "looks" at the function definition. Note that the user typed an input consisting of a single expression, i.e., (GETD (QUOTE FACT)), which was therefore interpreted as a form for eval. The user could also have typed GETD(FACT).
5_FACT(3)
LAMBDDA {below FACT} -> LAMBDA ?  Yes
FACTT {in FACT} -> FACT ?  Yes
      
The user runs his function. Two errors and corrections are offered by DWIM. In each case, the user indicats his approval by typing "Y", DWIM makes the correction, i.e., actually changes the definition of fact, and then continues the computation.
NON-NUMERIC ARG
NIL

(ITIMES broken)
      
An error occurs that DWIM cannot handle and the system goes into a break. At this point, the user can type in expressions to be eval-ed or apply-ed exactly as at the top level. The prompt character ":" indicates that the user is in a break, i.e., that the context of his computation is available. In other words, the system is actually "within" or "below" the call to itimes in which the error occurred.
6:BT
ITIMES
COND
FACT
COND
FACT
COND
*ENV*
FACT
*ENV*
APPLY
*PROG*LAM
LISPX
ERRORSET
EVALQT
NIL

      
The user types in the break command, BT, which calls for a backtrace to be printed.
7:N
1
      
The user asks for the value of the variable n, i.e., the most recent value, or binding. The interpreter will search the stack for the most recent binding, and failing to find one, will obtain the top level value from the atoms's value cell, which is car of the atom. If there are no bindings, and the value cell contains the atom NOBIND, and unbound atom error is generated.
8:EDITF(FACT)
edit
      
The user realizes his error, and calls the editor to fix it. It is an extremely useful facility of Interlisp.
1*(R NIL 1)
      
The user instructs the editor to replace all NIL's (in this case there is only one) by 1. The editor physically changes the expression it is operating on so when the user exits from the editor, his function, as it is now being interpreted, has been changed.
2*OK
FACT
      
The user exits from the editor and returns to the break.
9:RETURN 1
ITIMES = 1
6
      
The user specifies the value to be used by itimes in place of NIL by using the break command RETURN. This causes the computation to continue, and 6 is ultimately returned as the value of the original input, fact(3).
10_PP FACT

(FACT
  [LAMBDA (N)  **COMMENT**
    (if (ZEROP N)
        then 1
      else (ITIMES N (FACT (SUB1 N])
(FACT)
      
The user prettyprints fact, i.e., asks it be printed with appropriate indentations to indicate structure. Prettyprint also provides a comment facility. Note that both the changes made to fact by the editor and those made by DWIM are in evidence.
11_MAKEFILES()
****NOTE: the following are not contained on any file:
    the functions: FACT
want to say where the above go ? Yes
(functions)
FACT  File name: FACT.LISP
create new file FACT.LISP ? Yes
FACT.LISP...
(<PAPA>FACT.LISP.1)
      
The user calls makefiles to write out any changes he has made. The file package knows that the function fact has been changed, but doesn't know on which file it belongs, and asks the users as shown in the example. After this interaction, the symbolic file <PAPA>FACT.LISP.1 is written out. This file can be loaded into Interlisp at a later date via the function load, will cause fact to be defined as it currently is. There is also a facility in Interlisp for saving and restoring an entire core image via the funcitons sysout and sysin.
13_LOGOUT()
@
      
The user logs out, returning control to EXEC. However, he can still continue his session by re-entering Interlisp via the EXEC CONTINUE command.

* Warren Teitelman. Interlisp Reference Manual. (1978). Accessed: October 6, 2024. [Online]. Available: https://www.softwarepreservation.org/projects/LISP/interlisp/Interlisp-Oct_1978.pdf