perm filename LSPLOT.XGP[206,LSP]4 blob
sn#428532 filedate 1979-04-02 generic text, type T, neo UTF8
/LMAR=0/XLINE=3/FONT#0=BAXL30[FNT,CLT]/FONT#1=BAXM30/FONT#2=BAXB30[FNT,CLT]/FONT#3=SUB/FONT#4=SUP/FONT#5=GACS25/FONT#6=FIX20/FONT#7=SYMB30[FNT,CLT]/FONT#8=FIX25/FONT#11=GRFX25/FONT#12=GRFX35/FONT#9=BEESIX
␈↓ ↓H␈↓ ␈↓ ¬qMACLISP
␈↓ ↓H␈↓ ␈↓ ε8at
␈↓ ↓H␈↓ ␈↓ ε↔LOTS
␈↓ ↓H␈↓␈↓ ¬BCompiled for CS206
␈↓ ↓H␈↓␈↓ ¬Hby Carolyn Talcott
␈↓ ↓H␈↓␈↓ ¬GStanford University
␈↓ ↓H␈↓␈↓ ∧_This version printed at 15:54 on April 2, 1979.
␈↓ ↓H␈↓␈↓ εH␈↓ ?i
␈↓ ↓H␈↓α␈↓ ¬NTable of Contents
␈↓ ↓H␈↓␈↓ Page
␈↓ ↓H␈↓Preface
␈↓ ↓H␈↓I␈↓ α_USING MACLISP AT LOTS
␈↓ ↓H␈↓␈↓ α81␈↓ αxIntroduction␈↓ ∧8 . . . . . . . . . . . . . . . . . . . . . . . .␈↓ ≠ 1
␈↓ ↓H␈↓␈↓ α82␈↓ αxExample of Interactive Session␈↓ ε8 . . . . . . . . . . . . . . . .␈↓ ≠ 1
␈↓ ↓H␈↓␈↓ α83␈↓ αxSuggestions for Homework Preparation.␈↓ εx . . . . . . . . . . . . . . .␈↓ ≠ 3
␈↓ ↓H␈↓II␈↓ α_A MICRO-MANUAL FOR LISP - MOSTLY TRUTHFUL
␈↓ ↓H␈↓␈↓ α81␈↓ αxBasic notions.␈↓ ∧8 . . . . . . . . . . . . . . . . . . . . . . . .␈↓ ≠ 5
␈↓ ↓H␈↓␈↓ α82␈↓ αxSome Useful Abbreviations.␈↓ ¬x . . . . . . . . . . . . . . . . . .␈↓ ≠ 6
␈↓ ↓H␈↓III␈↓ α_INPUT AND OUTPUT
␈↓ ↓H␈↓␈↓ α81␈↓ αxBasic I/O functions.␈↓ ∧x . . . . . . . . . . . . . . . . . . . . . .␈↓ ≠ 8
␈↓ ↓H␈↓␈↓ α82␈↓ αxSpecifying the Source or Destination for I/O.␈↓ π8 . . . . . . . . . . . . .␈↓ ≠ 9
␈↓ ↓H␈↓␈↓ α83␈↓ αxFunctions for Selecting and Opening Files.␈↓ π8 . . . . . . . . . . . . .␈↓ 10
␈↓ ↓H␈↓IV␈↓ α_THE LISP EDITOR
␈↓ ↓H␈↓␈↓ α81␈↓ αxHow to Use the LISP Editor.␈↓ ¬x . . . . . . . . . . . . . . . . . .␈↓ 13
␈↓ ↓H␈↓␈↓ α82␈↓ αxExample session with the LISP Editor.␈↓ εx . . . . . . . . . . . . . .␈↓ 19
␈↓ ↓H␈↓␈↓ εH␈↓ ?i
␈↓ ↓H␈↓α␈↓ ε∃Preface
␈↓ ↓H␈↓ This␈α∞note␈α∞is␈α∞intended␈α∞as␈α∞an␈α∞introduction␈α∞to␈α∞the␈α∞use␈α∞of␈α∞the␈α∞student␈α∞version␈α∞of␈α∞MACLISP
␈↓ ↓H␈↓currently␈αavailable␈αat␈αthe␈αStanford␈αLOTS␈αComputing␈αCenter.␈α It␈αis␈αparticularly␈αaimed␈αat␈αstudents
␈↓ ↓H␈↓in␈α
CS206.␈α
In␈α
the␈α
first␈α
section␈α
we␈α
give␈α∞a␈α
brief␈α
discussion␈α
of␈α
how␈α
to␈α
use␈α
MACLISP.␈α
There␈α∞is␈α
a
␈↓ ↓H␈↓"photo"␈α
of␈α
a␈α
sample␈α
session␈αwith␈α
the␈α
LISP␈α
interpreter␈α
using␈αthe␈α
basic␈α
features␈α
that␈α
the␈αstudent␈α
will
␈↓ ↓H␈↓need.␈α Some␈αsuggestions␈αon␈αthe␈αmechanics␈αof␈αwriting,␈αdebugging,␈αand␈αpreparing␈αresults␈αto␈αturn␈αin
␈↓ ↓H␈↓as homework are also given.
␈↓ ↓H␈↓ The␈α∂second␈α⊂section␈α∂is␈α⊂the␈α∂MICRO␈α⊂MANUAL␈α∂for␈α⊂LISP␈α∂written␈α⊂by␈α∂John␈α⊂McCarthy.␈α∂ It
␈↓ ↓H␈↓contains␈α
a␈α
description␈αof␈α
the␈α
primitives␈αof␈α
LISP␈α
their␈α
semantics␈αand␈α
some␈α
useful␈αabbreviations␈α
for
␈↓ ↓H␈↓pratical␈α∞use.␈α
As␈α∞this␈α
contains␈α∞discussion␈α
of␈α∞only␈α∞the␈α
very␈α∞basic␈α
notions␈α∞of␈α
LISP␈α∞it␈α∞is␈α
essentially
␈↓ ↓H␈↓implementation␈α↔independent␈α⊗and␈α↔any␈α↔reasonable␈α⊗LISP␈α↔should␈α↔behave␈α⊗in␈α↔this␈α↔way␈α⊗(some
␈↓ ↓H␈↓abbreviations may have different names).
␈↓ ↓H␈↓ The␈α∪third␈α∩section␈α∪describes␈α∪Input/Output␈α∩in␈α∪the␈α∪Stanford␈α∩Version␈α∪of␈α∪MACLISP␈α∩and
␈↓ ↓H␈↓includes␈α⊃a␈α⊃few␈α⊃examples␈α⊃of␈α⊂the␈α⊃use␈α⊃of␈α⊃the␈α⊃I/O␈α⊂operations.␈α⊃ The␈α⊃fourth␈α⊃section␈α⊃describes␈α⊂the
␈↓ ↓H␈↓MACLISP editor.
␈↓ ↓H␈↓␈↓ εH␈↓ 91
␈↓ ↓H␈↓α␈↓ εSection I
␈↓ ↓H␈↓α␈↓ ¬βUSING MACLISP AT LOTS
␈↓ ↓H␈↓1. ␈↓αIntroduction␈↓
␈↓ ↓H␈↓ The␈α∂following␈α∂is␈α∞a␈α∂brief␈α∂introduction␈α∂to␈α∞the␈α∂use␈α∂of␈α∂the␈α∞student␈α∂version␈α∂of␈α∂MACLISP␈α∞at
␈↓ ↓H␈↓LOTS.␈α This␈αversion␈αcan␈αbe␈αrun␈αat␈αLOTS␈α by␈αtyping␈α"LISP"␈αto␈αthe␈αLOTS␈αmonitor.␈α Allocation,
␈↓ ↓H␈↓initialization␈α
of␈α
the␈α
Editor␈α
and␈α
other␈α
useful␈α
things␈α
are␈α
done␈α
automatically.␈α
As␈α
with␈α
other␈α
LISP
␈↓ ↓H␈↓interpreters,␈α
the␈α
top␈α
level␈α
is␈α
a␈α
read-eval-print␈αloop.␈α
Type␈α
in␈α
an␈α
S-expression␈α
and␈α
LISP␈αreturns
␈↓ ↓H␈↓the value. To exit LISP type <control>C.
␈↓ ↓H␈↓ This␈αversion␈αof␈αMACLISP␈αhas␈αthe␈αI/O␈αfunctions␈α␈↓¬DSKIN␈α␈↓and␈α␈↓¬DSKOUT␈α␈↓␈αwhich␈αare␈αsimilar␈αto
␈↓ ↓H␈↓the␈αfunctions␈αof␈αthe␈α
same␈αname␈αin␈αLISP1.6.␈α
To␈αinput␈αa␈αfile␈α
named␈α FOO.BAR␈αon␈αyour␈α
directory
␈↓ ↓H␈↓say␈α
␈↓¬(DSKIN FOO BAR)␈↓.␈α
If␈αthe␈α
file␈α
resides␈α
on␈αone␈α
of␈α
the␈α
additional␈αdirectories␈α
known␈α
to␈αLISP␈α
then
␈↓ ↓H␈↓␈↓¬(DSKIN FOO BAR <name>)␈↓␈αwill␈αread␈α<name>FOO.BAR.␈α One␈αsuch␈αdirectory␈αis␈αCS206.␈αIf␈αthe␈αfile
␈↓ ↓H␈↓resides␈α"on␈α"a␈α"directory␈α"unknown␈α"to␈α!LISP␈α"then␈α"the␈α"form␈α"of␈α"the␈α"instruction␈α!is
␈↓ ↓H␈↓␈↓¬(DSKIN FOO BAR DSK (m n))␈↓␈α∞where␈α∞␈↓¬(m n)␈α∞␈↓is␈α∞the␈α∞system␈α∞account␈α∞information␈α∞for␈α∞the␈α∞directory
␈↓ ↓H␈↓concerned.␈α⊃ The␈α⊃Editor␈α⊃functions␈α⊃␈↓¬SAVE␈α⊃␈↓and␈α⊃␈↓¬REFILE␈α⊃␈↓can␈α⊃be␈α⊃used␈α⊃to␈α⊃save␈α⊃or␈α∩update␈α⊃function
␈↓ ↓H␈↓definitions.␈αThe␈αfunction␈α␈↓¬DSKOUT␈α␈↓can␈αbe␈αused␈αto␈αwrite␈αon␈αa␈αfile.␈α For␈αexample␈αif␈α␈↓¬FF␈α␈↓is␈αa␈αfunction
␈↓ ↓H␈↓taking␈α∀one␈α∀argument␈α∃then␈α∀␈↓¬(DKSOUT (PRINC (FF (QUOTE␈α∀(A.B)))) FOO BAR)␈↓␈α∀creates␈α∃a␈α∀file
␈↓ ↓H␈↓FOO.BAR␈α
on␈αyour␈α
directory␈α
and␈α␈↓¬PRINC␈↓'s␈α
the␈α
result␈αof␈α
evaluating␈α
␈↓¬(FF␈α(QUOTE␈α
(A.B)))␈↓␈α
on␈αthat
␈↓ ↓H␈↓file.␈α~ More␈α~general␈α→I/O␈α~operations␈α~can␈α→be␈α~done␈α~using␈α→the␈α~MACLISP␈α~ I/O␈α→ functions
␈↓ ↓H␈↓␈↓¬UREAD/UWRITE␈α∂␈↓together␈α∂with␈α∞the␈α∂appropriate␈α∂control␈α∞switches.␈α∂ These␈α∂are␈α∞described␈α∂in␈α∂the␈α∞I/O
␈↓ ↓H␈↓section.
␈↓ ↓H␈↓ Sometimes␈α∂you␈α⊂will␈α∂make␈α∂error␈α⊂and␈α∂a␈α∂"breakpoint"␈α⊂will␈α∂occur.␈α∂ The␈α⊂system␈α∂will␈α⊂type␈α∂a
␈↓ ↓H␈↓message␈α∂preceded␈α∞by␈α∂a␈α∂";"␈α∞and␈α∂perhaps␈α∂give␈α∞you␈α∂the␈α∂option␈α∞of␈α∂correcting␈α∂the␈α∞error␈α∂on␈α∂the␈α∞fly.
␈↓ ↓H␈↓Usually␈αthe␈αinformation␈αthat␈α is␈αtyped␈αwill␈αalert␈α you␈αto␈αthe␈αcause␈αof␈αthe␈αerror;␈αif␈α not,␈αyou␈αshould
␈↓ ↓H␈↓read␈αabout␈αerrors␈αand␈αdebugging␈α
aids␈αin␈αa␈αMACLISP␈αmanual.␈α In␈α
any␈αcase,␈α to␈α get␈αback␈α
to␈αthe
␈↓ ↓H␈↓toplevel␈α
of␈α
MACLISP␈α
you␈α
type:␈α
␈↓¬<control>G␈α
␈↓or␈α ␈↓¬(IOC G)␈↓.␈α
(If␈α
the␈α
system␈α
replys␈α
with␈α
an␈αerror
␈↓ ↓H␈↓message␈αand␈αdoes␈αnot␈αask␈αyou␈αfor␈αa␈αcorrection␈αit␈αis␈αa␈αgood␈αidea␈αto␈αdo␈αa␈α<control>G␈αjust␈α
to␈αmake
␈↓ ↓H␈↓sure you have returned the appropriate level.)
␈↓ ↓H␈↓2. ␈↓αExample of Interactive Session ␈↓
␈↓ ↓H␈↓ The␈αfollowing␈αis␈αthe␈αlog␈αof␈αa␈αsession␈αwith␈αLISP␈αat␈αLOTS.␈α Things␈αin␈αlower␈αcase␈αare␈αtyped
␈↓ ↓H␈↓by␈α∂the␈α∂user␈α∂and␈α∂those␈α∂in␈α∂UPPER␈α∂case␈α∂are␈α∂generated␈α∂by␈α∂LISP.␈α∂ A␈α∂single␈α∂semicolon␈α∂";"␈α∂flags␈α∂a
␈↓ ↓H␈↓comment made by LISP. A triple semicolon ";;;" flags a comment made by the user.
␈↓ ↓H␈↓¬@lisp
␈↓ ↓H␈↓¬Student MacLisp Interpreter
␈↓ ↓H␈↓¬RIGHT!
␈↓ ↓H␈↓2␈↓ ε
Section I␈↓ H
␈↓ ↓H␈↓¬;;;ask LISP the value of some simple S-expressions
␈↓ ↓H␈↓¬nil
␈↓ ↓H␈↓¬NIL
␈↓ ↓H␈↓¬t
␈↓ ↓H␈↓¬T
␈↓ ↓H␈↓¬(cons 'a 'b) ;;; 'a is an abbreviation for (quote a)
␈↓ ↓H␈↓¬(A . B)
␈↓ ↓H␈↓¬(car (cons 'a 'b))
␈↓ ↓H␈↓¬A
␈↓ ↓H␈↓¬(eq 'a (car (cons 'a 'b)))
␈↓ ↓H␈↓¬T
␈↓ ↓H␈↓¬;;;define a function called double
␈↓ ↓H␈↓¬(defun double (x) (cons x x))
␈↓ ↓H␈↓¬DOUBLE
␈↓ ↓H␈↓¬;;;try it out
␈↓ ↓H␈↓¬(double nil)
␈↓ ↓H␈↓¬(NIL)
␈↓ ↓H␈↓¬(double 1)
␈↓ ↓H␈↓¬(1 . 1)
␈↓ ↓H␈↓¬(double (double 1))
␈↓ ↓H␈↓¬((1 . 1) 1 . 1)
␈↓ ↓H␈↓¬;;;read in a file
␈↓ ↓H␈↓¬(dskin gg lsp)
␈↓ ↓H␈↓¬GG
␈↓ ↓H␈↓¬DONE
␈↓ ↓H␈↓¬;;;this file contained the definition of the function gg
␈↓ ↓H␈↓¬;;;pretty print the definition of gg
␈↓ ↓H␈↓¬(grindef gg)
␈↓ ↓H␈↓¬(DEFUN GG (X) (COND ((ATOM X) X) (T (GG (CDR X)))))
␈↓ ↓H␈↓¬;;;gg finds the right most atom
␈↓ ↓H␈↓¬;;;write the definitions of double and gg in a file named abc.def.
␈↓ ↓H␈↓¬;;;the output also goes to the terminal
␈↓ ↓H␈↓¬(dskout (grindef double gg) abc def)
␈↓ ↓H␈↓¬(DEFUN DOUBLE (X) (CONS X X))
␈↓ ↓H␈↓¬(DEFUN GG (X) (COND ((ATOM X) X) (T (GG (CDR X)))))
␈↓ ↓H␈↓¬(DSK (4 1002))
␈↓ ↓H␈↓¬;;;dskout creates a file called abc.def (and hence destroys any
␈↓ ↓H␈↓¬;;;old file having the same name. It returns the device and directory
␈↓ ↓H␈↓¬;;; where the file was written.
␈↓ ↓H␈↓¬;;;trace gg
␈↓ ↓H␈↓¬(trace gg)
␈↓ ↓H␈↓¬(FASLOAD TRACE FASL SYS (4 1002)) FILE NOT FOUND
␈↓ ↓H␈↓¬;BKPT FAIL-ACT
␈↓ ↓H␈↓¬;;;this problem was induced by a system change made
␈↓ ↓H␈↓¬;;;after the current version of MACLISP was put up.
␈↓ ↓H␈↓¬;;;to get trace and other system functions not already
␈↓ ↓H␈↓¬;;;present first get fasfix.lsp from the cs206 area
␈↓ ↓H␈↓¬(dskin fasfix lsp cs206)
␈↓ ↓H␈↓¬FASFIX
␈↓ ↓H␈↓¬DONE
␈↓ ↓H␈↓␈↓ ε
Section I␈↓ 93
␈↓ ↓H␈↓¬;;;now do (faxfix f1 ... fn) where fi are MACLISP
␈↓ ↓H␈↓¬;;;system functions not already loaded. trace is one such.
␈↓ ↓H␈↓¬(fasfix trace)
␈↓ ↓H␈↓¬;LOADING TRACE 59
␈↓ ↓H␈↓¬(DSK (4 1002))
␈↓ ↓H␈↓¬(trace gg)
␈↓ ↓H␈↓¬(GG)
␈↓ ↓H␈↓¬;;;now execute gg
␈↓ ↓H␈↓¬(gg '(a b . c))
␈↓ ↓H␈↓¬(1 ENTER GG ((A B . C)))
␈↓ ↓H␈↓¬ (2 ENTER GG ((B . C)))
␈↓ ↓H␈↓¬ (3 ENTER GG (C))
␈↓ ↓H␈↓¬ (3 EXIT GG C)
␈↓ ↓H␈↓¬ (2 EXIT GG C)
␈↓ ↓H␈↓¬(1 EXIT GG C) C
␈↓ ↓H␈↓¬;;;trace is useful for debugging
␈↓ ↓H␈↓¬;;;when a traced function is entered (level ENTER fname arglist) is printed
␈↓ ↓H␈↓¬;;;when a traced function is exited (level EXIT fname result) is printed
␈↓ ↓H␈↓¬;;;however you may not want the function traced at a later time, so
␈↓ ↓H␈↓¬(untrace gg)
␈↓ ↓H␈↓¬(GG)
␈↓ ↓H␈↓¬(gg '(a b . c))
␈↓ ↓H␈↓¬C
␈↓ ↓H␈↓¬;;;thats all for now folks
␈↓ ↓H␈↓¬↑C
␈↓ ↓H␈↓¬@
␈↓ ↓H␈↓3. ␈↓αSuggestions for Homework Preparation.␈↓
␈↓ ↓H␈↓ Some␈αof␈αthe␈αhomework␈αfor␈αCS206␈αinvolves␈αwriting␈αLISP␈αprograms␈αto␈αcompute␈αsome␈αgiven
␈↓ ↓H␈↓recursive␈α∞functions.␈α
The␈α∞student␈α∞is␈α
expected␈α∞to␈α∞debug␈α
the␈α∞programs␈α∞then␈α
turn␈α∞in␈α∞the␈α
following
␈↓ ↓H␈↓things for each program:
␈↓ ↓H␈↓ 1. The internal form of the program.
␈↓ ↓H␈↓ 2. The corresponding external form recursive definition.
␈↓ ↓H␈↓ 3. A description of how the progam works and why.
␈↓ ↓H␈↓ 4. Output from test runs on a variety of input.
␈↓ ↓H␈↓This␈α
collection␈α
of␈α
data␈α
can␈α∞be␈α
put␈α
together␈α
in␈α
many␈α∞ways.␈α
The␈α
following␈α
procedure␈α
is␈α∞just␈α
one
␈↓ ↓H␈↓possiblity.
␈↓ ↓H␈↓␈↓ αλ1.␈α Using␈αsome␈αeditor␈αavailable␈αat␈αLOTS␈αcreate␈αa␈αfile␈αand␈αtype␈αin␈αthe␈αprograms␈αyou␈αwish␈αto
␈↓ ↓H␈↓␈↓ αHtest.␈α∪ This␈α∩allows␈α∪you␈α∩to␈α∪use␈α∩the␈α∪editor␈α∩to␈α∪correct␈α∩typos.␈α∪ Parenthesis␈α∪matching␈α∩is
␈↓ ↓H␈↓␈↓ αHessential here, so check it carefully.
␈↓ ↓H␈↓4␈↓ ε
Section I␈↓ H
␈↓ ↓H␈↓␈↓ αλ2.␈α When␈α
you␈αthink␈αyour␈α
programs␈αare␈αcorrectly␈α
written␈αrun␈α
LISP␈αand␈αread␈α
in␈αthe␈αfile␈α
(using
␈↓ ↓H␈↓␈↓ αH␈↓¬DSKIN␈α␈↓or␈α␈↓¬UREAD).␈α␈↓␈αNow␈αtry␈αyour␈α
functions␈αon␈αsome␈αtrivial␈αcases.␈α If␈αyou␈αdiscover␈α
some
␈↓ ↓H␈↓␈↓ αHbugs␈α
fix␈αthem␈α
using␈α
the␈αLISP␈α
editor␈αand␈α
␈↓¬SAVE␈α
␈↓or␈α␈↓¬REFILE␈α
␈↓the␈αnew␈α
versions.␈α
Now␈αtest
␈↓ ↓H␈↓␈↓ αHthem on non trivial data until you are convinced they are correct.
␈↓ ↓H␈↓␈↓ αλ3.␈α⊂ To␈α⊃get␈α⊂a␈α⊂"pretty␈α⊃printed"␈α⊂version␈α⊂of␈α⊃your␈α⊂definitions␈α⊂you␈α⊃can␈α⊂␈↓¬(GRINDEF f1 ... fn)␈↓
␈↓ ↓H␈↓␈↓ αHwhere␈α␈↓¬fi␈α␈↓are␈αfunction␈αnames␈α(atoms␈αwith␈αan␈α␈↓¬EXPR␈α␈↓property).␈α This␈αcan␈αbe␈αwritten␈αon␈αa
␈↓ ↓H␈↓␈↓ αHfile using ␈↓¬DSKOUT. ␈↓
␈↓ ↓H␈↓␈↓ αλ4.␈α⊂ To␈α⊂get␈α⊂output␈α⊂from␈α⊂sample␈α⊂runs␈α⊂the␈α⊂LOTS␈α⊂"PHOTO"␈α⊂program␈α⊂is␈α⊂useful.␈α⊂ PHOTO
␈↓ ↓H␈↓␈↓ αHcreates␈αa␈αfile␈αin␈αwhich␈αit␈αkeeps␈αa␈αlog␈αof␈αwhat␈αyou␈αtype␈αto␈αthe␈αterminal␈αand␈αwhat␈αit␈αtypes
␈↓ ↓H␈↓␈↓ αHback. Type HELP PHOTO to the monitor to find out how to use it.
␈↓ ↓H␈↓␈↓ αλ5.␈α Finally␈αyou␈αcan␈αedit␈αthe␈αfile␈αcontaining␈αthe␈αpretty␈αprinted␈αversions␈αof␈αyour␈αprograms␈αand
␈↓ ↓H␈↓␈↓ αHadd␈α∂external␈α∂form␈α∂definitions␈α∞and␈α∂documentation␈α∂for␈α∂each␈α∞program,␈α∂list␈α∂this␈α∂and␈α∞the
␈↓ ↓H␈↓␈↓ αHPHOTO file and turn them in.
␈↓ ↓H␈↓There␈α
are␈α
many␈α
variations␈α
on␈α
the␈α
above␈α
procedure.␈α
You␈α
will␈α
no␈α
doubt␈α
develop␈α
your␈α∞own␈α
style
␈↓ ↓H␈↓and␈αpreferences.␈α This␈αis␈αintended␈αonly␈αto␈αget␈αyou␈αgoing␈αand␈αpoint␈αout␈αsome␈αof␈αthe␈αpossibilities␈α
in
␈↓ ↓H␈↓the case that you are unfamiliar with LOTS, LISP or both.
␈↓ ↓H␈↓␈↓ εH␈↓ 95
␈↓ ↓H␈↓α␈↓ ε¬Section II
␈↓ ↓H␈↓α␈↓ β@A MICRO-MANUAL FOR LISP - MOSTLY TRUTHFUL
␈↓ ↓H␈↓1. ␈↓αBasic notions.␈↓
␈↓ ↓H␈↓ LISP␈α
data␈αare␈α
symbolic␈α
expressions␈αthat␈α
can␈αbe␈α
either␈α
␈↓↓atoms␈↓␈αor␈α
␈↓↓lists␈↓.␈α ␈↓↓Atoms␈↓␈α
are␈α
strings␈αof
␈↓ ↓H␈↓letters␈α⊃and␈α⊃digits␈α⊃and␈α⊃other␈α⊃characters␈α⊃not␈α⊃otherwise␈α⊂used␈α⊃in␈α⊃LISP.␈α⊃ A␈α⊃␈↓↓list␈↓␈α⊃consists␈α⊃of␈α⊃a␈α⊂left
␈↓ ↓H␈↓parenthesis␈αfollowed␈α
by␈αzero␈α
or␈αmore␈α
atoms␈αor␈αlists␈α
separated␈αby␈α
spaces␈αand␈α
ending␈αwith␈α
a␈αright
␈↓ ↓H␈↓parenthesis. Examples: ␈↓¬A, ONION, (), (A), (A ONION A), (PLUS A (TIMES B ONION) 1)␈↓.
␈↓ ↓H␈↓ The␈α↔LISP␈α↔programming␈α↔language␈α↔is␈α↔defined␈α↔by␈α↔rules␈α↔for␈α↔␈↓↓evaluating␈↓␈α↔certain␈α⊗LISP
␈↓ ↓H␈↓expressions␈α∞to␈α
yield␈α∞other␈α
LISP␈α∞expressions␈α∞as␈α
their␈α∞values.␈α
The␈α∞function␈α
␈↓↓value␈↓␈α∞used␈α∞in␈α
giving
␈↓ ↓H␈↓these␈α
rules␈α
is␈α
not␈α
part␈α
of␈α
the␈α
LISP␈α
language␈α
but␈α
rather␈α
part␈α
of␈α
the␈α
informal␈α
language␈α
in␈α
which
␈↓ ↓H␈↓LISP␈α
is␈αbeing␈α
defined.␈α
Likewise,␈αthe␈α
italic␈α
letters␈α␈↓↓e␈↓␈α
and␈α
␈↓↓a␈↓␈α(sometimes␈α
with␈α
subscripts)␈αdenote␈α
LISP
␈↓ ↓H␈↓expressions,␈αthe␈αletter␈α␈↓↓v␈↓␈α(usually␈αsubscripted)␈αdenotes␈αan␈αatom␈αserving␈αas␈αa␈αvariable,␈αand␈αthe␈αletter
␈↓ ↓H␈↓␈↓↓f␈↓ stands for a LISP expression serving as a function name.
␈↓ ↓H␈↓1. ␈↓↓value (␈↓¬QUOTE ␈↓↓e) = e␈↓. For example, the value of ␈↓¬(QUOTE A)␈↓ is ␈↓¬A␈↓.
␈↓ ↓H␈↓2.␈α∪␈↓↓value␈α∪(␈↓¬CAR␈α∪␈↓↓e)␈↓,␈α∪where␈α∪␈↓↓value␈α∪e␈↓␈α∪is␈α∀a␈α∪non-empty␈α∪list,␈α∪is␈α∪the␈α∪first␈α∪element␈α∪of␈α∀␈↓↓value e␈↓.␈α∪ Thus
␈↓ ↓H␈↓␈↓↓value ␈↓¬(CAR (QUOTE (A B C)))␈↓↓ = ␈↓¬A␈↓↓.␈α
3.␈α
␈↓␈↓↓value␈↓␈α
(␈↓¬CDR␈α
␈↓e)␈↓↓,␈↓␈α
where␈α␈↓↓value␈α
e␈↓␈α
is␈α
a␈α
non-empty␈α
list,␈α
is␈αthe
␈↓ ↓H␈↓the␈αlist␈α
that␈αremains␈αwhen␈α
the␈αfirst␈α
element␈αof␈α␈↓↓value e␈↓␈α
is␈αdeleted.␈α Thus␈α
␈↓↓value ␈↓¬(CDR␈α(QUOTE␈α
(A␈αB
␈↓ ↓H␈↓¬C)))␈↓↓ = ␈↓¬(B C)␈↓↓.␈↓
␈↓ ↓H␈↓4.␈α
␈↓↓value␈α(␈↓¬CONS␈α
␈↓↓e1␈αe2)␈↓,␈α
is␈αthe␈α
list␈αthat␈α
results␈αfrom␈α
prefixing␈α␈↓↓value e1␈↓␈α
onto␈αthe␈α
list␈α
␈↓↓value e2␈↓.␈α Thus
␈↓ ↓H␈↓␈↓↓value ␈↓¬(CONS (QUOTE A) (QUOTE (B C)))␈↓↓ = ␈↓¬(A B C)␈↓↓.␈↓
␈↓ ↓H␈↓5.␈α∃␈↓↓value␈α∃(␈↓¬EQUAL␈α∃␈↓↓e1␈α∀e2)␈↓␈α∃is␈α∃␈↓¬T␈↓␈α∃if␈α∃␈↓↓value␈α∀e1␈α∃=␈α∃value␈α∃e2␈↓.␈α∀ Otherwise,␈α∃its␈α∃value␈α∃is␈α∃␈↓¬NIL␈↓.␈α∀ Thus
␈↓ ↓H␈↓␈↓↓value ␈↓¬(EQUAL (CAR (QUOTE (A B))) (QUOTE A))␈↓↓ = ␈↓¬T␈↓↓␈↓.
␈↓ ↓H␈↓6. ␈↓↓value (␈↓¬ATOM ␈↓↓e) = ␈↓¬T␈↓↓␈↓ if ␈↓↓value e␈↓ is an atom; otherwise its value is ␈↓¬NIL␈↓.
␈↓ ↓H␈↓7.␈α␈↓↓value␈α(␈↓¬COND␈α␈↓↓(p␈↓β1␈↓↓␈αe␈↓β1␈↓↓)␈α...␈α(p␈↓βn␈↓↓␈αe␈↓βn␈↓↓))␈α=␈αvalue␈αe␈↓βi␈↓↓␈↓,␈αwhere␈α␈↓↓p␈↓βi␈↓↓␈↓␈αis␈αthe␈αthe␈αfirst␈αof␈αthe␈α␈↓↓p␈↓'s␈αwhose␈αvalue␈αis␈αnot
␈↓ ↓H␈↓␈↓¬NIL␈↓. Thus ␈↓↓value ␈↓¬(COND ((ATOM (QUOTE A)) (QUOTE B)) ((QUOTE T) (QUOTE C)))␈↓↓ = ␈↓¬B␈↓↓␈↓.
␈↓ ↓H␈↓8. An atom ␈↓↓v,␈↓ regarded as a variable, may have a value.
␈↓ ↓H␈↓9.␈α␈↓↓value␈α((␈↓¬LAMBDA␈α
␈↓↓(v␈↓β1␈↓↓␈α...␈αv␈↓βn␈↓↓)␈α
e)␈αe␈↓β1␈↓↓␈α...␈α
e␈↓βn␈↓↓)␈↓␈αis␈αthe␈αsame␈α
as␈α␈↓↓value e␈↓␈αbut␈α
in␈αan␈αenvironment␈α
in␈αwhich
␈↓ ↓H␈↓the␈α∞variables␈α∞␈↓↓v␈↓β1␈↓↓ ... v␈↓βn␈↓↓␈↓␈α∞take␈α∞the␈α∞values␈α∂of␈α∞the␈α∞expressions␈α∞␈↓↓e␈↓β1␈↓↓ ... e␈↓βn␈↓↓␈↓␈α∞in␈α∞the␈α∂original␈α∞environment.
␈↓ ↓H␈↓Thus
␈↓ ↓H␈↓␈↓↓value ␈↓¬((LAMBDA (X Y) (CONS (CAR X) Y)) (QUOTE (A B)) (CDR (QUOTE (C D))))␈↓↓ = ␈↓¬(A D)␈↓↓␈↓.
␈↓ ↓H␈↓10.␈α∩Here's␈α⊃the␈α∩hard␈α∩one.␈α⊃ ␈↓↓value␈α∩((␈↓¬LABEL␈α∩␈↓↓f␈α⊃(␈↓¬LAMBDA␈α∩␈↓↓(v␈↓β1␈↓↓␈α⊃...␈α∩v␈↓βn␈↓↓)␈α∩e))␈α⊃e␈↓β1␈↓↓␈α∩...␈α∩e␈↓βn␈↓↓)␈↓␈α⊃is␈α∩the␈α∩same␈α⊃as
␈↓ ↓H␈↓␈↓↓value ((␈↓¬LAMBDA␈α␈↓↓(v␈↓β1␈↓↓ ... v␈↓βn␈↓↓) e) e␈↓β1␈↓↓ ... e␈↓βn␈↓↓)␈↓,␈αbut␈αwhenever␈α␈↓↓(f a␈↓β1␈↓↓␈α... a␈↓βn␈↓↓)␈↓␈αmust␈αbe␈αevaluated,␈α␈↓↓f␈↓␈αis␈αreplaced
␈↓ ↓H␈↓by ␈↓↓(␈↓¬LABEL ␈↓↓f (␈↓¬LAMBDA ␈↓↓(v␈↓β1␈↓↓ ... v␈↓βn␈↓↓) e))␈↓. Lists beginning with ␈↓¬LABEL ␈↓define functions recursively.
␈↓ ↓H␈↓6␈↓ ε¬Section II␈↓ H
␈↓ ↓H␈↓ This is the core of LISP, and here are more examples:
␈↓ ↓H␈↓␈↓ βr␈↓↓value ␈↓¬(CAR X)␈↓↓ = ␈↓¬(A B)␈↓↓␈↓ if ␈↓↓value ␈↓¬X␈↓↓ = ␈↓¬((A B) C)␈↓↓␈↓, and
␈↓ ↓H␈↓␈↓ ↓}␈↓↓value␈↓¬((LABEL FF (LAMBDA (X) (COND ((ATOM X) X) ((QUOTE T) (FF (CAR X))))))
␈↓ ↓H␈↓ ¬↔␈↓¬(QUOTE ((A B) C)))␈↓↓ = ␈↓¬A␈↓↓.␈↓
␈↓ ↓H␈↓Thus␈α⊂␈↓¬((LABEL␈α∂FF␈α⊂(LAMBDA␈α∂(X)␈α⊂(COND␈α∂((ATOM␈α⊂X)␈α∂X)␈α⊂((QUOTE␈α∂T)␈α⊂(FF␈α∂(CAR␈α⊂X))))))␈↓,␈α⊂is␈α∂the
␈↓ ↓H␈↓LISP␈α
name␈αof␈α
a␈αfunction␈α
␈↓↓ff␈↓␈αsuch␈α
that␈α␈↓↓ff e␈↓␈α
is␈αthe␈α
first␈αatom␈α
in␈αthe␈α
written␈αform␈α
of␈α␈↓↓e.␈↓␈α
Note␈αthat␈α
the
␈↓ ↓H␈↓list ␈↓↓ff␈↓ is substituted for the atom ␈↓¬FF ␈↓twice in the course of evaluating the above expression.
␈↓ ↓H␈↓Difficult mathematical type exercise: Find a list ␈↓↓e␈↓ such that ␈↓↓value e = e␈↓.
␈↓ ↓H␈↓ You␈αmay␈α
now␈αprogram␈αin␈α
LISP.␈α Call␈αLISP␈α
system␈αon␈αa␈α
time-sharing␈αcomputer,␈αtype␈α
in␈αa
␈↓ ↓H␈↓list, and LISP will type back its value.
␈↓ ↓H␈↓2. ␈↓αSome Useful Abbreviations.␈↓
␈↓ ↓H␈↓ The above LISP needs some abbreviations for practical use.
␈↓ ↓H␈↓1.␈αSo␈αas␈αnot␈αto␈αdescribe␈αa␈αLISP␈αfunction␈αeach␈αtime␈αit␈αis␈αused,␈αwe␈αdefine␈αit␈αpermanently␈αby␈αtyping
␈↓ ↓H␈↓␈↓↓(␈↓¬DEFUN␈α⊂␈↓↓f (v␈↓β1␈↓↓ ... v␈↓βn␈↓↓) e)␈↓.␈α∂ Thereafter␈α⊂␈↓↓(f e␈↓β1␈↓↓ ... e␈↓βn␈↓↓)␈↓␈α∂is␈α⊂evaluated␈α∂by␈α⊂evaluating␈α∂␈↓↓e␈↓␈α⊂with␈α⊂the␈α∂variables
␈↓ ↓H␈↓␈↓↓v␈↓β1␈↓↓, ... ,v␈↓βn␈↓↓␈↓␈α→taking␈α→the␈α→values␈α→␈↓↓value e␈↓β1␈↓↓, ... ,value e␈↓βn␈↓↓␈↓␈α→respectively.␈α→ Thus,␈α→after␈α→we␈α→define
␈↓ ↓H␈↓␈↓¬(DEFUN FF (X) (COND ((ATOM X) X) ((QUOTE T) (FF (CAR X)))))␈↓,␈α?␈α?␈α?␈α<typing
␈↓ ↓H␈↓␈↓¬(FF (QUOTE ((A B) C)))␈↓, gets ␈↓¬A␈↓ from LISP.
␈↓ ↓H␈↓2.␈αThe␈αvariables␈α␈↓¬T␈↓␈αand␈α␈↓¬NIL␈↓␈αare␈αpermanently␈αassigned␈αthe␈αvalues␈α␈↓¬T␈↓␈αand␈α␈↓¬NIL␈↓,␈αand␈α␈↓¬NIL␈↓␈αis␈αthe␈αname
␈↓ ↓H␈↓of␈α2the␈α2null␈α2list␈α2().␈α2 Therefore,␈α2the␈α2above␈α2definition␈α2can␈α2be␈α2written
␈↓ ↓H␈↓␈↓¬(DEFUN FF (X) (COND ((ATOM X) X) (T (FF (CAR X)))))␈↓.
␈↓ ↓H␈↓3. We have the permanent function definitions
␈↓ ↓H␈↓ ␈↓¬(DEFUN NULL (X) (EQUAL X NIL))␈↓ and ␈↓¬(DEFUN CADR (X) (CAR (CDR X)))␈↓,
␈↓ ↓H␈↓and similarly for arbitrary combinations of ␈↓¬A␈↓ and ␈↓¬D␈↓.
␈↓ ↓H␈↓4. ␈↓↓(␈↓¬LIST ␈↓↓e␈↓β1␈↓↓ ... e␈↓βn␈↓↓)␈↓ is defined for each ␈↓↓n␈↓ to be ␈↓↓(␈↓¬CONS ␈↓↓e␈↓β1␈↓↓ (␈↓¬CONS ␈↓↓... (␈↓¬CONS ␈↓↓e␈↓βn␈↓↓ ␈↓¬NIL␈↓↓)))␈↓.
␈↓ ↓H␈↓5.␈α␈↓↓(␈↓¬AND␈α␈↓↓p␈αq)␈↓␈αabbreviates␈α␈↓↓(␈↓¬COND␈α␈↓↓(p q) (␈↓¬T␈↓↓ ␈↓¬NIL␈↓↓))␈↓.␈α ␈↓¬AND␈↓s␈αwith␈αmore␈αterms␈αare␈αdefined␈αsimilarly,␈αand␈α
the
␈↓ ↓H␈↓propositional connectives ␈↓¬OR␈↓ and ␈↓¬NOT␈↓ abbreviate similar conditional expressions.
␈↓ ↓H␈↓ Now we can give some further examples of LISP function definitions:
␈↓ ↓H␈↓␈↓¬(DEFUN␈α∃ALT␈α⊗(X)␈α∃(COND␈α∃((OR␈α⊗(NULL␈α∃X)␈α∃(NULL␈α⊗(CDR␈α∃X)))␈α∃X)␈α⊗(T␈α∃(CONS␈α∃(CAR␈α⊗X)␈α∃(ALT
␈↓ ↓H␈↓¬(CDDR X))))))␈↓
␈↓ ↓H␈↓defines␈α∂a␈α∂function␈α∂that␈α∂gives␈α∂alternate␈α∂elements␈α∂of␈α∂a␈α∂list␈α∂starting␈α∂with␈α∂the␈α∂first␈α⊂element.␈α∂ Thus
␈↓ ↓H␈↓␈↓¬(ALT (QUOTE (A B C D E)))␈↓ = ␈↓¬(A C E)␈↓.
␈↓ ↓H␈↓␈↓ ε¬Section II␈↓ 97
␈↓ ↓H␈↓ ␈↓¬(DEFUN SUBST (X Y Z) (COND ((ATOM Z) (COND ((EQUAL Z Y) X) (T Z)))␈↓
␈↓ ↓H␈↓ ␈↓¬(T (CONS (SUBST X Y (CAR Z)) (SUBST X Y (CDR Z))))))␈↓
␈↓ ↓H␈↓gives the result of substituting ␈↓¬X␈↓ for ␈↓¬Y␈↓ in ␈↓¬Z␈↓. Thus
␈↓ ↓H␈↓ ␈↓¬(SUBST␈α⊂(QUOTE␈α⊂(PLUS␈α⊂X␈α⊂Y))␈α⊂(QUOTE␈α⊂V)␈α⊂(QUOTE␈α⊂(TIMES␈α⊂X␈α⊂V)))␈↓␈α⊂=␈α⊂␈↓¬(TIMES␈α⊂X␈α⊂(PLUS␈α⊂X
␈↓ ↓H␈↓¬Y))␈↓.
␈↓ ↓H␈↓8␈↓ εH␈↓ H
␈↓ ↓H␈↓α␈↓ ¬}Section III
␈↓ ↓H␈↓α␈↓ ¬%INPUT AND OUTPUT
␈↓ ↓H␈↓ There␈α∩are␈α∪three␈α∩components␈α∩to␈α∪Input␈α∩and␈α∪Output␈α∩in␈α∩MACLISP.␈α∪ First␈α∩are␈α∪the␈α∩basic
␈↓ ↓H␈↓functions␈α∞which␈α∂read␈α∞and␈α∂print.␈α∞ Some␈α∂of␈α∞these␈α∂deal␈α∞with␈α∂S-expressions,␈α∞others␈α∂with␈α∞charaters.
␈↓ ↓H␈↓There␈αare␈α
also␈αfunctions␈αto␈α
do␈αconversions␈α
between␈αcharacters␈αand␈α
ASCII␈αcode.␈α
Second␈αthere␈αis␈α
a
␈↓ ↓H␈↓collection␈α⊃of␈α⊂switches␈α⊃which␈α⊃can␈α⊂be␈α⊃turned␈α⊃on␈α⊂or␈α⊃off␈α⊃to␈α⊂control␈α⊃the␈α⊃source␈α⊂of␈α⊃input␈α⊃and␈α⊂the
␈↓ ↓H␈↓destinations␈α
of␈α
output.␈α
Typically␈αthe␈α
input␈α
source␈α
is␈α
either␈αthe␈α
terminal␈α
or␈α
the␈α
currently␈αopened
␈↓ ↓H␈↓file.␈α⊂ Output␈α∂can␈α⊂go␈α∂to␈α⊂the␈α∂terminal,␈α⊂the␈α∂currently␈α⊂opened␈α∂file,␈α⊂or␈α∂both.␈α⊂ Finally␈α∂there␈α⊂are␈α∂the
␈↓ ↓H␈↓functions that select, open and close files.
␈↓ ↓H␈↓1. ␈↓αBasic I/O functions.␈↓
␈↓ ↓H␈↓␈↓¬(READ)␈α␈↓reads␈αone␈αS-expression,␈αwhich␈αis␈αeither␈αa␈αlist␈α enclosed␈α in␈α matching␈αparentheses␈α or␈α an
␈↓ ↓H␈↓␈↓ αλatom␈α⊂ delimited␈α⊂ by␈α⊂a␈α⊃special␈α⊂character␈α⊂such␈α⊂as␈α⊂a␈α⊃space␈α⊂or␈α⊂a␈α⊂parenthesis.␈α⊃(A␈α⊂parenthesis
␈↓ ↓H␈↓␈↓ αλwould␈α
be␈α
saved␈α∞up␈α
and␈α
used␈α
on␈α∞the␈α
next␈α
call␈α
to␈α∞␈↓¬READ.)␈α
␈↓␈α
␈↓¬READ␈α
␈↓returns␈α∞the␈α
S-expression
␈↓ ↓H␈↓␈↓ αλwhich␈αit␈αread,␈αconverting␈αit␈αfrom␈αthe␈αexternal␈αrepresentation␈αas␈αcharacters␈α to␈α LISP␈αinternal
␈↓ ↓H␈↓␈↓ αλform.␈α∞ When␈α
reading␈α∞from␈α
a␈α∞file,␈α
providing␈α∞an␈α
argument␈α∞to␈α
␈↓¬READ␈α∞␈↓␈α
causes␈α∞it␈α
to␈α∞return␈α
the
␈↓ ↓H␈↓␈↓ αλvalue␈α
of␈αthat␈α
argument␈αwhen␈α
the␈αend-of-file␈α
is␈αreached␈α
(unless␈αyou␈α
have␈αspecified␈α
a␈αfancy
␈↓ ↓H␈↓␈↓ αλeof␈α
function).␈α
If␈α
no␈α
argument␈αis␈α
provided,␈α
it␈α
closes␈α
the␈αfile␈α
and␈α
patiently␈α
waits␈α
for␈αinput␈α
from
␈↓ ↓H␈↓␈↓ αλthe terminal.
␈↓ ↓H␈↓␈↓¬(READCH) ␈↓ like read, but reads in one character and returns it as a character object.
␈↓ ↓H␈↓␈↓¬(TYI)␈α∪␈↓reads␈α∪in␈α∩one␈α∪character␈α∪and␈α∩returns␈α∪ a␈α∪ number␈α∩ which␈α∪ is␈α∪ the␈α∩ASCII␈α∪code␈α∪for␈α∩the
␈↓ ↓H␈↓␈↓ αλcharacter.
␈↓ ↓H␈↓␈↓¬(PRINT x)␈α∞␈↓prints␈α
out␈α∞the␈α
S-expression␈α∞␈↓¬x␈α
␈↓in␈α∞a␈α
form␈α∞which␈α
is␈α∞readable␈α
by␈α∞ humans␈α∞ but␈α
which
␈↓ ↓H␈↓␈↓ αλcould␈α also␈α be␈α read␈αback␈αinto␈αLISP␈αif␈αit␈αwere␈αprinted␈αto␈αa␈αfile␈αrather␈αthan␈αto␈α
the␈αterminal.
␈↓ ↓H␈↓␈↓ αλThe␈α∂expression␈α∂printed␈α∞out␈α∂is␈α∂preceded␈α∞by␈α∂a␈α∂newline␈α∞and␈α∂followed␈α∂by␈α∞a␈α∂space.␈α∂ If␈α∞special
␈↓ ↓H␈↓␈↓ αλcharacters␈α⊂or␈α∂strings␈α⊂of␈α⊂characters␈α∂are␈α⊂used␈α∂with␈α⊂other␈α⊂than␈α∂their␈α⊂ normal␈α⊂meanings,␈α∂ for
␈↓ ↓H␈↓␈↓ αλexample␈α
if␈α a␈α
parenthesis␈α
appears␈αin␈α
the␈α
pname␈αof␈α
an␈α
atom,␈αthey␈α
are␈α
preceded␈αand␈α
followed
␈↓ ↓H␈↓␈↓ αλby "|" so that the output could be read back in.
␈↓ ↓H␈↓␈↓¬(PRIN1 x)␈α⊂␈↓is␈α⊂the␈α⊃same␈α⊂as␈α⊂␈↓¬(PRINT x)␈α⊃␈↓except␈α⊂that␈α⊂the␈α⊂leading␈α⊃newline␈α⊂and␈α⊂trailing␈α⊃space␈α⊂are
␈↓ ↓H␈↓␈↓ αλomitted.␈α
␈↓¬PRIN1␈α∞␈↓can␈α
be␈α∞used␈α
to␈α
print␈α∞ multiple␈α
items␈α∞ on␈α
a␈α
line,␈α∞but␈α
spacing␈α∞between␈α
the
␈↓ ↓H␈↓␈↓ αλitems must be provided for explicitly, for example by evaluating ␈↓¬(TYO 40)␈↓.
␈↓ ↓H␈↓␈↓¬(PRINC x)␈α⊃␈↓is␈α⊃like␈α⊃␈↓¬(PRIN1 x)␈α⊃␈↓except␈α⊃that␈α∩special␈α⊃characters␈α⊃or␈α⊃strings␈α⊃of␈α⊃characters␈α∩are␈α⊃ not
␈↓ ↓H␈↓␈↓ αλsurrounded␈α∂by␈α∂"|".␈α∂ This␈α∞makes␈α∂the␈α∂output␈α∂more␈α∞pleasing␈α∂in␈α∂certain␈α∂situations,␈α∂however␈α∞it
␈↓ ↓H␈↓␈↓ αλcannot be read back into LISP.
␈↓ ↓H␈↓␈↓¬(TERPRI) ␈↓types out a newline.
␈↓ ↓H␈↓␈↓¬(TYO n)␈α
␈↓outputs␈αa␈α
character␈αwhose␈α
ASCII␈α
code␈αis␈α
given␈αby␈α
the␈α
number␈α␈↓¬n.␈α
␈↓␈α␈↓¬PRINC␈α
␈↓may␈α
also␈αbe
␈↓ ↓H␈↓␈↓ αλused to output character objects.
␈↓ ↓H␈↓␈↓ ¬␈Section III␈↓ 99
␈↓ ↓H␈↓ As␈α
an␈α∞example␈α
of␈α∞how␈α
some␈α∞of␈α
these␈α
reading␈α∞and␈α
printing␈α∞functions␈α
can␈α∞be␈α
used␈α∞here␈α
is
␈↓ ↓H␈↓part␈α∞of␈α∞a␈α∞program␈α∞that␈α∂is␈α∞used␈α∞as␈α∞a␈α∞self-documentation␈α∂feature␈α∞in␈α∞a␈α∞larger␈α∞ system.␈α∂ When␈α∞the
␈↓ ↓H␈↓system␈α∞is␈α
loaded␈α∞it␈α
prints␈α∞a␈α
message␈α∞telling␈α
the␈α∞user␈α
to␈α∞type␈α
␈↓¬(BBHELP)␈α∞␈↓for␈α∞information.␈α
␈↓¬BBHELP
␈↓ ↓H␈↓¬␈↓prints␈αout␈αa␈αmessage␈α
explaining␈αitself␈αthen␈αdoes␈αa␈α
␈↓¬READ.␈α␈↓␈αIf␈αthe␈αuser␈α
then␈αtypes␈αone␈αof␈α
the␈αtopic
␈↓ ↓H␈↓names␈αthe␈α
appropriate␈αmessage␈α
is␈αprinted␈αotherwise␈α
an␈αerror␈α
message␈αis␈α
printed.␈α The␈α"|"s␈α
around
␈↓ ↓H␈↓each␈αline␈αof␈αthe␈αmessage␈αtell␈αLISP␈αthat␈αthis␈αis␈αreally␈αa␈αsingle␈αatom.␈α␈↓¬PRINC␈α␈↓prints␈αit␈αas␈αa␈αcharacter
␈↓ ↓H␈↓string omitting the "|" delimeters. ␈↓¬PRINT ␈↓would retain the "|"s.
␈↓ ↓H␈↓¬ (DEFUN BBHELP ()
␈↓ ↓H␈↓¬ (PROG (TOPIC)
␈↓ ↓H␈↓¬ (BBMSG)
␈↓ ↓H␈↓¬ HELP
␈↓ ↓H␈↓¬ (SETQ TOPIC (READ))
␈↓ ↓H␈↓¬ (COND ((EQ TOPIC 'HELP) (BBHELPER))
␈↓ ↓H␈↓¬ ((EQ TOPIC 'SYNTAX) (BBSYNHELPER))
␈↓ ↓H␈↓¬ ((EQ TOPIC 'PUB) (BBPUBHELPER))
␈↓ ↓H␈↓¬ ((EQ TOPIC 'LPT) (BBLPTHELPER))
␈↓ ↓H␈↓¬ ((EQ TOPIC 'TXT) (BBTXTHELPER))
␈↓ ↓H␈↓¬ ((EQ TOPIC 'EXIT) (RETURN 'Bye))
␈↓ ↓H␈↓¬ (T (BBERRHELPER TOPIC)))
␈↓ ↓H␈↓¬ (GO HELP)))
␈↓ ↓H␈↓¬ (DEFUN BBMSG ()
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (PRINC '|The BB programs convert a list of atoms having |)
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (PRINC '|EXPR FEXPR or VALUE properties to an external form.|)
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (PRINC '|Type HELP to get a list of BBHELP topics|)
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (PRINC '|Type EXIT to get out of BBHELP|)
␈↓ ↓H␈↓¬ (TERPRI))
␈↓ ↓H␈↓2. ␈↓αSpecifying the Source or Destination for I/O.␈↓
␈↓ ↓H␈↓ When␈α⊃ an␈α⊃I/O␈α⊃function␈α⊃is␈α⊂called,␈α⊃the␈α⊃source␈α⊃from␈α⊃which␈α⊃it␈α⊂is␈α⊃to␈α⊃take␈α⊃its␈α⊃input␈α⊃or␈α⊂the
␈↓ ↓H␈↓destinations␈α∞ on␈α∞which␈α∞it␈α∞ is␈α∞ to␈α∞ put␈α∞its␈α∞ output␈α∞are␈α∞determined␈α∞by␈α∞the␈α∞values␈α∞of␈α∞certain␈α
global
␈↓ ↓H␈↓variables␈α∩called␈α∩switches.␈α∩ The␈α∩I/O␈α⊃switches␈α∩are␈α∩␈↓¬↑Q,␈α∩␈↓␈↓¬↑R,␈α∩␈↓and␈α⊃␈↓¬↑W.␈α∩␈↓␈α∩These␈α∩switches␈α∩may␈α⊃be
␈↓ ↓H␈↓␈↓¬SETQ␈↓ed,␈αlambda␈αbound,␈αor␈αset␈αusing␈αthe␈α␈↓¬IOC␈α␈↓function␈αas␈αdescribed␈αbelow.␈α The␈αswitches␈αhave␈αthe
␈↓ ↓H␈↓following interpretation:
␈↓ ↓H␈↓␈↓¬↑Q␈↓ If␈α
the␈α
value␈α
of␈α∞␈↓¬↑Q␈α
␈↓is␈α
␈↓¬T␈↓,␈α
the␈α
input␈α∞is␈α
taken␈α
from␈α
the␈α
currently␈α∞open␈α
file.␈α
If␈α
␈↓¬↑Q␈α
␈↓is␈α∞␈↓¬NIL␈↓,␈α
the
␈↓ ↓H␈↓␈↓ αλdefault␈α
input␈αis␈α
taken␈αfrom␈α
the␈αthe␈α
terminal.␈α Thus␈α
if␈αthere␈α
is␈αan␈α
open␈αfile␈α
and␈αyou␈α
set␈α␈↓¬↑Q␈α
␈↓to
␈↓ ↓H␈↓␈↓ αλ␈↓¬T␈↓ then LISP will read and eval each S-expression in that file.
␈↓ ↓H␈↓␈↓¬↑R␈↓ If␈α the␈α value␈α of␈α␈↓¬↑R␈α␈↓is␈α␈↓¬T␈↓,␈αthe␈αoutput␈αdestinations␈αinclude␈αthe␈αcurrently␈αopen␈αfile.␈α If␈αit␈αis␈α␈↓¬NIL␈↓
␈↓ ↓H␈↓␈↓ αλthe output does not go to the currently open file.
␈↓ ↓H␈↓␈↓¬↑W␈↓ If␈αthe␈αvalue␈αof␈α␈↓¬↑W␈α␈↓is␈α
␈↓¬T␈↓,␈αthe␈αoutput␈αdestinations␈αdo␈αnot␈α
include␈α the␈αterminal.␈α If␈αit␈αis␈α␈↓¬NIL␈↓␈α
then
␈↓ ↓H␈↓␈↓ αλoutput will go to the terminal.
␈↓ ↓H␈↓10␈↓ ¬␈Section III␈↓ H
␈↓ ↓H␈↓ The␈α
␈↓¬IOC␈α
␈↓function␈αcan␈α
be␈α
used␈αto␈α
set␈α
switches.␈α It␈α
has␈α
the␈αbasic␈α
form␈α
␈↓¬(IOC␈α<character>)␈↓.
␈↓ ↓H␈↓For I/O switches the following characters are relevant:
␈↓ ↓H␈↓␈↓¬Q␈↓ Sets the switch ␈↓¬↑Q ␈↓to ␈↓¬T␈↓ this enabling input from the file that is currently open.
␈↓ ↓H␈↓␈↓¬R␈↓ Sets the switch ␈↓¬↑R ␈↓to ␈↓¬T␈↓ enabling output to the currently open file.
␈↓ ↓H␈↓␈↓¬S␈↓ Sets the switch ␈↓¬↑Q ␈↓to ␈↓¬NIL␈↓ enabling input from the terminal.
␈↓ ↓H␈↓␈↓¬T␈↓ Sets the switch ␈↓¬↑R ␈↓to ␈↓¬NIL␈↓ disabling output to a file.
␈↓ ↓H␈↓␈↓¬V␈↓ Sets the switch ␈↓¬↑W ␈↓to ␈↓¬NIL␈↓ enabling output to the terminal.
␈↓ ↓H␈↓␈↓¬W␈↓ Sets the switch ␈↓¬↑W ␈↓to ␈↓¬T␈↓ disabling output to the terminal.
␈↓ ↓H␈↓ Typing␈α∞<control><char>␈α
at␈α∞the␈α∞terminal␈α
has␈α∞the␈α∞same␈α
effect␈α∞as␈α∞evaluating␈α
␈↓¬(IOC <char>)␈↓.
␈↓ ↓H␈↓The␈α⊃file␈α∩closing␈α⊃functions␈α∩reset␈α⊃some␈α⊃of␈α∩the␈α⊃switches.␈α∩ For␈α⊃example␈α⊃after␈α∩reading␈α⊃all␈α∩the␈α⊃S-
␈↓ ↓H␈↓expressions␈αin␈αa␈αfile,␈αLISP␈α
closes␈αthe␈αfile␈αand␈αenables␈α
input␈αfrom␈αthe␈αterminal.␈α When␈α
an␈αoutput
␈↓ ↓H␈↓file is closed the ␈↓¬↑R ␈↓switch is reset to ␈↓¬NIL␈↓.
␈↓ ↓H␈↓3. ␈↓αFunctions for Selecting and Opening Files.␈↓
␈↓ ↓H␈↓ The␈α∂functions␈α⊂␈↓¬UREAD,␈α∂␈↓␈↓¬UWRITE,␈α⊂␈↓␈↓¬UAPPEND,␈α∂␈↓and␈α⊂␈↓¬UFILE␈α∂␈↓together␈α⊂with␈α∂certain␈α⊂␈↓¬STATUS␈α∂␈↓and
␈↓ ↓H␈↓␈↓¬SSTATUS␈α∂␈↓functions␈α∂comprise␈α∂the␈α∂file␈α∂handling␈α∂part␈α∂of␈α∂the␈α∂I/O␈α∂system␈α∂for␈α∂Stanford␈α∂versions␈α∂of
␈↓ ↓H␈↓MACLISP.
␈↓ ↓H␈↓ File names are represented by a 4-list of the form
␈↓ ↓H␈↓␈↓ ¬1(name1 name2 dev dir)
␈↓ ↓H␈↓Name1␈α⊃ and␈α⊂ name2␈α⊃ together␈α⊃ make␈α⊂ up␈α⊃ the␈α⊂"filename,"␈α⊃dev␈α⊃is␈α⊂the␈α⊃"device,"␈α⊂and␈α⊃dir␈α⊃is␈α⊂the
␈↓ ↓H␈↓"directory."␈α∂In␈α∞ the␈α∂ DEC-10␈α∞ implementation,␈α∂dev␈α∂is␈α∞the␈α∂device␈α∞name,␈α∂name1␈α∞is␈α∂the␈α∂file␈α∞name,
␈↓ ↓H␈↓name2␈α∀is␈α∀the␈α∀extension,␈α∀and␈α∀dir␈α∀is␈α∀a␈α∀list␈α∀ of␈α∀ two␈α∀fixnums,␈α∀ the␈α∀project␈α∀number␈α∀and␈α∪the
␈↓ ↓H␈↓programmer number.
␈↓ ↓H␈↓ The␈α∂system␈α∂maintains␈α∞a␈α∂ default␈α∂4-list.␈α∂ The␈α∞defaults␈α∂are␈α∂updated␈α∞every␈α∂time␈α∂one␈α∂of␈α∞the
␈↓ ↓H␈↓functions␈α⊂␈↓¬UREAD,␈α⊂␈↓␈↓¬UWRITE,␈α⊂␈↓␈↓¬UAPPEND,␈α⊂␈↓or␈α⊂␈↓¬UFILE␈α⊂␈↓is␈α⊂called,␈α⊂so␈α⊂ that␈α⊂the␈α⊂ defaults␈α⊂ correspond␈α∂to
␈↓ ↓H␈↓the␈α
last␈αfile␈α
that␈αwas␈α
used.␈α The␈α
defaults␈αmay␈α
be␈αexamined␈α
by␈α␈↓¬(STATUS CRFILE)␈↓,␈α
which␈αreturns
␈↓ ↓H␈↓the␈α
first␈α two␈α
elements␈α of␈α
the␈αdefault␈α
4-list,␈αand␈α
␈↓¬(STATUS CRUNIT)␈↓␈αwhich␈α
returns␈αthe␈α
last␈αtwo.
␈↓ ↓H␈↓It␈α∞is␈α∞not␈α∞necessary␈α∞to␈α∞specify␈α∞all␈α∞four␈α∞parts␈α∞ of␈α∞ the␈α∞ 4-list␈α∞when␈α∞ one␈α∞of␈α∞these␈α∞four␈α∞functions␈α
is
␈↓ ↓H␈↓used. Any omitted parts are taken from the defaults.
␈↓ ↓H␈↓ The␈α∃functions␈α∃ ␈↓¬UREAD,␈α∃␈↓␈↓¬UAPPEND,␈α∃␈↓␈↓¬UWRITE,␈α∃␈↓and␈α∃␈↓¬UFILE␈α∃␈↓are␈α∃ ␈↓¬FSUBR␈↓s␈α∃ which␈α∃ do␈α∃ not
␈↓ ↓H␈↓evaluate their arguments. They may be applied to a 4-list, e.g.
␈↓ ↓H␈↓␈↓ ∧(␈↓¬(APPLY 'UREAD '(FOO BAR DSK COMLAP))␈↓
␈↓ ↓H␈↓␈↓ ¬␈Section III␈↓ *11
␈↓ ↓H␈↓or␈α
they␈α
may␈α
be␈α
called␈α
with␈α
the␈α
4-list␈αas␈α
four␈α
arguments,␈α
which␈α
is␈α
convenient␈α
when␈α
calling␈αthem
␈↓ ↓H␈↓from top level.
␈↓ ↓H␈↓␈↓¬UREAD␈α␈↓␈αThis␈α function␈α selects␈α an␈α input␈α file.␈α The␈αargument␈αlist␈αis␈αa␈α4-list␈αas␈α
described␈α above.
␈↓ ↓H␈↓␈↓ αλThe␈α specified␈α
file␈α is␈α
made␈α the␈α
default␈α input␈α
source.␈α Note␈α
that␈α the␈α
␈↓¬↑Q␈α␈↓switch␈α
mst␈αbe
␈↓ ↓H␈↓␈↓ αλturned on before input will be automatically taken from this file.
␈↓ ↓H␈↓␈↓¬UWRITE/UAPPEND␈α∂␈↓␈α∂These␈α∂functions␈α⊂open␈α∂an␈α∂output␈α∂file.␈α∂ When␈α⊂done␈α∂ with␈α∂ this␈α∂ file,␈α⊂ ␈↓¬UFILE␈α∂␈↓
␈↓ ↓H␈↓␈↓ αλmust␈α∂ be␈α⊂ used␈α∂to␈α∂close␈α⊂it␈α∂and␈α∂give␈α⊂it␈α∂a␈α⊂name.␈α∂ In␈α∂the␈α⊂␈↓¬UWRITE␈α∂␈↓case␈α∂a␈α⊂new␈α∂file␈α⊂is␈α∂created
␈↓ ↓H␈↓␈↓ αλdestroying␈α
any␈α
oldfile␈α
of␈α
that␈α
name.␈α
In␈α
the␈αcase␈α
of␈α
␈↓¬UAPPEND␈α
␈↓the␈α
output␈α
is␈α
added␈α
on␈α
to␈αthe
␈↓ ↓H␈↓␈↓ αλend␈α
of␈α
and␈α
existing␈α
file.␈α The␈α
arguments␈α
are␈α
the␈α
last␈αtwo␈α
elements␈α
of␈α
a␈α
4-list,␈α specifying␈α
the
␈↓ ↓H␈↓␈↓ αλdevice␈α and␈αdirectory␈α on␈α which␈α the␈α file␈α is␈αto␈αbe␈αwritten.␈α The␈αfirst␈αtwo␈αparts␈αof␈αthe␈α4-list
␈↓ ↓H␈↓␈↓ αλare not specified until the file is ufile'd.
␈↓ ↓H␈↓␈↓¬UFILE␈α⊂␈↓␈α⊂␈↓¬(UFILE␈α∂name1␈α⊂name2)␈↓␈α⊂closes␈α⊂the␈α∂currently␈α⊂open␈α⊂output␈α⊂file␈α∂ and␈α⊂ gives␈α⊂ it␈α⊂the␈α∂ name
␈↓ ↓H␈↓␈↓ αλname1.name2. ␈↓¬(UFILE) ␈↓ takes name1 and name2 from the defaults.
␈↓ ↓H␈↓ The␈αfunctions␈α␈↓¬STATUS␈α␈↓AND␈α␈↓¬SSTATUS␈α␈↓examine␈αand␈αset␈αthe␈αstatus␈αof␈αsystem␈αvariables.␈α The
␈↓ ↓H␈↓relevant applications for I/O are the following.
␈↓ ↓H␈↓␈↓¬(STATUS␈α
CRUNIT)␈↓␈α
returns␈α
the␈α
current␈α
(default)␈α
device␈α
and␈α
directory.␈α
It␈α
returns␈α
␈↓¬NIL␈↓␈α
if␈α
none␈αhas
␈↓ ↓H␈↓␈↓ αλbeen set.
␈↓ ↓H␈↓␈↓¬(SSTATUS␈α⊗CRUNIT␈α⊗dev␈α⊗dir)␈↓␈α⊗sets␈α⊗the␈α⊗defaults␈α⊗for␈α⊗device␈α⊗and␈α⊗directory␈α⊗to␈α⊗␈↓¬dev␈α↔␈↓and␈α⊗␈↓¬dir
␈↓ ↓H␈↓¬␈↓ αλ␈↓respectively.
␈↓ ↓H␈↓␈↓¬(STATUS␈α
CRFILE)␈↓␈α∞returns␈α
the␈α∞current␈α
(default)␈α∞file␈α
name␈α
and␈α∞extension.␈α
It␈α∞returns␈α
␈↓¬NIL␈↓␈α∞if␈α
none
␈↓ ↓H␈↓␈↓ αλhas been set.
␈↓ ↓H␈↓␈↓¬(SSTATUS␈α∪CRFILE␈α∩nam␈α∪ext)␈↓␈α∩sets␈α∪the␈α∩defaults␈α∪for␈α∩file␈α∪name␈α∩and␈α∪extiosion␈α∩to␈α∪␈↓¬nam␈α∪␈↓and␈α∩␈↓¬ext
␈↓ ↓H␈↓¬␈↓ αλ␈↓respectively.
␈↓ ↓H␈↓␈↓¬(STATUS␈αUREAD)␈↓␈αreturns␈α
the␈α4-list␈αnaming␈αthe␈α
currently␈αopen␈αinput␈αfile.␈α
(As␈αset␈αby␈α
␈↓¬(UREAD␈αnam
␈↓ ↓H␈↓¬␈↓ αλext dev dir)␈↓).
␈↓ ↓H␈↓␈↓¬(SSTATUS UREAD nam ext dev dir)␈↓ has the same effect as ␈↓¬(UREAD nam ext dev dir)␈↓.
␈↓ ↓H␈↓␈↓¬(STATUS␈αUWRITE)␈↓␈αreturns␈αthe␈αdevice␈αand␈αdirectory␈αdefaults␈αfor␈αthe␈αcurrently␈αopen␈αoutput␈αfile␈α(As
␈↓ ↓H␈↓␈↓ αλset by ␈↓¬(UWRITE nam ext dev dir)␈↓).
␈↓ ↓H␈↓␈↓¬(SSTATUS UWRITE dev dir)␈↓ has the same effect as ␈↓¬(UWRITE dev dir)␈↓.
␈↓ ↓H␈↓ As␈α
an␈α
example␈α∞of␈α
how␈α
the␈α
file␈α∞selecting␈α
and␈α
opening␈α
functions␈α∞can␈α
be␈α
used␈α
we␈α∞give␈α
here
␈↓ ↓H␈↓two␈αprograms.␈α ␈↓¬TTYMSG␈α␈↓will␈αwrite␈αthe␈αmessage␈αgiven␈αit␈αas␈αan␈αargument␈αon␈αthe␈αterminal␈αno␈αmatter
␈↓ ↓H␈↓what␈α
the␈α
value␈α
of␈α
the␈α∞I/O␈α
switches␈α
are␈α
when␈α
it␈α
is␈α∞called.␈α
It␈α
saves␈α
the␈α
current␈α∞switches,␈α
disables
␈↓ ↓H␈↓output to a file and enables output to the terminal, ␈↓¬PRINT␈↓s the message then restores the switches.
␈↓ ↓H␈↓¬ (DEFPROP TTYMSG
␈↓ ↓H␈↓¬ (LAMBDA(MSG)
␈↓ ↓H␈↓¬ (PROG (CR CW) (SETQ CR ↑R CW ↑W)
␈↓ ↓H␈↓¬ (SETQ ↑R NIL ↑W NIL)
␈↓ ↓H␈↓12␈↓ ¬␈Section III␈↓ H
␈↓ ↓H␈↓¬ (PRINT MSG)
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (SETQ ↑R CR ↑W CW)))
␈↓ ↓H␈↓¬ EXPR)
␈↓ ↓H␈↓The␈αprogram␈α␈↓¬BB␈α␈↓is␈α
the␈αtop␈αlevel␈αof␈αa␈α
program␈αto␈αconvert␈αa␈α
list␈αof␈αfunction␈αdefinitions␈α to␈α
external
␈↓ ↓H␈↓form.␈α∞ A␈α∞typical␈α∞call␈α
to␈α∞␈↓¬BB␈α∞␈↓would␈α∞look␈α
like␈α∞␈↓¬(BB␈α∞LPT␈α∞'(BB)␈α
BBBB␈α∞OUT)␈↓.␈α∞ ␈↓¬LPT␈α∞␈↓specifies␈α∞a␈α
version
␈↓ ↓H␈↓of␈α∂external␈α∂form␈α∂suitable␈α∂for␈α∂printing␈α∂on␈α∂a␈α∞line␈α∂printer.␈α∂ ␈↓¬'(BB)␈α∂␈↓is␈α∂the␈α∂list␈α∂of␈α∂definitions␈α∂to␈α∞be
␈↓ ↓H␈↓printed.␈α⊂ In␈α⊂this␈α⊂case␈α⊂␈↓¬BB␈α⊂␈↓will␈α⊂print␈α⊂itself␈α⊂out.␈α⊂ The␈α⊂final␈α⊂two␈α⊂items␈α⊂specify␈α⊂the␈α⊂file␈α⊃name␈α⊂and
␈↓ ↓H␈↓extension␈α∂where␈α∞the␈α∂result␈α∞is␈α∂to␈α∞be␈α∂written.␈α∞ After␈α∂some␈α∞initialization␈α∂the␈α∞program␈α∂opens␈α∂a␈α∞file
␈↓ ↓H␈↓using␈α∞␈↓¬UWRITE.␈α∞␈↓␈α∂Since␈α∞no␈α∞arguments␈α∞are␈α∂provided␈α∞the␈α∞current␈α∞default␈α∂unit␈α∞is␈α∞assumed.␈α∂ It␈α∞then
␈↓ ↓H␈↓lambda␈α
binds␈α
␈↓¬↑R␈α
␈↓and␈α
␈↓¬↑W␈α
␈↓to␈α
␈↓¬T␈↓␈α
thus␈α∞disabling␈α
output␈α
to␈α
terminal␈α
and␈α
enabling␈α
output␈α
to␈α∞the␈α
file
␈↓ ↓H␈↓that␈αwas␈αopened.␈α It␈αthen␈αcalls␈αthe␈αappropriate␈αversion␈αof␈αthe␈αconverter␈αprogram␈α(which␈αdoes␈αthe
␈↓ ↓H␈↓printing).␈α⊂ Finally␈α⊂it␈α⊂closes␈α⊂the␈α∂file␈α⊂and␈α⊂pops␈α⊂out␈α⊂of␈α∂the␈α⊂lambda␈α⊂expression␈α⊂thus␈α⊂restoring␈α∂the
␈↓ ↓H␈↓switches␈α⊂to␈α⊂their␈α⊂initial␈α⊂values.␈α⊂ Before␈α⊂exiting␈α⊂it␈α⊂prints␈α⊂the␈α⊂current␈α⊂values␈α⊂of␈α⊂the␈α⊃device␈α⊂and
␈↓ ↓H␈↓directory␈α∂portions␈α∂of␈α∂the␈α∂default␈α∂file␈α∂name␈α∂list,␈α∂just␈α∂so␈α∂you␈α∂will␈α∂know␈α∂where␈α∂the␈α∂file␈α⊂has␈α∂been
␈↓ ↓H␈↓written.
␈↓ ↓H␈↓¬ (DEFUN BB FEXPR (SPECS)
␈↓ ↓H␈↓¬ ((LAMBDA (TERPRI BASE *NOPOINT)
␈↓ ↓H␈↓¬ (PROG (MODE ITEMS FILE BEGINLINE ENDLINE)
␈↓ ↓H␈↓¬ (SETQ MODE (CAR SPECS))
␈↓ ↓H␈↓¬ (SETQ ITEMS (CADR SPECS))
␈↓ ↓H␈↓¬ (SETQ FILE (CDDR SPECS))
␈↓ ↓H␈↓¬ (COND ((EQ MODE 'PUB) (SETQ BEGINLINE '⊗⊗ ENDLINE '⊗))
␈↓ ↓H␈↓¬ (T (SETQ BEGINLINE '/ ENDLINE '/ )))
␈↓ ↓H␈↓¬ (UWRITE)
␈↓ ↓H␈↓¬ ((LAMBDA (↑R ↑W)
␈↓ ↓H␈↓¬ (COND ((EQ MODE 'LPT) (EVAL (LIST 'BBMCLLPT ITEMS)))
␈↓ ↓H␈↓¬ ((EQ MODE 'PUB) (EVAL (LIST 'BBMCLPUB ITEMS)))
␈↓ ↓H␈↓¬ ((EQ MODE 'TXT) (EVAL (LIST 'BBMCLTXT ITEMS)))
␈↓ ↓H␈↓¬ (T (TTYMSG 'INVALID_MODE)))
␈↓ ↓H␈↓¬ (TERPRI)
␈↓ ↓H␈↓¬ (APPLY 'UFILE FILE)) T T)
␈↓ ↓H␈↓¬ (PRINT (STATUS CRUNIT))))
␈↓ ↓H␈↓¬ T 10. T))
␈↓ ↓H␈↓␈↓ εH␈↓ *13
␈↓ ↓H␈↓α␈↓ εSection IV
␈↓ ↓H␈↓α␈↓ ¬=THE LISP EDITOR
␈↓ ↓H␈↓ The␈α∞ LISP␈α∞Editor␈α∞was␈α∂written␈α∞by␈α∞R.P.Gabriel␈α∞and␈α∞T.Finin.␈α∂ It␈α∞is␈α∞a␈α∞structural␈α∂editor␈α∞that
␈↓ ↓H␈↓runs␈α∞in␈α∞the␈α∞MACLISP␈α∞interpreter.␈α∞ You␈α∞may␈α
edit␈α∞functions␈α∞that␈α∞are␈α∞currently␈α∞defined␈α∞or␈α∞get␈α
a
␈↓ ↓H␈↓function␈α⊂from␈α⊂a␈α⊂file␈α∂to␈α⊂edit.␈α⊂ Editing␈α⊂is␈α⊂done␈α∂by␈α⊂manipulating␈α⊂subexpressions␈α⊂of␈α⊂the␈α∂defining
␈↓ ↓H␈↓expression␈α∩for␈α∩the␈α∪function.␈α∩ The␈α∩editor␈α∪knows␈α∩about␈α∩a␈α∩top␈α∪level␈α∩expression␈α∩and␈α∪a␈α∩current
␈↓ ↓H␈↓expression␈α
(CE).␈α
Initially␈α
they␈α
are␈α
the␈α
same.␈α The␈α
current␈α
expression␈α
is␈α
a␈α
list.␈α
You␈α
can␈αchange,
␈↓ ↓H␈↓add,␈α⊂or␈α⊂delete␈α⊂elements␈α⊂of␈α⊂the␈α⊂list,␈α⊂move␈α⊂parentheses␈α⊂in␈α⊂and␈α⊂out␈α⊂to␈α⊂change␈α⊂the␈α⊂subexpression
␈↓ ↓H␈↓structure, or change the CE by moving up, down or sideways within the toplevel expression.
␈↓ ↓H␈↓1. ␈↓αHow to Use the LISP Editor.␈↓
␈↓ ↓H␈↓ The␈α∂following␈α∂is␈α∂taken␈α∂from␈α∂the␈α∂online␈α∂documentation␈α∂of␈α∂the␈α∂LISP␈α∂editor␈α∂at␈α⊂the␈α∂Stanford
␈↓ ↓H␈↓University AI Lab.
␈↓ ↓H␈↓ The following is a very brief introduction to the use
␈↓ ↓H␈↓ of the LISP Editor.
␈↓ ↓H␈↓ Loading the Editor
␈↓ ↓H␈↓ ------- --- ------
␈↓ ↓H␈↓ 1). To run the LISP Editor, one simply types (EDIT)
␈↓ ↓H␈↓ or (EDIT FOO) to edit the in-core function "FOO" or
␈↓ ↓H␈↓ (EDIT FOO FOO BAR DSK (COM RPG)) to edit the function
␈↓ ↓H␈↓ "FOO" in file FOO.BAR in the directory of COM,RPG.
␈↓ ↓H␈↓ 2). (EDIT) or (EDIT FOO) or (EDIT FOO FOO BAR) or (EDIT FOO
␈↓ ↓H␈↓ FOO BAR DSK (COM RPG)) can be done in LISP's that have
␈↓ ↓H␈↓ an autoload property for EDIT. Typing (EDIT) causes the
␈↓ ↓H␈↓ Editor to be initialized and entered. (EDIT1 <exp>) will make
␈↓ ↓H␈↓ <exp> the toplevel editable expression. (EDIT2 <var>) will
␈↓ ↓H␈↓ make (PROG2 (SETQ <var> <current value of var>) T) the
␈↓ ↓H␈↓ toplevel while (EDIT2 (GET <var> <indicator>)) will make it:
␈↓ ↓H␈↓ (DEFPROP <var> <value> <indicator>).
␈↓ ↓H␈↓ 3). (EDITV <atom>) edits the value of <atom>; the editted expression
␈↓ ↓H␈↓ is actually (prog1 (setq <atom> <value of atom>) t).
␈↓ ↓H␈↓ 4). (EDITP <atom> <prop>) edits the <prop> property of <atom>; the
␈↓ ↓H␈↓ actual editted expression is (defprop <atom> <value> <prop>).
␈↓ ↓H␈↓ How to Look at the Current Expression (CE)
␈↓ ↓H␈↓ --- -- ---- -- --- ------- ---------- --
␈↓ ↓H␈↓14␈↓ ¬}Section IV␈↓ H
␈↓ ↓H␈↓ P prints the CE using the current print depth
␈↓ ↓H␈↓ (sublist cutoff) and print length (length cutoff)
␈↓ ↓H␈↓ PP pretty-prints the entire CE
␈↓ ↓H␈↓ PS pretty-prints the CE using the print depth cutoff
␈↓ ↓H␈↓ W prints the "window" surrounding the CE. Thus if
␈↓ ↓H␈↓ window size is 2, it prints the 2 preceeding and 2 following
␈↓ ↓H␈↓ tokens around the CE, where "token" means expression or
␈↓ ↓H␈↓ parenthesis.
␈↓ ↓H␈↓ (WINDOW n)
␈↓ ↓H␈↓ changes the window size to n.
␈↓ ↓H␈↓ (PL n) changes the print length to n (initially 5)
␈↓ ↓H␈↓ (PD n) changes the print depth to n (initially 2)
␈↓ ↓H␈↓ Changing the CE
␈↓ ↓H␈↓ -------- --- --
␈↓ ↓H␈↓ (CR E1...En) changes the CE to E1...En (i.e. splices in
␈↓ ↓H␈↓ E1...En), and makes the CE E1.
␈↓ ↓H␈↓ (n E1...En) n>0, changes the n-th element of the CE to
␈↓ ↓H␈↓ E1...En
␈↓ ↓H␈↓ (n E1...En) n<0 changes the n-th element of the CE from the
␈↓ ↓H␈↓ end to E1...En
␈↓ ↓H␈↓ (n) n>0 deletes the n-th element of the CE
␈↓ ↓H␈↓ (n) n<0, deletes the n-th element from the end
␈↓ ↓H␈↓ RI moves the right parenthesis in one expression
␈↓ ↓H␈↓ RO moves the right parenthesis out one expression
␈↓ ↓H␈↓ LI similar to RI
␈↓ ↓H␈↓ LO similar to RO
␈↓ ↓H␈↓ DELETE deletes the CE (if the CE is the toplevel
␈↓ ↓H␈↓ expression, the Editor assumes that the user
␈↓ ↓H␈↓ wants to edit a different function and requests:
␈↓ ↓H␈↓ (function name <file specifications>):
␈↓ ↓H␈↓ The answer can be of several forms; examples:
␈↓ ↓H␈↓ 1) FOO - loads FOO from core
␈↓ ↓H␈↓ 2) (FOO FOO BAR) - loads FOO from FOO.BAR
␈↓ ↓H␈↓ 3) (FOO BAR DSK (COM RPG)) - loads FOO from FOO.BAR in
␈↓ ↓H␈↓ the directory of COM,RPG.
␈↓ ↓H␈↓ 4) NEW - gives a fresh top-level expression
␈↓ ↓H␈↓ 5) cntrl-G - quits back to the Editor command decoder
␈↓ ↓H␈↓ 6) UNDO - <see below>.
␈↓ ↓H␈↓ Moving around within the Expression
␈↓ ↓H␈↓ ------ ------ ------ --- ----------
␈↓ ↓H␈↓ n n>0 makes the new CE the n-th element of the CE
␈↓ ↓H␈↓ n n<0, makes the new CE the n-th element from the end
␈↓ ↓H␈↓ of the CE
␈↓ ↓H␈↓␈↓ ¬}Section IV␈↓ *15
␈↓ ↓H␈↓ ↑ makes the CE the immediate parent of the CE
␈↓ ↓H␈↓ TOP makes the CE the toplevel expression
␈↓ ↓H␈↓ NX makes the CE the next one after the CE
␈↓ ↓H␈↓ BK makes the CE the one before the CE
␈↓ ↓H␈↓ MARK marks the current location so that it can be JUMPed
␈↓ ↓H␈↓ to by the command JUMP. Note: MARKing and JUMPing
␈↓ ↓H␈↓ is not guaranteed to work in all cases, since
␈↓ ↓H␈↓ modification of the thing being edited can render
␈↓ ↓H␈↓ the MARK meaningless.
␈↓ ↓H␈↓ JUMP jumps to the last MARKed location
␈↓ ↓H␈↓ UNMARK forgets where the last MARK was set (speeds
␈↓ ↓H␈↓ execution)
␈↓ ↓H␈↓ Adding Expressions
␈↓ ↓H␈↓ ------ -----------
␈↓ ↓H␈↓ (A n E1...En) puts E1...En after the n-th element of the CE
␈↓ ↓H␈↓ (B n E1...En) puts E1...En before the n-th element of the CE
␈↓ ↓H␈↓ (AI E1...En) puts E1...En after the CE and makes E1 the new CE
␈↓ ↓H␈↓ (BI E1...En) puts E1...En before the CE and makes E1 the new CE
␈↓ ↓H␈↓ (R exp1 exp2) replaces all occurrences of exp1 with exp2 in the CE, viewed
␈↓ ↓H␈↓ as a list, returns nil? if no occurrences found
␈↓ ↓H␈↓ (TR exp1 exp2)replaces all occurrences of exp1 with exp2 in the CE, viewed
␈↓ ↓H␈↓ as a tree
␈↓ ↓H␈↓ Finding Expressions (i.e. changing the CE)
␈↓ ↓H␈↓ ------- ----------- --- -------- --- --
␈↓ ↓H␈↓ (F pat) finds the next occurrence of pat, searching in
␈↓ ↓H␈↓ print order
␈↓ ↓H␈↓ (BF pat) finds the next occurrence of pat, searching in
␈↓ ↓H␈↓ inverse print order
␈↓ ↓H␈↓ (F pat T) finds the next occurrence of pat but looks at the
␈↓ ↓H␈↓ topmost elements of the CE first (useful for
␈↓ ↓H␈↓ getting to PROG tags)
␈↓ ↓H␈↓ (BF pat T) similar to above
␈↓ ↓H␈↓ (F pat n) finds the n-th occurrence of pat
␈↓ ↓H␈↓ (BF pat n) similar to above
␈↓ ↓H␈↓ F finds the next occurrence of the last search
␈↓ ↓H␈↓ pattern
␈↓ ↓H␈↓ BF similar to above
␈↓ ↓H␈↓ Patterns
␈↓ ↓H␈↓ --------
␈↓ ↓H␈↓ Pat, as used above, can contain any of the following:
␈↓ ↓H␈↓ Element of pat What it matches
␈↓ ↓H␈↓ ------- -- --- ---- -- -------
␈↓ ↓H␈↓ atom atoms EQ to it
␈↓ ↓H␈↓16␈↓ ¬}Section IV␈↓ H
␈↓ ↓H␈↓ list calls matcher recursively
␈↓ ↓H␈↓ ? any atom or single list
␈↓ ↓H␈↓ (i.e. an s-expression)
␈↓ ↓H␈↓ ?X any element; binds ?X to
␈↓ ↓H␈↓ whatever it matched
␈↓ ↓H␈↓ * any non-empty string of
␈↓ ↓H␈↓ elements
␈↓ ↓H␈↓ *X matches as *, but binds *X to
␈↓ ↓H␈↓ the list of elements it matched
␈↓ ↓H␈↓ =?X whatever ?X matched last time
␈↓ ↓H␈↓ =*X whatever *X matched last time
␈↓ ↓H␈↓ (RESTRICT ? P1...Pn) any element satisfying the
␈↓ ↓H␈↓ predicates P1,...,Pn
␈↓ ↓H␈↓ ($R ? P1...Pn) same as above.
␈↓ ↓H␈↓ (RESTRICT ?X P1...Pn) similar to above but binds ?X
␈↓ ↓H␈↓ to what it matched.
␈↓ ↓H␈↓ ($R ?X P1...Pn) same as above.
␈↓ ↓H␈↓ Note: (A ?X IS A ?X) matches (a word is a word) but
␈↓ ↓H␈↓ not (a word is a sentence). Simlarly for (*X is a *X).
␈↓ ↓H␈↓ Invoking the Matcher
␈↓ ↓H␈↓ -------- --- -------
␈↓ ↓H␈↓ (MATCH pat) attempts to match pat against the CE
␈↓ ↓H␈↓ (MATCH pat var1 ... varn) attempts to match pat against the
␈↓ ↓H␈↓ CE while retaining the values of the
␈↓ ↓H␈↓ variables var1,..., varn. (E.g.
␈↓ ↓H␈↓ (MATCH (* *A *B ?A) *A ?A).
␈↓ ↓H␈↓ MATCH attempts to match the last pat against the
␈↓ ↓H␈↓ CE. Like F and BF above.
␈↓ ↓H␈↓ REMATCH attempts to get the next match of pat against
␈↓ ↓H␈↓ the CE. Usually this only makes sense if
␈↓ ↓H␈↓ pat contains some * variables.
␈↓ ↓H␈↓ (REMATCH var1 ... varn) rematches but will retain var1,...,varn.
␈↓ ↓H␈↓ Hairy Matching Uses
␈↓ ↓H␈↓ ----- -------- ----
␈↓ ↓H␈↓ (PR pat) replaces the CE with the instantiation of
␈↓ ↓H␈↓ pat (substitutes the values of ?-variables
␈↓ ↓H␈↓ and *-variables)
␈↓ ↓H␈↓ (PA n P1...Pn) similar to (A n E1...En)
␈↓ ↓H␈↓ (PB n P1...Pn) similar to (B n E1...En)
␈↓ ↓H␈↓ (PAI P1...Pn) similar to (AI E1...En)
␈↓ ↓H␈↓ (PRA exp1 pat) similar to (R exp1 exp2)
␈↓ ↓H␈↓ (TPRA exp1 pat) similar to (TR exp1 exp2)
␈↓ ↓H␈↓ Other Commands
␈↓ ↓H␈↓ ----- --------
␈↓ ↓H␈↓␈↓ ¬}Section IV␈↓ *17
␈↓ ↓H␈↓ (SAVE filename <optional ext>)saves the toplevel expression
␈↓ ↓H␈↓ in the file given by the file
␈↓ ↓H␈↓ specs (will create files not
␈↓ ↓H␈↓ existent),
␈↓ ↓H␈↓ [LSP is the default value for the extension.]
␈↓ ↓H␈↓ SAVE saves the toplevel expression
␈↓ ↓H␈↓ in the file last saved in. If
␈↓ ↓H␈↓ there was none, the file spec.
␈↓ ↓H␈↓ is requested.
␈↓ ↓H␈↓ (REFILE FOO <file specs>) replaces the function FOO in
␈↓ ↓H␈↓ the file given by the file
␈↓ ↓H␈↓ specs with that found under
␈↓ ↓H␈↓ the "draft" property of FOO
␈↓ ↓H␈↓ where <file specs> is of the
␈↓ ↓H␈↓ form (file <optional ext>).
␈↓ ↓H␈↓[NB: <file specs> is a 4-list (filename ext dev dir) or some
␈↓ ↓H␈↓ initial segment thereof. Thus calls to REFILE are different
␈↓ ↓H␈↓ in format from those to SAVE or EDIT]
␈↓ ↓H␈↓ (REFILE (FOO1...FOOn)<file specs>)
␈↓ ↓H␈↓ similar to above but refiles
␈↓ ↓H␈↓ FOO1...FOOn.
␈↓ ↓H␈↓ (REFILE (FOO1...FOOn)<infile specs><outfile specs>)
␈↓ ↓H␈↓ (REFILE * <infile><optional outfile>) updates every function
␈↓ ↓H␈↓ in infile. Note that the
␈↓ ↓H␈↓ specs are as file specs in the
␈↓ ↓H␈↓ vanilla refile above.
␈↓ ↓H␈↓ similar to above but files the
␈↓ ↓H␈↓ result in the outfile
␈↓ ↓H␈↓ REMEMBER puts the toplevel expression
␈↓ ↓H␈↓ under the "draft" property
␈↓ ↓H␈↓ (preserves DEFUN format and
␈↓ ↓H␈↓ comments)
␈↓ ↓H␈↓ OK REMEMBER's and EVAL's the
␈↓ ↓H␈↓ toplevel expression
␈↓ ↓H␈↓ (i.e. defines the function as
␈↓ ↓H␈↓ well as remembers it)
␈↓ ↓H␈↓ (COMMENT T) allows comments to be in the
␈↓ ↓H␈↓ toplevel expression (uses the
␈↓ ↓H␈↓ grind-read-table)
␈↓ ↓H␈↓ (COMMENT NIL) disables above
␈↓ ↓H␈↓[note added by editor: if you have comments in your files, use
␈↓ ↓H␈↓";;;" rather than ";" to flag them. Then the editor is less
␈↓ ↓H␈↓likely to scramble them.]
␈↓ ↓H␈↓ The Undo Feature
␈↓ ↓H␈↓ --- ---- -------
␈↓ ↓H␈↓ The Editor allows the user to "undo" any editing he has
␈↓ ↓H␈↓ done. Thus if he has made a mistake or simply is
␈↓ ↓H␈↓18␈↓ ¬}Section IV␈↓ H
␈↓ ↓H␈↓ experimenting, he can invoke the undo feature to undo each
␈↓ ↓H␈↓ step. However the undoer requires a history of the edit to
␈↓ ↓H␈↓ be kept and so uses a lot of space. Be warned!
␈↓ ↓H␈↓ (UNDO T) enables undoing
␈↓ ↓H␈↓ (UNDO n) enables undoing with only the last undoable
␈↓ ↓H␈↓ commands being saved (initially 6.)
␈↓ ↓H␈↓ (UNDO NIL) disables undoing and flushes the undoqueue (the
␈↓ ↓H␈↓ history)
␈↓ ↓H␈↓ UNDO undoes the last command. Successive UNDO's will
␈↓ ↓H␈↓ undo prior edit commands.
␈↓ ↓H␈↓ The following commands can be undone:
␈↓ ↓H␈↓ ↑ TOP RI RO LI LO NX BK BF DELETE F OK REMEMBER (COMMENT
␈↓ ↓H␈↓ -) (A -) (B -) (R -) (PA -) (PB -) (PAI -) (PBI -) (PL -)
␈↓ ↓H␈↓ (PD -) (PRA -) (BF -) (F -) (CR -) (PR -) (AI -) (BI -)
␈↓ ↓H␈↓ (N -) (N) N (EDPROG -).
␈↓ ↓H␈↓ Exiting and Etc.
␈↓ ↓H␈↓ ------- --- ---
␈↓ ↓H␈↓ EXIT exits the Editor (to the LISP toplevel)
␈↓ ↓H␈↓ (EDIT) gets you back to the Editor
␈↓ ↓H␈↓ (REMEDIT) flushes the Editor.
␈↓ ↓H␈↓ Any other command is handed to LISP to be EVAL'ed.
␈↓ ↓H␈↓␈↓ ¬}Section IV␈↓ *19
␈↓ ↓H␈↓2. ␈↓αExample session with the LISP Editor.␈↓
␈↓ ↓H␈↓ Here␈α
are␈αsome␈α
things␈α
you␈αcan␈α
do␈α
using␈αthe␈α
Editor␈α
feature␈αof␈α
LISP.␈α
The␈αuser␈α
types␈αin␈α
lower
␈↓ ↓H␈↓case, LISP replys in upper case, ";;;" flags a user comment, ";" a LISP comment.
␈↓ ↓H␈↓¬;;;get the function gg from the file abc.def
␈↓ ↓H␈↓¬(edit gg abc def)
␈↓ ↓H␈↓¬← ;;; the "←" means you are in the editor
␈↓ ↓H␈↓¬;;;pretty print the definition
␈↓ ↓H␈↓¬pp
␈↓ ↓H␈↓¬(DEFUN GG (X) (COND ((ATOM X) X) (T (GG (CAR X)))))
␈↓ ↓H␈↓¬
␈↓ ↓H␈↓¬← ;;;make gg return the right most atom instead of the left most
␈↓ ↓H␈↓¬;;;first make (CAR X) the CE
␈↓ ↓H␈↓¬4 3 2 2 p
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬(CAR X)
␈↓ ↓H␈↓¬;;;now change CAR to CDR
␈↓ ↓H␈↓¬← (1 cdr)
␈↓ ↓H␈↓¬← p
␈↓ ↓H␈↓¬(CDR X)
␈↓ ↓H␈↓¬;;;remember the new definition
␈↓ ↓H␈↓¬← remember
␈↓ ↓H␈↓¬;;;update the definition
␈↓ ↓H␈↓¬← (refile gg (abc def))
␈↓ ↓H␈↓¬updated functions are: GG
␈↓ ↓H␈↓¬(ABC DEF DSK (4 1002))
␈↓ ↓H␈↓¬;;;try out a newly defined function---fiddle
␈↓ ↓H␈↓¬;;;note that you can evaluate expressions in the
␈↓ ↓H␈↓¬;;;editor as if you were at the top level of LISP
␈↓ ↓H␈↓¬← (fiddle 'x)
␈↓ ↓H␈↓¬(X . X)
␈↓ ↓H␈↓¬← (fiddle '(x.y))
␈↓ ↓H␈↓¬SPEC PDL OVERFLOW
␈↓ ↓H␈↓¬;;;oops must be a bug
␈↓ ↓H␈↓¬← (edit fiddle)
␈↓ ↓H␈↓¬(FIDDLE)
␈↓ ↓H␈↓¬← pp
␈↓ ↓H␈↓¬(DEFUN FIDDLE (X)
␈↓ ↓H␈↓¬ (COND ((ATOM X) (DOUBLE X))
␈↓ ↓H␈↓¬ (T (FIDDLE (CONS (CDR X) (CAR X))))))
␈↓ ↓H␈↓¬;;;hmmm better fix it
␈↓ ↓H␈↓¬← 4 3 2 (1 cons) pp
␈↓ ↓H␈↓20␈↓ ¬}Section IV␈↓ H
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬←
␈↓ ↓H␈↓¬(CONS (CONS (CDR X) (CAR X)))
␈↓ ↓H␈↓¬
␈↓ ↓H␈↓¬← (2 (fiddle (cdr x)) (fiddle (car x)))
␈↓ ↓H␈↓¬← p
␈↓ ↓H␈↓¬(CONS (FIDDLE #) (FIDDLE #))
␈↓ ↓H␈↓¬;;;remember the new definition and
␈↓ ↓H␈↓¬;;;redefine the function
␈↓ ↓H␈↓¬← ok
␈↓ ↓H␈↓¬FIDDLE
␈↓ ↓H␈↓¬← (fiddle 'x)
␈↓ ↓H␈↓¬(X . X)
␈↓ ↓H␈↓¬← (fiddle '(x.y))
␈↓ ↓H␈↓¬((Y . Y) X . X)
␈↓ ↓H␈↓¬;;; save it fiddle.lsp
␈↓ ↓H␈↓¬← (save fiddle)
␈↓ ↓H␈↓¬(DSK (4 1002))
␈↓ ↓H␈↓¬;;; copy functions in abc.def into uvw.xyz updating any that the editor
␈↓ ↓H␈↓¬;;;knows have been changed.
␈↓ ↓H␈↓¬← (refile * (abc def) (uvw xyz))
␈↓ ↓H␈↓¬updated functions are: GG GG DOUBLE DOUBLE
␈↓ ↓H␈↓¬(UVW XYZ DSK (4 1002))
␈↓ ↓H␈↓¬;;;abc.def is unchanged