You are on page 1of 788

INTERLISP REFERENCE MANUAL

BY WARREN TEITELMAN
contributions by:

A. K. HARTLEY
J. W. GOODWIN
D. C. lEWIS
BOLT BERANEK & NEWMAN

D. G. BOBROW
P. C. JACKSON
l. M. MASINTER
XEROX PALO ALTO RESEARCH CENTER

XEROX
PALO ALTO RESEARCH CENTER
3180 PORTER DRIVE/PALO ALTO/CALIFORNIA 94304

BOLT BERANEK & NEWMAN

Copyright© 1974
Revised October, 1974

XEROX CORPORATION

Acknowledgements and Background

INTERLISP

has evolved

from a succession or LISP systems that began with a

LISP designed and implemented for the DEC

,PDP-1

by D. G. Bobrow and O. L.

Murphy 1 at Bolt, Beranek and Newman in 1966. and documented by D. G. Bobrow.
An upwards compatible version of this LISP was implemented for the SOS 940 in
1967,

by

Bobrow and Murphy.

This system contained the seeds for many or the

capabilities and features of the current system:
interpreter, 2

uniform

error handling,

an

sophisticated debugging facilities,4 etc.

a compatible compiler and

on-line

LISP

oriented

editor, 3

940 LISP was also the first LISP

system to demonstrate the feasibility of u•ing software paging

techniq~es

and a

large virtual memory in conjunction with a list-processing sys tern [ Bob2).

owrn, the Do-What-I•Mean error correction facility, was introduced into the
system

in

1968

by

W.

Teitelman

[TeiZ],

who

was

also

re~ponsible

for

documentation for the 940 LISP system.

1-----------------------------------------------------------------------------D. G. Bobrow is currently at Xerox Palo Alto Research Center (PARC). D. L.
Murphy is with Digital Equipment Corp.

2

The preliminary version of the compiler was written by L. P. Deutsch, now
at Xerox PARC. This was considerably modified and extended bY D. L. Murphy
before producing the final working version.

8

The original idea of a LISP oriented structure editor belongs to L. P.
Deutsch. The editor in its current form was written by W. Teitelman. now
of Xero·x PARC.

4

Designed and implemented by W.

Teitelman.

i

In

1970,

an upwards compatible version of 940 LISP called BBN

LlSP 5 was

designed for the PDP-10 by D. G. Bobrow, D. L. Murphy, A. K. Hartley, and W.
Teitelman,

and implemented by Hartley with· assistance from Murphy.
fo~

Hartley was also responsible
code for the PDP-10.
system

for

Burchfiel,
hardware

the
D.

L.

IC

modifying the 940 LISP compiler to generate

BBN-LISP ran under TENEX, a sophisticated time sharing

PDP-10

designed

Murphy,

T .. R.

and

implemented by

Strollo,

and R.

s ..

D.

G.

Bobrow,

provide extensive .and

.~ophisticated

J.

D.

Tomlinson.[Bob1]· With

paging and Z56K of virtual memory provided by. TENEX,

practical to

A.

interactive

it

user

became
support

facilities, such as the prograrruner's as.sistant [Tei4], CLISP [Tei5J, and a more
sophisticated DWlM, all of which were designed and developed bY W. Tei telman.
In 1971, the

bl~ck co~piler

was designed and implemented by D. G. Bobrow. ·The

BBN-LISP Manual [Tei3J was written by
IC

w.

Teitelman, with contributions from A.

Hartley and from J. W. Goodwin, who also wrote TRANSOR and the special

arithmetic functions, as well as a number of other utility functions.
of

the

system was . changed from BBN·LISP
'

maintenance and development of the

~ystem

to.

INTERLISP
.
.

in

when

the

evolved into a joint effort between

Bolt Beranek and Newman, and Xerox Palo Alto Research Center.
reference manual was written by \./,

1973,

The name

The INTERLISP

Teitelman, with contributions from

(in

alphabetic order) D. G. Bobrow, J. W. Goodwin, A. K.. Hartley, P. C. Jackson, D.
C. Lewis, and

L.

K~

Masinter.

The

cove~

was designed by Alice R. Fikes.

INTERLISP-10 is currently the LISP system used at Bolt Be.ranek. and Newman,
Xerox

Palo

Alto

Res~arch

Center,

Stanford

Research

Institute

Artificial

Intelligence Center, Information Sciences· Institute, and the Dendral Project at

5---1ti;·ci~~;~~~--;;;;;;;;;;;;·;~d-d~~~~~h~~~i~h·-;;;·;;N-ti8;-~~~--;;~~;~;;d·b;
the Information Processing Techniques Section of the Advanced Research
Project Agency, as was all of the subsequent work on the system that was
performed at . BBN.
Since March 1972, the contributions made to the
development of the system by W. Teitelman, including the preparation of
this manual, were sponsored by Xerox Palo Alto Research Center.

ii

Stanford University, in addition to being available at Computer Corporation of
America

and

Case

Institute

of

Technology.

The

total

community now comprises approximately one hundred users.
INTERLISP

for

the

IBM

370,

CDC

3300,

Burroughs

and

INTERLISP-10

usor

Implementations of
6700

are

nearing

completion.

INTERLISP is a continuously evolving system, both in response to complaints,
suggestions,

and

network,

well

as

requests of the many users scattered throughout
as

the

long

range

goals

of

the

individuals

the ARPA
primarily

responsible for the system, which are currently:

Person
W. Teitelman

Xerox Palo Alto
Research Center
3180 Porter Drive
Palo Alto, Calif. 94304

Responsible for
User facilities: i.e., pretty-print, editor,
break and trace, advising, printstructure,
D\.J!M, CLISP, programmer's assistant, etc.

A. K. Hartley
Bolt Beranek & Newman
50 Moulton St.
Cambridge, Mass. 02138

INTERLISP·iO interpreter, garbage collector,
all SUBR's{hand-code machine language functions),
compiler.

D. C. Lewis
Bolt Beranek & Newman
50 Moulton St.
Cambridge, Mass. 02138

INTERLISP-10 input-output, readtables,
terminal tables, user data types.

J. W. Goodwin
Bolt Beranek & Newman
50 Moulton St.
Cambridge, Mass. 02138

INTERLISP-10 overlays, sysin, sysout, makesys,
special arithmetic functions, functions
for accessing TENEX capabilities, TRANSOR.

L. M. Masinter
Xerox Palo Alto
Research Center
3180 Porter Drive
Palo Alto, Calif. 94304

pattern match compiler, record package,
INTERSCOPE.

Hi

The preparation of this manual has involved the efforts of several persons at
Xerox PARC, whom· I specifically want to mention, and to express my appreciation
for their support through this arduous, and at times seemingly endless task.

Thank you Suzan (Jerome), Janet (Farness), Peter (Deutsch),

Larry (Tesler).

Bob (Walker), and

I couldn't have done it without you.
Warren Teitelman
Palo Alto
December, 1973


Special thanks go to R. L. Walk.er, L. M. Masinter, and I... P. Deutsch for
assistance in the preparation of this first revision.

w. T.

October, 1974.

TABLE Of CONTENTS

SECTION 1: Introduction
SECTION 2: Using INTERLISP
Using the INTERLISP Manual • . • . . • . • • . • • • • • . . • • • . • . •
Using the INTERLISP-10 System on Tenex ••••••••••••

1

4

SECTION 3: Data types, Storage Allocation, and Garbage
Collection, ~nd Overlays
Data Types .......................................... .

Literal Atoms ............................... .
Pnames ......•••.•••.•••..•••.•...•••••. ~ •..•..

Numerical Atoms •••••••••.....••..•••••••••..•

Lists ··················••11i•·········~········
Arrays ...........· ...... , .•......... "' ........ .
Strings ••o•••••·········••••••••~••••••••••••

Storage Allocation and Garbage Collection •..••••••
Shared INTERLISP-10 ·····················~·········

1
2
5
.5

8
9
10

12

· 15

SECTION 4: Function Types and Implicit PROGN
Exprs ......•.......•..•••.•....•.....••...•.•••••..

1

Compiled functions .••••.•••.•....••••.•..•.•.••.•.

3

Function Type . . . . . . . . . . . . . . . • . . . . . . . . . .. . . . . . . . . . . .

3
4
4

PROGN .• ••••

I

. . . . . . . . . . ·•

.•

Implicit PROGN . . . . . . . . . . . . . . .. . . . . . • . . • . . . . . . • • . . . .

SECTION 5: Primitive Functions and Predicates
Primitive functions ..•..•• , .. i., ....... ,..........
and RESETFORM , •......•. , .•.••••.• ·•.••.•• ,.
Predicates a~d Logical Connectives .••.••••.••••.••

RESETVAR

1
9

12

SECTION 6: List Manipulation and Concatenation
SECTION 7: Property Lists and Hash Links
Property L1$tS ........................•. ~.........
Hash Links .......•.•.....•• " •••••••••••• ,..........

Hash Overflow ••••••••• ~......................

1

1
4

7

TABLE OF CONTENTS (cont.)

SECTION 8: Function Defini Uon and Evaluation
SECTION 9: The INTERLISP Editor
Introduction ..................................... .

Commands for the New User ......•...•.•••••.•••.•..
Attention Changing Commands ....•....••••••••..••..
Local Attention Changing Commands ..•...• ·••...
Commands That Search .•...............•••..•..
Search Algorithm .............•.......•..
Search Commands •. " , .•••••••

9

••••••••••••

1
10
15
15
21
23

25

Location Specification ..•...••••..••....
Commands That Save and Restore the

28

Edit Cha.in ..... "... ~. a~.: • • • • • • • • • • • • • • • • • • • •

34

Commands That Modify Structure ...•.•...•......•.••
Implementation.of Structure Modification

36

Conunands .. ·•....••

a •••••••

~

• • _.· . • • • • • • • • •· • • • •

The A, B, : Commands ........•...••.....•.• ·...

Form Oriented Editing and the Role of UP ....•
Extract *nd Emb6d .•........ ~ ...•.•....•• ~···~

37
. 3.9
43

The MOVE Corntniind ..•..•..•••••••••••••••••••••

45
48

Commands That "Move Parentheses" ••.•.........
TO and THRU .......•.....•.....•..• ~ ....... • .•

51
54

The R Command ...••..••••••••.•••• o • • • • • • • • • • •
Commands That Print ........ : ....••..•.••••...•..
9

••

Commands That Evaluate .....•. , .... ~ •.••.•....•......

Corrunands That TE!st .•..• "' •• ·~ •••. ,~ ', ••••.••• • ·• •.••••••
~lac r· o s . . . . . . . . . . . . ...• ~ . . • • • . . . . • . • • • . • . ~ • . • • • . • • •
Miscellaneous Corrunands •..•............•.......•• ti.

UNDO ...•......•.•••.•.••• -.·:···· ....... ~ •.••..••••••
EDITDEFAULT .•...•....••••••••••••.••.•••••.•••.•.•
o

•••

Editor Functions

57
60
62

64
67
70
78
80
83

SECTION 10: Atom, String, Array, and Storage"T'ianipulation
Pnames and Atom Manipulation .. ;...................

l

String Functions ............................ o.....

5

Searching Strings ....•....•. ., , .••..••.....•. -. . . . .

8

String Storage •••••••••o•••••••••••••••••••o•

11

Array Functions . . . . . • • . . . . . . • • • • • • . • • • • • . • . • . • • • . .

12

Storage Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

14

SECTION 11: Functions with Functional Arguments
SECTION 12: Variable Bindings and Pushdown List Functions
The Pushdown List and the Interp~eter .••••...•.•..
The Pushdown List and Compiled Functions .,.........
Pushdown List Functions •..•...••..••.••••...•.•••.
The Pushdo~n List and Furiarg . ., . .,..................

H

3
6
7
II

TABLE OF CONTENTS (cont.)

SECTION 13: Arithmetic Functions
General Comments . . . • . . . . . . . . . . . . . . • . • . . . . . . . . . . • . .

1

Integer Arithmetic . . . . . • . . . . . . . . . . . • • • . . . . . • . . • . . •
Floating Point Arithmetic •.••.•..••••.••••.•••••••
Mixed Arithmetic . . . • . . • • . . . . . . . . . • • • . . . • • • • • • • • • • •
Special Functions . • . . . • . . • . • . . . • . . • . • • • • . . • • . • . • • •
Reusing Boxed Numbers in 1NTERLISP•10 • SETN ••••••

2
6
7
8
10

Box and Unbox .. ., • . . . . • . . • . . . . . . . • • . • • . • . • . • • . • . • • .

13

SECTION 14: Input/Output Functions
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Addressable files . . . . . . . . • . . • • • • . • . • • . • . • • . • .
JFN Functions in INTERLISP-10 • • • • • • • • • • • • • • . •
Input functions ......................... •.........
Output Functions ......•.•.••...••••• , • • • • • • • • • • • • .
Printlevel .
Readtables and Terminal Tables • • • . • • • • • • • • • • • • • • • .
Readtable Functions ..•.••••••••••••••.•••••••
Syntax Classes . . . • . . . . . . . • • . . • . . . . . . • . • • . . . . .
Read-macro Characters .....••.•..•.••.•.••••.•
Terminal Tables ....... , . . . • . . • • • . • . . . . . . . • • . .
Terminal Control Functions .•....•...••••••••.
Line-Buffering and Control • . . • . . • . . . . • • • • . • • .
Miscellaneous Input/Output Control Functions •..•••

o..................................

1
5
9
11
19
20
21
22
23

26
28

30
32

35

Sys in and Sysout . . . . . . • • • . . . . . . • . . ... . . • . . . . . . • . . . •

37

Symbolic File Input . • • • • • • • • • . • • • • • • . • • • • . • • • • • • • .
File ~laps ....•..•• "'..........................
Symbolic File Output . . • • • • . • . • . . • • • • • • • • • • . . . • • . • •

39
42
44

PRETTYPRINT • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

45

Cor:iment Feat\lre

8'.

46

PRETTYDEF • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

47
55
62
63
64
65

GI

•••••••••••••••••••••••••••

Special PRETTYPRINT Controls .•••.•• ~.........
File Package . . . . . . . . • . . • • . . • . . . . . . • . • • • • . . . . . . • • . •
Noticing Files .............................
Marking Changes ... , . . . • . . . . • . . • • . • • . • • . • . • . • .
Updating Files . . . . . • • • • . • • • • • • • • • • • • • • • • • • • • •

II.

~tAKEFILE

......•.

G

••••••••••••••••••••••••••

II.

Remaking a Symbolic File .;...................

65

67

SECTION 15: Debugging - The Break Package
Debugging Facilities .•.•.•.•..•.•.•••..••......•••
BREAK 1 ...•....•..•.•.••.••.•••.••. o • • • • • • • • • • • • • • •
Break Cornrnands . . . . • • • • . . • • . • • • • • • • • • . • • • • • • . •

1
4
7

Brkcoms . . . . . . . . . . • . • . • . . . • . . . • • • . • . . . • . • • • • • •
Brk.file .••...••..•.••••.••••••••.•••.••••••••

15
1'5

BreakmaCros .............•...••...••...•. ·. . . . .

16
16.

Break.resetforms . . • . . • • • • . • • • • • . . . • • • • • • • • • . • •
Break Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
BREAK.IN .......... "·························•··

iU

17
21

TABLE OF CONTENTS (cont.)

SECTION 16: Error Handling
Unbound Atoms and Undefined Functions •..•..•.•.••.
Teletype Initiated Breaks ..•............•.......
Control H
Control B
Control E

.................. .
........... • ....... .

Other Types of Errors .............••.•••.••••...
Breakcheck - When to Break
•...•.•.•••.....•.•
Error Types " . . . . . . . . . . . . . . . . . .

. ......... .

Error Handling by Error Type ...•..••••.....•.
Error Functions .

Ill

.................................

II

Interrupt Characters ..•.....•...•••••.•......•...•

1
2
2
3
3
4
·4
7
12
13
16

SECTION 17: Automatic Error Correction - The DWIM Fae Hi ty

Introduction ............................. .

Interaction with DWIM ..•....•...•.•..
Spelling Correction Protocol
.•...•..
Parentheses Errors Protocol .•.••.•••••..
Spelling Correction ..•............•.•..•....

1

DWIMUSERFN ••••••••••••••••••••

5
5
7
10
1t
12
15
16
17
18
19

Spelling Corrector Algorithm ••.•..
DWIM Functions
"

23

Synonyms . . . . . • •

• ••••

fl

•••••••••••••••••••

Spelling Lists
Error Correction .............................. .
Unbound Atoms ............................... "

Undefined Car of Form ..................... .
Undefined Function in Apply ..

............. ............... " ... .

20

SECTION 18: The Compiler and Assembler
The Compiler ................. " ..........

e ••

Compiler Questions
Nlambdas ......... .
Global Variables
Compiler Functions
DECLARE:
RECOMPILE
Open Functions
Compiler Macros
FUNCTION and Functional Arguments
Block Compiling
Specvars ................................. .

1
3
5
6
7
11

u

14
16
18
19
19

Loe a 1 freevars ................................. .

20

Retfns

21

.....•...•.•.............••.•• ".

Blkapplyfns
Blklibrary
Linked Function Calls ...••......•....•..••••.•..
Relinking
The Block Compiler .......•...
BLOCKCOMPILE
Block Declarations
BCONPL

iv

22
22
23

27
28

29
30
32

TABLE OF CONTENTS (cont.)

BRECOMPILE . . . . . . • . . . . . . . . . . . • . . . . • . . . . . . . . . . .
Compiler Structure . . . . . . . . . . . . . . • . . . . . . . . . . . • . . . • .
ASSEMBLE ............•............• , . . . . . . • . . . . . . . .
LAP • • • . • . . • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

Using ASSEMBLE . . . . . . . . . . . . . . . . . . . . . . . . • . . . • . . . . . . .
Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . .
Compiler Printout and Error Messages ..........•...

33
35
36
4'1
47
48

49

SECTION 19: Advising

Implementation of Advising ..............•.•.•..•..

2

Advise Functions .................. , . . . . . . . . . . . . . . .

5

SECTION 20: Printstructure, Interscope. and Helpsys
Printstructure . , . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Inter scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Help sys ......... ·...................................

1
10
21

SECTION 21: Miscellaneous

Measuring Functions
BREAKDOWN ......................................... .

EDITA ............................................. .

Input Protocol .............................. .

EDITA commands and variables ................ .

Interfork Communication in INTERLISP-10 .....•...••
Subsys ......................................•.....
Miscellaneous TENEX Functions in INTERLISP-10 ..•..
Printing Reentrant and Circular List Structures ...
Typescript files .......................•......•.•.

1
5
8
10

12
18
19

22
23

30

SECTION 22: The Programmer's Assistant and LISPX
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Overview ....... ·........ ,..................... ... . . .

Event Specification . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . .
History Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . • . . . . •
Implementation of REDO, USE, and FIX .........
History Commands Applied to History Conunands •
History Commands That Fail . . • . . . . • . . . . • . . • . . .
~lore History Commands . • . . . . . . . . . . • • . . . • • . . . . •
Mi see llaneous Fea tu res and Commands . . . • • • • . . • . . . . .
Undoing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

·1
6
11
14

17
20
21
22
28
38

Cl...........

41

functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . .

44
47
48

Testmode ............•.•.........•

Undoing out of order ...•..........•.........•
SAVESET ................... , .....•• , . , ... , . • . .
Format and Use of the History List .••...•......•.•
LI SPX and READLINE . . . . . . . . . . . . . • . . . • • • . . • . • . . . . • . •
The Editor and the Assistant ..........•••....•.•..

42
43

61

Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

63

Greeting and User Initialization •.••.•.•••....••.•

64

v

TABLE OF CONTENTS (cont.)

SECTION 23: CLISP - Conversational LISP
Introduction .•.•••••••••.•.•...
CLI SP Syn tax
Infix Operators

................................ .

Prefix Operators .•.....................
Constructing Lists - the <,>Operators
IF, THEN, ELSE
Iterative Statements ..............••...•.........
Errors in Iterative Statements .•.............
Defining New Iterative Statement Operators
CLISP Translations

..........................

Declarations ......... , ...................... .

Local Declarations ...•.•....•..•.•....
The Pattern Match Compiler •.•.••.••..••..•..
Element Patterns .•..•••...•...•.•.
Segment Patterns ··~····
....•..•
Assignments . . . . . . . . • . • .
. ......•.•...

1
9
10
13
16
17
18
28
29

31
35
37
38
41
43

45

Place-markers .............. ., .......•....... •

Record Declarations •.•...•...•...•...•..

46
46
47
50
53

CREATE ....•..•••..

59

Replacements ...•.........•.•.•......•.

Reconstruction ....................... .
Record Package ...............•.•.••...•.... ., ...
I

••••••••••••••••••••

II

Implementation
CLISPifY ....... .
DWIMIFY
Compiling CLISP
Operation ............... •
CLISP Interaction with User •.•••••.•.••••.•.•.
CLISP Internal Conventions ..•.••...••.•..••
CLISP Functions and Variables .•..•..•••....
e e e e e e

I

61
62
65
67

...................... .

e e e e

I

I

e

0

I

e • e e e •

I

I

e e • '

68
71
72
15

APPENDIX 1: TRANSOR
Introduction ........ .
Using TRANSOR ••••••••
The Translation Notes
TRANSORSET .......... .
Controlling the sweep

1
3
4

a
t

e

0

0

t

't

t

t

t

t

APPENDIX 2: INTERLISP Interpreter
APPENDIX 3: Control Characters
MASTER INDEX

Vi

t

t

t

t

t

I

t

t

t

t

t

t

t

II

t

e

t

t

t

14

SECTION 1
INTRODUCTION

a LISP system that is

*

currently implemented on (or implementations are in progress for) at least five

R

different

INTERLISP

R

implementations, although it does contain some material that is relevant only

R

to INTERLISP-10, the implementation of INTERLISP for the DEC PDP-10 under the

R

BBN TENEX time shar.ing system.[Bob1] 1 Where this is the case, .such material is

R

clearly marked.

R

This document is a reference manual for INTERLISP,

machines.

This manual

is a reference manual

for

all

INTERLISP has been designed to be a good on-line tnteractive system (from which
it

derives

its

name).

Some of the

features

provided

include

elaborate

debugging facilities with tracing and conditional breakpoints (Section 15), and
a

sophisticated

LISP

oriented

editor

within

the

system

(Section

9).

Utilization of a uniform· error processing through user accessible routines
(Section 16) has allowed the implementation of DWIM, a

~o-~hat-!-~ean

facility,

which automatically corrects many types of errors without losing the context of
computation (Section 17).

The CLISP facility (Section 23) extends the LISP

syntax by enabling ALGOL-like infix operators such as +, -. *• /,
OR,

etc.,

as well as

=,

~.

AND,

IF-THEN-ELSE statements and FOR-WHILE-PO statements.

,-----------------------------------------------------------------------------INTERLISP-10 is designed to provide the user access to the large virtual

memory allowed by TENEX, with relatively small penalty in speed (using
special paging techniques de~cribed in [Bob2]). INTERLISP-10 also providos
for
essentially unlimited quantity of compiled code vi~ the overlay
facility
described
in
section 3.
INTERLISP-10 was
the
first
implementation of INTERLISP, and is still the most widely used.

1.1

+
+

+
+

error system tables (section redefine the The user can also action define of new INTERLISP system is the programmer's assistant (Section 22). Stanford LISP. CLISP also includes a sophisticated pattern match compiler. arrays. we have implemented TRANSOR.. line-buffering protocol.2 . facility of the even garbage variou~ action on Readtables and terminal specify echo modes. including the ability to define + read + formatting + datatypes (section 23) in addition to the lists.. as well as a record package that facilitiates 11 data . parentheses.g. characters and useful of the system as interrupt output radix. LISP 1. less 11 programming.5. strings. + conditions. specified operations. and free him to concentrate more fully on the conceptual difficulties and creative aspects of the problem he is trying to solve. "built-in" macro A novel aspects characters. which monitors and records all user inputs. + 14) allow the user complete control over input. etc.CLISP expressions are automatically converted to equivalent INTERLISP forms when they are first encountered. and applies these transformations to source programs written 1. The user can instruct the programmer• s assistant to repeat a particular operation or sequence of operation~. CUSP. DWHI. e. To aid in converting to INTERLISP programs written in other LISP dialects. + INTERLISP has also been designed to be a Jlextble system. or to UNDO the effects of The goal of the programmer's assistant. accepts transformations (or can operate from a subsystem which previously defined transformations).. Even + such + collection allocation and messages. etc. th the user in the development of his programs. with possible modifications. such as characters. and hash + association tables (hash links) already provided. is to provide a programming environment which will "cooperate" w:I. all can be affected through ·~ functions provided for that purpose. Advising (section 19) + enables users to selectively modify or short-circuit any system function.

good introduction to LISP has been written by Clark Weissman [Weil). and up to date versions of any or all chapters will be available in machine readable form from W. A Although not completely accurate with respect to INTERLISP. 2 + + + 1. i~ available for use within INTERLISP. A complete format directed list processing system FLIP [Tei1J. Therefore. Teitelman at Xerox PARC. some parts may only be clear to people who have had some experience with other LISP systems.5 to INTERLISP.in another LISP dialect. Although we have tried to be as clear and complete as possible. TRANSOR was used extensively in converting from 940 LISP to BBN-LISP on the PDP·10. In addition. Another useful introduction is given by Berkeley [Ber1J in the collection of Berkeley and Bobrow [Ber2]. and In addition. A set of transformations is available for converting from Stanford LISP and LISP 1. reissuing the index and table of contents at periodic intervals. this document is not designed to be an introduction to LISP. TRANSOR alerts the programmer to problem areas that (may) need further attention. Changes to this manual will be issued by replacing sectio!"S or pages.3 . the differences are small enough to be mastered by use of this manual and on•line interaction. the manual will be maintained on-line. producing object programs which will run on INTERLISP (Appendix 1).

October. + i. an update consisting + of just the thanged to the ~ariual corr~sponds INTERLISP system during the first ten to changes or ~onths or 1974.) Thus the reader who is already fa. almost all of them represent extensions or additions. + For those whb do not wish to obtairi an entire new manual. A significant number of these (about 60 pages) occur in section 14 About 30 pages of chapter 23 (CLISP) have been changed. + material). and 1• 1 '·' Changed material •+• (for deletion or original (indicating changes to fitX'isting material ihat more or less p~ges is available~ 1. the + reader is encouraged to skim through the manual noting changes which may affect + him. + in the text is flagged in the outside margin by the appearance of either a + (for addition of completely new material). + the rest of the changes are scattered throughout the manual. 1974.4 Note: very .mil iar with + the INTERLISP manual can quickly determine what has been changed. + The first revision to the INTERLISP reference + additions + Approximately 200 (out of 700) pages have been changed to some extent in this + revision.+ First· revision. or + preserve 1 ts original structure.e. Nevertheless. + few of these changes are not "upwards compatible" with the · original manual. + (input/output).

MIT Press. 196-::.C. V10 3.Bibliography [Berl] Berkeley. [Smi1] Smith. Bobrow.ISP • Conversational LISP 11 . [ Bobl J Bobrow. D.!§f 1. "A Model and Stack Implementation for Multiple Environments" (to be published).Q. D. L. 1972. J. Murphy. ( Ber2] Berkeley. D. \. Memo No. 0 W.. and Murphy. Stanford BBN°LISP TENEX Reference Manual. Intelligence Hartley. December 1972. [ Bob2 J Bobrow.. Bobrow. and Bobrow. MIT Press. [Bob3] Bobrow. October 1970. [ Tei4) Teitelman. August 1973. and Newman.!l ArtU'icial lntel liqence... Murphy. first revision February 1972. A Simple Introduction" in Berkeley. D. "Storage Organization and Management in TENEX 11 Proceedings of f!!ll Joint Computer Conference. March.. D. (McC1J McCarthy.. Third International ~ Conference .- [ Tei2] Teitelman. Ney 1969.:. Burchfiel. December 1972. D. Dickenson Press (1967). its Operation and Applications. S. E.5 Programmer's Manual. 1966. "CL. . 11 LISP. et al. E.!l Artificial Intelligence..G. D. The Programming Language LISP. second revision August !972.G.O".G.. L5 .· c.QJ! Artificial Intelligence. Proceedings of the Fall Joint Computer Conference. [Tei 1] Teitelman. and Wegbreit. [MurlJ Murphy./. -- [ Tei3] Teitelman. "TENEX.C. .. "MLISP 11 Artificial University. July 1971. ( Tei5] Teitelman. Bolt Beranek. March 1967. W.) International Joint Conference .G. Communications or the ACM. D. E.· BB!\1 Report. Third International ~ Conference .K. and LISP 1.!::. 1966. "Automated Programmering The Programmer·•s Assistant". 135 [>. (editors). "Toward a Programming laboratory" in Walker. R. D. Communications of the ACM.:1 Primer. A.. A format Directed List Processor in USP. W. G.!.Q.C. D. B. D. J. a Paged Time Sharing System for the PDP-i. "The Structure of a LISP System Using Two Level Storage". (ed. FLIP. W. and Tomlin5on. August 1973. [Ber2].. [Weil] Weissman. D. L.G.L.

.

more or less independent Each section is paginated independently. ~leta•LISI' notatton ts used Jor descrtbtng forms. + since the largest user cummunity is still that of INTERLISP-10. Throughout the manuai. member(car[x]. Examples: member(x:y] is equivalent to (MEMBER X V). sections. + This manual purports to be a reference manual for all implementations of INTERLISP. both present and future. there is a composite index for the entire manual.Format. Notation. In addition. plus several appendices and a table of contents. However. one such notational convention is: The names of Juncttons and uartables are wrttten tn lower case and underltned when they appear tn the text. + Where this is the case. the original + implementation for the DEC PDP-10.1 . INTERLISP is currently implemented on (or implementations are in progress for) + at least four different computers. the text refers to INTERLISP-10. terminology and conventions will be offset from the text and typed in italics.1 Using the INTERLISP Manual . to facilitate issuing Each section contains an index to key words. and variables contained in that section.F'OO] is 2 .SECTION 2 USING INTERLISP 2 . the manual does contain some implementation + dependent material. frequently at the beginning of a section~ For example. updates of sections. and Conventions The INTERLISP manual is divided into separate. functions. and is indicated as such.

The purpose of this is to allow a single function to be used both for the computation of some quantity.! of (FOOx) but E!!:'of (FOO. member[x.g. te £!!.s which might cau. could cause bizarre effects. value of member[x. £fil!.y] Similarly. i. and as a test for a condition. e.se inftnt. x). number&. terminate by an nltstp check.(A B • C)]•member[x. we have made the following implementation decision: All Juncttons that iterate through a li. followed fact by Note that this read the program. upper case quoted. the beginning with the value of . Other important conventions are: TRUE in 111/TERLISI' mean. notation t.!ll! is either NIL. mapc..g.. or the tau of x For example. Note that in meta-LISP notation lower case variables are evaluated.!!!· (FOO x) is (FOO (A 8 C)). the occasional list that ends in an atom.sh betU1een e..sttngui. or the value of its last expression. non-NIL. in of (FOO x y)..e. is either NIL.loops. arrag.. convention x is is ~ and !.sed to di. rather than the con11entional null-check.g . but cddr of (FOO x •· y). a. !. e. Similarly. is {FOO ABC).s. . CAB.2 .s a safety precaution again. e.~ is E!. whereas (FOO • x) In other words.!!!:. and the value of ~· Le. Accordingly.s not NIL. Thus. (FOO • (A 8 C)) and (FOO ABC) read in as equal structures.Q.st encountering data tgpe. C) or worse.g. expression. Although most lists terminate in NIL.equivalent to (MEMBER (CAR X) (QUOTE FOO))..st.!?!: is the value or its first TRUE.(A B)J reverse[(A B • C)]=reverse[(A B)] 2.s u.!:. if' ~=(A B C). a number or string..s..strtng. etc. member. length.

st.empt. of 1Vll and cdr of 1VIL are always NIL.FLAST. the user .y] i.s of these Junctions in the text.scribed as a function of one argument.suggestive names are u.strings and arrays are not li. have 'argument names' .s true.st.s. However.sed to test for li. !.system parameters. "! i.as read. nth.g.6). flast.e . i.st. SUBRS.s.scribed in the writeup. 1 we have provided fast versions of' memb. eval • . e. and it.ill: loops if given poorly formed arguments. linelenath. nl. it does not have to end in 11/IL.ample.sed in the de. fa~. mo. a. See Section 10.g. 2.sed by the Junctions getd and putd de.. a value cell initialized to the atom 1t!OBI1VD (Section 1. number11.s. In particular. When new literal atoms are created (by the read program. to help detect these situations. Jor tutorial purpo.stem will re.st ignore the extra arguments.structure created by one or more con. W. and a property Li.g. ££.st(R£ADLIN£} returns <RDTBL LIN£ LISPXFLGJ. fnth.e. Y.• ! and ll are the .!!2_. e. fmcmb. e.s t. pack. (A ..s a l i.append[(A B ..s opposed to "! i. The term list refers to any . Mo.se.st att.. hand coded functions.. V. ~· .set . etc .setting. BAD ARGUMENT .st functions that .setq. In .scribed in Section 8.s to change them.s ~ to Y.setq. . i.Q.system functions have extra optional arguments for internal u.scription.s cdr of the atom.I!· exprp. but arglt.s an argument.sg.st i.st functions whose names end in I! are predicates.. The value eel l of an atom i.il. Section 5. printlevel. i. do not require quoting their arguments.s. they return the current value without changing it.stp.selected from U. and length which compile open and terminate on NIL checks.!!. C).se.sarily imply an atom.s. i.s.g.scribed under argli. Z. readline is de.g .s true.st. X. i.s. and-riie .se that are not de. . IJ given Nil a.. Section 8. Note that not being a list doe.. last.s property Li.3 . e.e. or mk. defineq. The Junction definition cell ts acce.same identical LISP pointer. more . print.!. .such.should Ju. e.st initialized to 1tlll (Section 7). return a. tl1cy are provided with a Junction definition cell initialized to NIL (Section 8).s de." means equal[x:y} i.s.s not nece.. radix.st functions whose names end in~ are nlambda'.y]:append[(A B).s their value the old .s u. All No. and therefore may cause infinite £. For ex. Many . · The Ju net ion li. and flength all generate errors when interpreted if their argument ends in a non-list other than NIL." meaning eq[x.atom). However. a. 8) i. nor ore they atoms.ses. etc .s equal to u.such ca.s car of the atom.y] For users with an application requiring extreme efficiency.£.ample.e . For ex.

followed . an error is generated. However. The user can then conttnue his program with no ill effects with the TENEX CONTINUE command. If typed during a garbage the garbage collection will first be completed.-. user line. control returns .· the user types typing control·C at any point in the computation returns control ir.unediately to TENEX.g£ of a form never evaluated. type an identifying message. must be used if the name of a function is to be ~ ~· or (section 8) computed as for example.r i! DEFI1V/TElY not adui. even if. REENTER command. !£ill is followed by a "talking to" This level as 1 @1 format: if just one expression is typed on a ~-ed to In both cases. NLAMBDA. to INTERLISP'S top immediately. ihat the called evalgt. when functional arguments are applied. 2. £.INTERLISP departs from LISP L5 and other LISP dialects in that i. INTERLISP will i.e. and then control returned . LOGOUT(). otherwise. top just i f . the (for historical reasons).!Uated. Typing control·D at any point during a computation collection~ will be will return ·control to evalqt.4 level. or FUNARG. indicates the user is talking to TENEX. he interrupted it during a garbage collection. . the first is by~ ·~·. the date. the indicating INTERLISP is ready for another input. if i l l of a form is not an atom with n function definition.!X are described in section 8.2 Using the INTERLISP·10 System on TENEX ·An Overview Call INTERLISP-10 by typing LISP followed by a carriage return. In other words.able U the Control-C !!!E typed during !! garbage collection.. and a prompt character INTERLISP indicates executive.-. eval and !1!J?. the second. 2. of which is LAMBDA. i t is !Y. and not a function object. inputs in either eval or greet~ng. Or he can reenter his program at evalgt with the TENEX lli lJ!!!!. value is typed. Le.!. a list ill.two expressions are typed. evalqt calls l ispx which accepts. INTERLISP is normally exited via the function LOGOUT.

the read program automatically supplies (and prints) this carriage return when a matching right parenthesis is typed. echoing a \ and the erased character. e. 1 ) 1 is used throughout the manual to denote carriage-return.·..:~~--~~. addition.~~. control-Q will only affect at most the last line of input. and reference to that part of the manual where they are described.:· ~.f·· ~~~.-~~~-t~~-1--Q··.5 . 0 0 'typed ahead' several inputs.. making it unnecessary for the user to do so.. 3 4 Except following control[TJ..us·. Typing control-A erases the last charactor typed in...e..When typing to the INTERLISP read program._a_c_t_i_o_n_ . i.. as well as how the user can define his own interrupt characters..~.·. even during a garbage collection. 3 the user must type a carriage return before any characters are delivered to the function requesting input. when the read is Appendix 3 contains a list of all control characters. coNS(A B) (A • B) 2-. . beyond the last carriage return. i. INTERLISP to print up to the 1 ## 1 typing a control-Q will cause and clear the input buffer.."' ln typing controlmU (in most cases) will cause the INTERLISP editor (Sect ion 9) completed.> T 4 However. Since the INTERLISP read program is normally line-buffered to make possible the action of control-Q.> and rubout to immediately clear the input buffer.. 2.. Control-A will not back up to be called on tha expression being read. see Section 14. Rubout however will clear the entire input buffer as soon as it is typed. G>E T.g. a Section 16 describes how the system's interrupt characters can be disabled or redefined. e. the output buffer..g.·.~ -~~·-. erase the entire line last carriage return...~.~~:.e. Control-0 can be used to immediately clear '..

2. following brief console session.g. see appendix 3. + other character has no effect.e. are illustrated in the Underlined characters were typed by the user. Functions may independently evaluate arguments. ABX (C or ""· See Section 14 for more details.• left square bracket (in the expression beihg read). error handling. Thus to input an atom containing a syntactic delimiter. control•D. The user defines· a . B.. tV followed by any For more Most of the "basics" of on. In (Section 8).-unction. shown here is an example of an The function fact everyday run•of-the-mill function of one argument.g. FOOtV1 and F001 are identical. editing..6 ..g. precede it by"· e. which is evaluated.g. . INTERLISP. and a The prompt character• indicates the user is at the top level or INTERLISP. i. + following tV is A. The user calls INTERLISP from TENEX. ~~· Z. ( A ( B ( CJ·= (A ( B ( C)) ) . or not evaluate them. control•C. defining functions. + details. etc. for computing factorial of n. functions are defined via DEFINE or DEFINEQ.The INT ERL ISP read program treats square brackets as 'super-parentheses 1 : a right square bracket automatically supplies enough right parentheses to match back to the has la~t appea~e~~ e. (A (8 (C (D] E)=(A (B (C (0))) E).g. or if none to match the first left parentheses. e. and spread their arguments. If the characte~ chara~ter is input. saving your work. + 1v (control-V) can be used to type a control character that would otherwise + interrupt the input process.. greeting. ' 2.line use of INTERLISP. + e. •. the corresportding control tVATVBTVC is the atom control•Acontrol•Bcontrol·C. e. !!. etc. % is the universal escape character for read. 1. or not spread them (Section 4).tl. INTERLISP prints a date.

7 ..> FACT :RETURN 1. 1 13 FACT) 14 2..1 @LISP.> IT IMES COND FACT 6 LAMBDDA [IN FACT) -> LAMBDA ? YESJ FACTT [IN FACT) -> FACT ? YES.> 12 (FACT [LAMBDA ( N) ccorw (( EQ N 0) 1) FACT (T (!TIMES N (FACT (SUBl N]) ~PRETTYOEF((FACT) FACT. .> INTERLISP-10 11-17-73 .>- corm FACT COND FACT """'TOP"'"' =!U 7 :EDITF(FACT) EDIT ""(R NIL 1) 1110K. (LAMBDDA (N) (COND ((EQ N 0) NIL) (T (ITIMES N (FACTT (SUB1 N] (FACT) ~CGETD (QUOTE FACT)} (LAMBDDA (N) (CONO ((EQ N O) NIL) (T (ITIMES N (FACTT (SUBl N)))))) ~DEFINEO((FACT 2 3 ~FACT(3) 4 NON-NUMERIC ARG NIL HI !TIMES 5 (BROKEN) :BT. GOOD EVENING....> 'BREAK' = 1 8 1 9 10 11 6 ~PP FACT.

interpreted . In INTERLISP. and in both cases. and then continues the computation. The user "looks" at the function definition.8 At This . 2. facility is very useful for debugging.e. i. modified in va~ious ~s the names and values The stack can be searched and/or ways (see Section 12). the user can type in expressions to be eval•ed or apply-ed exactly a~ at the top level. i. Two errors occur and corrections are off. which calls for a back trace to be. getd and putd. BT.se putd). and the system goes into a break. as well of its arguments are stored on the stack. by DWIM (Section 17). for~· the user typed an input consisting of a single (GETD (QUOTE FACT)).that expression. 6. DWIM makes the correction. An error occurs tha't DWIM cannot handle. which is associated with the name of the function (Section 8). At this point. INTERLISP are stored in a special cell called the Function definitions functi~n in definition cell.e.e. the user indicates his approval. form 4. the name of the function that was called.e.3. printed.· (define and defineq u. The user types in the break conunand. i. The user runs his function.ered In each case. Note . the system is actually "within" or "below" the call to itimes in which the error occurred.and compiled code (see Section 18 for discussion of the compiler) are completely compatible. Break commands ·are discussed in Section 15. i. This cell is accessible via the two functions. which was therefore interpreted as a The user could also have typed GETD(FACT). that the context or his computation is available. actually changes the definition of fact. The prompt character •i• indicat~s that the user is in a break. that point the user can examine the state of the computation. In other words. specify that the system go into a "break" whenever a certain function or functions are called. 5. which also explains how the user can "break" a particular function.

which when loaded into INTERLISP at a later date via the function 12!!! (Section 14).e. and calls the editor to fix _it. Section 9 begins with a simple introduction designed for the new user. and the value cell contains the atom NOB IND. 8. 10. fact(3). it is as it is now being interpreted. asks it be printed with appropriate indentations to indicate structure. the most recent value. or binding.7. has been changed.9 . i. and 6 is ultimately returned as the value of the original input. an unbound atom error is generated (Section 16). This causes the computation to continue. a comment facility. The user instructs the editor to replace all NIL's (in this case there is only one) by 1. his function. The interpreter will search the stack for the most recent binding.£! to be defined. The editor physically changes the expression operating on so when the user exits from the editor.. will obtain the top level value from the atom's value cell.£!!: of the atom (Section 3).as 2. The user writes his function on a file by using prettydef (Section 14). Prettyprint also provides Note that both the changes made to fact by the editor and those made by DWIM are in evidence.1. (Note that the system is still in the break. creating a TENEX file. 9. which is . FACT. 12. The user specifies the value to be used by itimes in place of NIL by using the break command RETURN. It is an extremely useful facility of INTERLISP.e. will cause!!. and failing to find one. The user exits from the editor and returns to the break. The user prettyprints (Section 14) fact.) The editor is described at length and in detail in Section 9. The user asks for the value of the variable Il• i. 11. If there are no bindings. The user realizes his error. 13.

.currently is.10 However. restoring an There is also a facility in INTERLISP for saving and entire core image via the functions sysout and sysin (Section 14). The user . logs ·out. he can still INTERLISP via . 14. 2. continue his session by re-entering CONTINUE command.the TENEX REENTER or .it. returning control to TENEX.

3 2.Y] SLIBR equal EOUAL[X.3 2.8 2.Y] files FLAST[X] 2.4.3 2.4 2.3.3 2.TTBL] SUBR control characters control-A control-C control-D control-0 2.3 2.2 .6 2.5 2.2 2.4 2.3 control-Q control-U control-\/ debugging DEFINE[ X} DEFINEQ( X] NL11 dot notation DWIM eq EQ[X.5 2.2 2.3 2.9 2.5 2.8 2.8 2.3 2.V] escape character EVAL[X] SUBR eval format EVALQT FASSOC[X. .3 2.4·5 2.3 2.8 FLENGTH[ X] FMEMB(X.Y] FNTH[X.4 2.3 2.3 IHL HLISTP[ X] NOB mo null-check predicates INDEX .8 2.2 2.4 2.LDFLG.3 2.8 2.4 2.PRINTFLGJ LOGOUT[] SUBR 2.6.10 2.3.4 2.4 2.4 2.5 2.3 2.9 2.4 2.ARGn] SUBR~ ARGUST[ X] back trace BAD ARGUMENT FASSOC (arror message) BAD ARGUMENT FLAST (error message) BAD ARGUMENT FLENGTH (error message) BAD ARGUMENT FMEMB (error message) BAD ARGUMENT FNTH (error message) BT (break command) cornrnuE ( tenex conunand) CONTROL[U.6 2.8 2.3.Index for Section 2 Page Numbers APPLY[FN.N] function definition cell functional arguments garbage collection GE TD[ X] SUBR interrupt characters LINELENGTH[N] SUBR line-buffering LISTP[X] SUBR lists LOAD[FILE.5 2.3 2.3 2.9 2.8 2.ARGS] SUBR apply format APPLY*[F11.3 2.5 2.4 2.3 2.6.1 .8 2.3 2.2 2.ARG1.5 2.4.

....... ..9•10 2....• ... .... ... .. ............••• variable bindings ) (carriage-return) ## (typed by sy$tem) % (escape character) notation (typed by system) \ (typed by system) • ] ~ • ..5 2..........Y] SUBR RADIX(N) SUBR REENTER (tenex command) RETURN (break command) rubout ....... ... ....4................ ............2 2..5 2................ . .......6 ... ....4. .............4..8 2. square brackets SYSIN(FILE] SUBR SYSOUT[FILE) EXPR TENEX true user interrupt c~aracters U......5 2......... ... .... . .5 2. ...10 2.......3 2..4.. ..... ........3 2.... .. . .. ...10 2 ........ .... ..... ........ ..... ........................ ...... ..3 2........ . ~ 9: • • • • • • • • • • • • • • • • • • • • • ..... ..................3 2..... .. ............2. ..........A... .•......3.6............ . . ... ..................................... •....... .......Page Numbers ........ ...... ... PRETTYDEF PRETTY PRINT PRINTLEVEL(N] SUBR prompt character property list pushdown list PUTD(X.....9 2..... •. (typed by system) ..10 2......... (error message) value cell . • • • • • • ~ INDEX....2 2..9 2... . .. ............2 2.. ....................8 2......9 2.S.8 2.9 2.. .6 2.........6...5 2.................6 2..6 2.. . ..9 2.....8 2.....

3. atom. 3. AND OVERLA\'S 1 INTERLISP operates in an 18-bit address space. large ahd small integers. on which INTERLISP was first implemented. what input sequence will cause the INTERLISP read program to construct an element of that 1--------------------------------a-•o•-----------G----------------------------This section was written by A. INTERLISP address space. K.1 Data Types The data types of INTERLISP are lists. W. as described in section 23. 2 This address space is divided into 512 word pages with a limit of 512 pages. first the input syntax and output format are described. etc.SECTION 3 DATA TYPES. In the descriptions of the various data types given below. Where this is the case. any storage itself and all data storage are contained within this A pointer to a data element such as a number. 3 Compiled code and hash arrays are currently included with arrays. The user can also define new data types. atoms. is simply the address of the data element in this 18°bit address space. GARBAGE COLLECTION. the implementation. pnames. floating point numbers. string characters and string pointers. for each data type.1 + + + + + .144 words. arrays. Hartley and J. for the DEC PDP-10. 2 3 INTERLISP is currently implemented on (or implementations are in progress for) at least four different machines. that is.. This section treats subjects that are for the most part somewhat implementation dependent. the discussion refers to INTERLISP-10. Goodwin. or 262. STORAGE ALLOCATION. but only that portion of address space currently in use actually exists on medium.

1. Note that some data types cannot be input. C. i.% ( ) " J and[. print the same. they are not stored in the atom's pname. Next. or equivalently. the format in which an element or that data type is stored in memory is described. Literal atoms are printed by print and prinZ as a sequence of characters with %'s inserted before all delimiting characters (so that the atom will read back in properly). Literal atoms are printed by print as a sequence of characters without extra %'s. The syn ta tic characters that delimit atoms are space.and ABC(D by prinl. they will. end-of-line. mkatom. B. Finally. they can only be constructed.g. the five characters A. that is. they will always be the same identical atom. be However. Literal atoms are unique.e. always have the same address in memory. and how the INTERLISP print program will print such an element. 4 line-feed. arrays.2 . and D will be printed as ABC%(D by print. those functions that construct elements or that data type are given. they 3.1 Literal Atoms A literal atom is input as any string of non-delimiting characters that cannot be interpreted as a number. if two literal atoms have the same pname. these characters may included in atoms by preceding them with the escape character %. Literal atoms can be constructed by pack.type. and gensym (which uses mkatom). The extra %'s are an artifact of the print program. these For example. (. e. the atom consisting of . 3. In other words.

will always be ~· 6 Thus if pack or mkatom is given a list of' characters corresponding to a literal atom that already exists. and do not make a new atom. Similarly.3 it . returns a pointer to that atom. if the read program is given as input of a sequence of characters for which an atom already exists. they return a pointer to that atom. 3.

4 . or compiled code).• EXPR.A literal atom is a 3 word (36 bits) datum containing: PROPERTY LI ST (CDR) WORD I: 0 WORD 2: TOP LEVEL BINDING (CAR) 17 18 35 FUNCTION CALLING INSTRUCTION 0 WORD 3: PNAME 0 I 35 RESERVED FOR FUNCTIONS ON FILES 17 18 35 I FIGURE 3-1 Car of a literal atom. contains its top level binding. the right half is a pointer to the function definition. if any. containing an instruction to be executed for calling the function associated with that atom. the function definition cell.£!!!: of the atom is a pointer to its property list.e. The remaining half word is reserved for an extension of INTERLISP-10 to permit storing function definitions on files. i. ~lord 2.e . 3. is a full 36 bit word. contains a pointer to the pname of the atom. the left half of the third word. the right half of word 1. SUBR. 6 The pname cell. initially the atom NOBIND • . initially NIL. The left half differs for different function types (i.

since we define a pname simply to bo how that pointer is printed. do not have property lists. or explicit pnames. the atom. The first character of a pname contains its length. A pname is a sequence of 7 bit characters packed 5 to a word. the use of' the term pname in a discussion of data types or storage allocation means pnames of atoms or strings. beginning at a word boundary. and floating point numbers. Integers The input syntax for an integer is an optional sign (+ or ·) followed by a I 7-----------------------------------------------------------------------------All INTERLISP pointers have pnames.word of. Thus. only literal atoms and strings have their pnames explicitly stored. 3. 3.1. for example. and refers to~ sequence of characters stored in a·certain part of INTERLISP'S memory.3 Numerical Atoms Numerical atoms. This data type only It does not appear.3. functions definition cells. occurs as a component of an atom or a string. comprise another data type with storage assigned as it is needed. There are currently two types of numbers in INTERLISP: iritegers. Pnames . have no input syntax or output format as they cannot be directly referenced by user programs. value cells.5 .Z Pnames The pnames of atoms/ pointed to in the third .t. or simply numbers. as an element of a list. thus the maximum length of a pname is 126 characters. However.

e.g. 9 If the sequence of digits used to create the integer is too large. followed by an optional Q. a few pages of address space. While small integers have a unique representation. overlapping the INTERLISP-10 machine language code. 9 To avoid having to store (and hence garbage collect) the values of small integers. (The handling of overflow as a result of arithmetic operations is discussed in Section 13. octal or decimal. as described in Section 13. other words. but not tho same address in memory. The setting of ~ (Section 14).g. Integers are created by pack and mkatom when given a sequence of characters observing the above syntax. 1 small' integers is -1536 thru +1535. 8 If the Q is present. are reserved for their representation. and therefore not be ~· For this reason the function ~ (or equal) should be used to test equality of large integers. large integers do not. and in fact are indistinguishable internally since no record is kept of how integers were created. otherwise in decimal. 77Q and 63 both correspond to the same integers. Integers are also created as a result of arithmetic operations. the digits are interpreted in octal.6 . In two large integers may have the same value. An integer is stored in one 36 bit word. The small number pointer Currently the range of The predicate smallp is used to test whether an integer is 'small'. (PACK (LIST 1 Z (QUOTE Q))) = 10. is the value of the number. itself. e. the high order portion is discarded.sequence of digits. minus a constant.) 3. determines how integers are printed: signed or unsigned. thus its magnitude must be less than 2t35.

or free format. followed by a decimal point. followed by an exponent (represented by E followed by a signed integer).2E+6 0 Floating 5E2 5 . for example.0 5. 5.00 5. The range is ~2. but at least one of them must be present to distinguish a floating point number from an integer. 10 Both signs are optional.3 .7 . is initialized to T.Floating Point Numbers A floating point number is input as a signed integer. the above floating point numbers would be printed free format as: 5.1E2 point numbers are printed using the facilities provided by TENEX.94E-39 thru ~1. 3.005 -5. the following will be recognized as floating point numbers: 5. followed by another sequence of digits called the fraction.0 floating point numbers are also created by pack and mkatomo and as a result of arithmetic operations as described in section 13. INTE. 20-·--------·----•••••••••o••m•••••••••••••••••a•o•••••••m•••o••••••••-•••••-•• and terminated by a delimiter.0 5.3 SE 3 ·5.RLISP-10 calls the :floating point number to string conversion routines 11 using the format control specified by the function fltfmt (Section 14). fltfmt F'or example. and either the fraction following the decimal point. or the integer preceding the decimal point may be omitted. One or the other of the decimal point or exponent may also be omitted. 11 Add i t ion al information concerning these conversions may be obtained from the TENEX JSYS Manual.0 510.01 .69£38 (or 2t·128 thru 2t127). A floating point number is stored in one 36 bit word in standard PDP-10 format.01 .2£6 500.

g.4 Lists The input syntax for a list is a sequence (at least one) 12 of INTERLISP data elements. (delimited on both sides).3.s. e. and that (A B . as described in Section 2. then printing the second element. O).. £9. the final element can be preceded by a .nts of a list are printed using prin2 if the list is being printed by print or prin2.g. 3. e. 13 Note that in INTERLISP terminology. indicating that cdr of the final node in the list is to be the element immediately following CA B C . 1 t is simply a structure composed of one or more conses. and by 2rint if the list is being printed by prin1. If cdr of the terminal node is not NIL. until the final node is reached. 14 then printing a space.g. atoms numbers. case). £!!:.!: of this terminal node is NIL (the usual is printed followed by a right parenthesis. ------------------------~-----------------------------------------------------12 () is read as the atom NIL. 14 The individual eleme. and then printin~ the first element of the list. NIL) is thus equivalent to (AB C).£2!1! and .1.5£!. etc.!.8 . a list does not have to end in NIL.of the terminal ~ode If Lists are considered io terminate when .!.!: of some node is not a list. otherwise . e.!!· Lists are printed by printing a left parenthesis. (C D)) is thus equivalent to (A 8 C 0) . literal parentheses or brackets.. other enclosed lists. etc. 13 Note that the input sequence (A B C . Lists are constructed by the primitive functions . i l l of the terminal node is printed. (A (B (CJ.ru: the •. If there are two or more elements in a list. (A • B) or of the last node in a list will be NIL. in A bracket can be used to terminate several lists.• Note however that (AB • CO) will create a list containing the five literal atoms A B • C and O.

and prinl. Arrays are printed by both print. Arrays do not have input syntax. 5 Arrays An array in INTERLISP is a one dimensional block of contiguous storage of arbitrary length. and therefore not collections. and a list input as (A B . # Array elements can be referenced by the functions ill and !. The unboxed number region· of an array is used to store 36 bit quantities that are not INTERLISP pointers •. and that carriage returns may be inserted where dictated by linelength. prin2. a section containing containing relocation information.9 during spe~ifies which . (C D)) will print as (A B C 0).g. 3. 1. Arrays are partitioned into· four sections: a header. and a section The last three sections can each be of arbitrary length (including O). they can only be created by the function array. ill of the terminal node.£!. a section containing INTERLISP pointers. to be chased from garbage The relocation informaion is used when the array contains the definition of a compiled function. Note also that printlevel affects the printing of lists to teletype. A list node is stored in one 36 bit word. the header is two words long and contains 'the length of the other sections as indicated in the diagram below. Note that a list input as (A B C • NIL) will print as (A B C). as described in Section 10.followed by a space. another space. A list is stored as a chain of list nodes. and then the right parenthesis.!: of the list (a pointer to the first element of the list).lls!• and set by the functions !ill and setd. a period. and the left half containing ill of the list (a pointer to the next node of the list). as followed by the address of the array pointer (in octal). as described in Section 14. the right half containing . and 3. unboxed numbers. e. machine instructions.

The format of an array is as follows: HEADER WORD 0 WORD ADDRESS OF RELOCATION INFORMATION USED BY GARBAGE COLLECTOR LENGTH ADDRESS OF POINTERS FIRST DATA WORD NON-POINTERS POINTERS RELOCATION INFORMATION FIGURE 3-2 The header contains: word 0 word 1 3. 3 . right address of pointers relative to word O of block. left address of relocation information relative to word O of block (> O if relocation information exists.locations in the unboxed region of the array must be changed if the array is moved during a garbage collection. terminated by a followed by a sequence of any characters 11 • 11 • " and % may .10 . 0 if ordinary array). negative if array is a hash array. left used by garbage collector.6 right length of entire block=ARRA\'SIZE+2. be included in a string by preceding them with the escape character %. Strings The input syntax for a string is a except 11 and %.1.

in turn. thus av. Strings are created by mkstring. This method of storing strings permits the creation of a substring by creating a new string pointer. see Section 10. String pointers and string characters are two separate data types. and the number of characters.11 . pointer. String characters are 7 bit bytes packed 5 to a word.oiding copying of the characters.Strings are printed by print and prin2 with initial and final "'s. 3. a string pointer and the sequence of characters. The format of a string pointer is: # OF CHARACTERS 0 14 5 * ADDRESS OF STRING + CHARACTER POSITION . substring. by prinl without the delimiting "'sand extr~ Strings are printed %'s. contains the character position at which the string characters begin. For more details. 15 and several string pointers may reference the same characters. The INTERLISP pointer to a string is the address of the string The string pointer. 35 15 FIGURE 3-3 The maximum length or a string is 32K (K=1024) characters. Internally a string is stored in two parts. and concat. and %'s inserted where necessary for it to read back in properly.

mkstring. For example. all occupy 1 word except atoms which use 3 words. The storage allocation and garbage collection methods differ for the various data types.. meaning that the space is reserved for storage of elements of that type. a garbage collection is initiated. The major distinction is between the types with elements of fixed length and the types with elements of arbitrary length. when a large integer is created by iplus.is needed by the functions which create new data elements. The page is the smallest unit of memory that may be assigned for use by a particular data type. such as £2.3. additional storage is assigned only during a garbage col)ection.2 Storage Allocation and Garbage Collection In the following discussion. and strings (string characters) are variable length. floating point numbers. Storage is allocated as . pnames. and string pointers are fixed length. type table. the integer is stored in the next available location in the space assigned to integers. atoms. which may result in more storage being assigned. List node. large integers.!:!!• pack. A small amount of storage is assigned to each data type when !NTERLISP-10 is started. Elements of fixed length types are stored so that they do not overlap page 3 . for each page of memory there is a one word entry in a The entry contains the data type residing on the page as well as other information about the page. The type of a pointer is determined by examining the appropriate entry in the type table. Allocatton will refer to the process used to obtain from the already assigned storage a particular location for storing one data element. we will speak of a quantity of memory being assigned to a particular data type. Arrays.s. If there is no available location.12 .

. The garbage collector determines what data is currently in use and reclaims that which is no longer in use. (i.13 .e. each available location contains a pointer to the next available location. A new element is stored at the first location on the free-list. A garbage collection may also be initiated by the user with the function reclaim (S~ction 10). adjacent. 16 Elements of variable length data types are allowed to overlap page boundaries. beginning with the contents or the push-down lists and the components (i. Consequently all pages assigned to a particular variable length type must be contiguous. When the allocation routine for a type determines that no more space is available in the assigned storage for that type.Thus the pages assigned to a fixed length type need not be boundaries. and function definition cell) of all atoms with at least one non-trivial component~ i6--•--••-•-•••••••••••-••••••0~Du•oaaaaaao••OGoooao•••••••••••••••••••••-••••• The allocation routine for list nodes is more complicated. . Lists are the only data type which operate this way. When INTERLISP-10 is first called. If more space is needed.!:• . any empty page will be used. Data in use (also called active data) is any data that can be •reached' from the currently running program execution) or from atoms. First a page is chosen (see CONS for details). a garbage collection is initiated. then the free list for that page is used. ·variable bindings and functions in To find the active data the garbage collector 'chases• all pointers. · 3.£!.. Space for a new element is allocated following the last space used in the assigned block of contiguous storage. Each page containing list nodes has a separate free list.£!!!:.e. The method of allocating storage for these types employs a free list of available locations. and the free-list pointer is updated. a few pages of memory are assigned to each data type. 0 that is.

14 . Host data types are marked using bit tables: that is tables containing one bit for each datum. all However. If the amount of storage reclaimed for the type that initiated the garbage collection is less than the minimum free storage requirement for that type. The garbage collector as Signs additional storage to fixed length types by finding empty pages. and then a scan or all active data that can contain point~ts tci the moved data is performed to update the pointers. When the mark and chase process is completed. Arrays. 17 unused space for fixed length types is reclaimed since the additional cost is ·sUght.ked using a half-word in the array header. thereby avoiding the time consuming process of updating all pointers to moved data. the garbage collector will assign enough additional storage to free storage requirement. it is marked. space for a variable length type is reclaimed only when that type initiated the garbage collection. and all pointers contained in it are chased.--~---------------------·--------------------------------------~------------The 'type of a garbage collection• or the •type that initiated a garb•ge collection' means either the type that ran out of space and called the garbage collector. Whenever a garbage collection or any type is initiated. s~tisfy the minimum The minimum free storage requirement for each data may be set with the function minfs (Section 10).When a previously unmarked datum is encountered. To reclaim unused space in a block of storage assigned to a variable length type. and adding the appropriate size elements from each page to the free list. This free list allocaticin method permits reclaiming space without movirtg any djta. the active elements are compacted toward the beginning of tho storage block. Assigning i. unmarked (and therefore unused) space is reclaimed. or the argument to reclaim. are mar. 3. longer active ad~ing their locations to th~ free-list for that type. however. are reclaimed by Elements or fixed length types that are no.

As a Similarly. In addition to increasing the storage assigned to the type initiating a garbage collection. storage is added.3 Shared INTERLISP-10 The INTERLISP-10 system initially obtained by the user is shared. if the user changes anything in the original shared INTERLISP-10. private pages are added to his memory. 3. if the minfs setting is 2000 words. 3. that is.15 . 512 additional words would be assigned. the number of active words has increased by 700. If available no more for example. user adds to the system. a private copy of the changed page is created. storage is increased to i/2 minfs. active data has increased by less than 1/4 of the minfs value. 1024 additional words (two pages) will be assigned to bring the total to 2024 words available. the garbage collector will attempt to minimize garbage collections by assigning more storage to other fixed length types according to the following algorithm .additional storage to a variable length type involves finding empty pages and moving data so that the empty pages are at tha end of the block of storage assigned to that type. and there were 500 words available. If there has been no increase. all active users of INTERLISP-10 are actually using the same pages of memory. by advising a system function. for example. If the number of active words had increased by only 300. to attain the ~ value. 18 Xf the amount of active data of a type has increased since the last garbage collection by more than 1/4 of the minfs value for that type. i8--------------------··o•···----·--·-·-···-··········-··u••••••••••••e•-·-··-· We may experiment with different algorithms. storage is increased (if necessary). and after all unused words have been collected there are 1000 words available.

making the system be shared will result in a savings in swapping time. the savings in time will vanish. because once a page that was initially shared is made private. or GET and START. Since every pointer on an initially shared but now private page can also point to private data. the sharing mechanism permits a large saving in garbage collection time. i. 19 + + 19------------------------------·--------~------------------------------------makesys is also advised (see section 19) to set the variable makesysdate to (DATE). 3.In addition to the swapping time saved by having several users accessing the same memory. since we do not have to garbage collect any data in the shared system. Similarly. because it may be pointed to by something in the shared system. For example. and may therefore be make sys[ file] wo~thwhile even if the system is only being used by one user. new INTERLISP-10 systems are brought up by loading the appropriate compiled files and then performing makesys[LISP. the time and date the system was made.SAVJ. This reduction in garbage collection time is possible because the shared system usually is not modified very much by the user.e. If the shared system is changed extensively. i.16 . and thus do not need to chase from any pointers on shared pages during garbage collections. shared. every pointer on it must be assumed active. including private user pages. creates a saved file in which all pages in this system.e. if a system is large and seldom modified. A user may create his own shared system with the function make sys. they must always be chased. If several people are using the same system. making it be shared Will result in a reduction of garbage collection time. are made This system can then be run via the TENEX command RUN. read execute.

e. Goodwin. makesys can be given as a second argument a string to be used instead of "INTERLISP-10". Alternatively. 20 The INTERLISP-10 Swapper 2 i 3. Wegbreit (PARC)· and J. 22 + Shadow space and the swapper are intended to be more or less transparent to the + user.4 INTERLISP-10 + provides a very large auxilary address space exclusively for swappable arrays (primarily compiled function definitions). printed when the system is first + Primarily for use in conjunction with + • makesys. could be expanded to 121 million words.5 million words.herald[ string] makes string be the 'herald' for the system.17 + + + + + + . this "shadow space" can currently accomodate + an additonal 256K words. and with + some further modifications. + + 22 Since compiled code arrays point to atoms for function names. can easily be expanded to 3. this section is included in the manual to give programmers a + reasonable feeling for what overlays are like. + 20----------------------------------------------------------------------------makesvs is advised ~o set the variable heraldstring to the concatenation + of "INTERLISP-10".SAV was run. . the message started. W. + + 3. the month and day of the makesys. W. . without getting unnecessarily • technical. since much of the system and user compiled code can be made swappable. which are typically lists rather than arrays. e.STAR·TREK] would cause the message STAR-TREK followed by the date and"···" to be printed when STREK. makesys[STREK. However. Goodwin (BBN). + 256K Thus. there is still a very real and finite limit to the total size of programs that INTERLISP-10 can accomodate.g. i. The INTERLISP-to ~wapper was designed by E. the overlay system provides essentially unlimited space for compiled code. and 11 . and strings for error messages. + In addition to the + of resident address space. there is that much more resident space available for these other data types. However. and implemented by J. as well as to document some new functions and system controls which + may be of interest for authors of exceptionally large systems. " and to call herald on this string. L. + + + + 2J.SAV. not to mention the fact that programs usually have data base.

auxiliary address space used exclusively for + an INTERLISP data type called a swappable array. atoms. + called the "resident" space to distinguish it from shadow space. etc. fetch + them back in if they have. or a hash array - The resident space occupied lists. fetch them into the buffer (if + not already there). + by the original array can then be garbage collected normally (assuming there + are no remaining pointers to it. a swappable array can be made resident again at any time. it is brought (swapped) in by mapping or overlaying the pages of + shadow space in which i t lies onto a section of the swapping buffer.18 . from which the system takes its name.1 Overlays + The shadow space is a very large. + The main purpose and intent of the swapping system is to permit utilization of + swappable arrays directly and interchangeably with resident arrays. + The array is now (directly) accessible.4.+ 3. Thus all system code that relates to arrays must + recognize handles as a special kind of array. pointer data. + This is accomplished as follows: A section of the resident address space is + permanently reserved for a swapping buffer. Th is However. + could cause the array to be overlaid with something else. + resident array - + can be copied into shadow space ("made swappable"). such as The regular address space is Any kind of compiled code. and it has not been made shared by a makesys). and even be prepared for the second fetch to bring + the swappable array in + 23---------------------------------------··-----------------------------------Currently 64 512 word pages. thereby + saving resident space which is then available for other data types. but of + course this requires (re)allocating the necessary resident space. so in effect it is + liable to go away at any time. + Similarly. 3. further requests for swapping at a different place than did the first. when necessary check that they have not disappeared. binary data. from which it is referred + to by a one-word resident entity called a handle. 23 ~hen a particular swappable array + is requested. strings. + process is the swapping or overlaying .

The net slowdown due to this extra level of indirection is too small to measure accurately in tho overall running of a program. and will generate ARG NOT ARRAY errors i f called + with one.. note that + programs which generate and use pointers directly into the bodies of arrays. • b~~~.4.:h. Thus.._r_e_g_i_s_t·e·r·. and in fact + ccodep will be true for either. etc.--i~~~~~~-t-i~~-s.-.~ i~~~ ~~i. and then users will be free to copy resident data arrays into swappable ones or vice-versa. !!!!• gethash. since they cannot fetch the array in. or + take CAR or CDR of them.~~k.3 + Efficiency Once of the most impor. will not work..tant design goals for the overlay system was that + swappable code should not execute any extra instructions compared to resident + code.~. On analytical grounds.4. However..~ ..~. + This will be fixed someday. + nor guarantee that it would not go away. 24 and similarly when a swappable + 24· • . 3. puthash. there is no need to distinguish between swappable and resident compiled definitions. because this accounts for the overwhelming majority of + arrays in typical systems. and brings it in + otherwise.·.d·b. finds it in the buffer if it is already there. + 3.-. Thus.-a-. run equally well at any location in the buffer.19 + + + + + . once it had been swapped in.2 + The Non-Code Arrays data-array functions (elt.) do not yet + recognize swappable arrays. + The system supports the running of compiled code directly from the swapping + buffer. and for as much as 60% of the overall data and codo. and the function calling mechanism knows when a swappable definition is + being called. the instructions of a swappable piece + of code are identical (except for two instructions at the entry point) to those + of the resident code from which it was copied.The major emphasis in the design of the overlay system has been placed on + running compiled code.. from the user's point of view.e--t~d. + 3. one would expect it to be around 2%.i.

+ function calls another function (of any kind) it uses the exact same calling + sequence as any other code.4. argtype. if no swapping is done in between. and + + + ~~----------------------------------------------------------------------------If the function in question does nothing. 9etd. plus however much of + shadow space needed for the body of the array. 3. ·~ swappable code are paid at the point of entry (both calling and returning). However. 26 + The cost of the swapping itself. i. arglist. changename.20 . which has a high probability of faulting. since two successive + fetches of the same function are not the same. nargs. i t costs approximately twice as much . another morass of uncertainty. f. is even harder to measure meaningfully.g. putd. and are (typically) entered frequently.to enter 1 ts definition if it is swappable as compared to resident. This raises the problem of measuring page fault activity. e. + + + + + + + + + 26 The cost of fetching is probably not in the mapping operation itself but in the first reference to the page.a + difficult constraint to meet in itself .e. break.4 Thus. which occupies one word of resident space. all costs associated with running of that the Similarly. page 3. two successive Specifications + Associated with the overlay system is a datatype called a swparray. very small functions are normally not made swappable (see mkswapp. + PMAP 1 s (the Tenex operation to fetch one page) are not the same from one moment + to another. calls. because they don't save much space. arraysiza.21).!!m. even i f the virtual state of both forks is exactly the same . Larger programs don't exhibit a measurable slow down since they amortize the entry cost over longer runs. 3.26 Thus. a compiled (LAMBDA NIL NIL). (numeric + datatype 4). due to the fact + instance created by the first fetch is almost certain to be resident when the + second is done. The BBN INTERLISP group has a project in progress to measure the interaction of INTERLISP·10 and TENEX. the fetch of a new piece or swapped code + into the buffer. printstructure. all that can be reported is + that empirical measurements and observations have shown no consistent slowdown -f· in performance of' systems containing swappable functionsp viz a viz resident + functions. advise.

~ a array.control the swappability of all future • definitions as they initial + definition of mkswapp function + swappable: is T.v] Analogous to array. or by + compiling to core. is a resident array. + swparray[n. will make swappable if ( 1) noswapflg is NIL.cdef] the inverse of mkswap. ccodep is true + for all compiled functions/definitions. Returns x if 2S is a swappable array and. their atom's cell. are created. + NIL otherwise. 3. swparrayp[x) Analogous to arrayp.swapped definition on its + CODE property.21 is resident.p. Before they are stored away + into function is + If the value + into a swappable definition + is copied ccodep[x] is true. or an atom with .edita all work equally well with swappable as resident programs. of mkswapp made + By + the user can + completely . and (undoably) redefined with the latter. the mkswapp definition it is left redefining mkswapp or advising it. + All compiled definitions begin life as resident + arrays. The a and ( Z) the + . otherwise. mkswap[x] If ~ Allocates a swappable array. whether they are created by load. it of mkswap is lS· mkunswap[x] mkswapp[fname. returns array which is a copy of 2S· If atom and its swappable is a literal • + is + The value + 2£ is either a swappable + array. applied to the atom and the array.

setsbsize should be used with care. 27 + + definition is . 3. or when the size is zero.name of the function is not on noswapfns. without 27----------------------------------------------------------------------------Currently.22 . Returns returns the the to !!• previous current size than a value. greater Sets the size of the swapping buffer + + its of pages. Therefore. and (3) + the + mkswapsize words. initially 128. the system lacks error recovery routines for situations such as a call to a swappable function which is too big for the swapping buffer. setsbsize[n] size of number + setsbsize[] + changing it.

12 3....... .7......12 3......Y] SUBR ••••••••••••••••••••••••••••••••••• escape character •.. Y] SUBR •.......2 3.........12 3 ...12 literal atoms •.....•••••••••••.... ..........................TYP] SUBR ••••••••••••••••••••••••••••••• MKA TOM[ X] SUBR •••••••••••••••••••••••••••••••••• MKS TR ING[ X] SUBR •••••••••••••••••••••••••••• . LINELEl1GTH[ N] SUBR line-feed LIST[Xl .......•••••••••••••••••••••••••••••• floating point numbers •••••••••••••••••••••••••• FLTFMT[N] SUBR •••••••••••••••••••••••••••••••••• free-1 ist ........9 3.••••••••••••••••••••••• E (in a floating point number) •••••••••••••••••• ELT[A....••••••••••••••••••••••••• CODE (property name) •.2 3........••.. ...21 3. PACK[ x] SUBR P.. .IJ] SUBR ••••••. 8 3 .....14-15 3. ...VJ SUBR ••••••••••••••••••••••••••••••• array header ...........X2............ ...• .21 3.••.......••••• 3.. EQP[X..••••...........•... ARRAY[ tJ......••.•• MKSWAPP[ f~M .......... 1.ipacting ...9 3..6..•••••••••••••••••••••... ••• MKSWAP[ X J ...12 3............2 . ......21 3.......1.......... pname cell pnames pointer ··········•••.1...4 3.17 3.....12.8 list nodes ...•••••. garbage collection ••. NOSWAPFNS (Overlay variable/parameter) •••••••••• octal . ••••••••••••••••••• 0 • •........•••••••... II function definition cell .......9.... •.......9 3.3.19........ •••••••••••••••••••••••••••••• ..9 3..OF] ••••••••••••••••••••••••••• .... .......•••••••••••• MAKESYSDATE (system variable/parameter) ••••••••• MHIFS[t~.16 3... .....••••.Xn] SUBR* •••••••••••••••••••••• CONS[ X... P .7 3.........4 fJOB If·JD •' .. ......1 3......9. ... . ............X2.1..•.......14 3...... lists ..4 3..•...... 3.........................13-14 3.••••••••••••••••••••• ARRAYP(X] SUBR ..... ..•••••••....••••••••••••••••••••••••••• array pointer ••................22 3..•e•••••••e••············· . •••••• MKSWAPSIZE (Overlay variable/parameter) ••••••••• MKUl~SWAP[ X] ••••••••••••••••••••••••••••••••••••• 3..12 3.......••..1..5..6.............2-3...2....••••..6-7 3..••.• • • • • • • • • • • • • • • • • • • INDEX............11-12 3....•••......9.•.••••••••••••••••••••••••••••••••• arrays atoms carriage-return .......•••••••..18 3...... 11 3...........Xn] SUBRia •••••••••••••••••••••••• 3 .•••• data types •..... .21 3.......9 3.......4-5.•.......17·22 3.1-12 3.....2 3 ..2-3. ...... .....11 3.......1 .........•....••••••....•••••••••••••••••••••••••••••••••• handle .. overlays ..........••••...21 3.7 3..... ••• .........age ....•••..••••••••..••••• ELTO[A..22 3.1-2...........Index for Section 3 Page Numbers ARG tJOT ARRAY (error message) .. .•••.....•••••••••••••••••••••••• CONCAT[Xl...21 3....... II ••••••••• 3.IJ] SUBR ••••••.....14 CCODEP[F1J] SUBR .12 3............ I I• I <II I I I I IO GI I I I I I I I I I I I I I I I I I I I I 0 I 0 large integers ... hash arrays a e HtRALD[STRHlG] SUBR ••••••••••••••••••••••••••••• HERALDSTRING (system variable/parameter) •••••••• i11tegers .9 end-of-1 ine 3..••••••••••••••••••••••••••• GENSYM[CHAR] ..••••••••••••••••••••• cor.6 3. ......16 3 .....................12-15 3...8.... 1 3.2 3..•••. I •• I I I I •••••••••• ... .....4 3..5 3.... 19 3.12 3 ............•••••••••••••••••••••••••••••••• MAKESYS[FILE] EXPR •••••...... .21 3.6-7......

9 3.9..4 3.2.2..16 3.9...1..Z.FILE] SUBR private pages property list Q (following a number) RADIX[N] SUBR RECLAIM[ N] SUBR relocation information (in arrays) RUt~ ( tenex command) SETA[A.11 3.13·14 3.12 3.V] SUBR SWPARRAYP[X] SUBR TENEX unboxed numbers (in arrays) ..18 3..9 3. 3.2.2.11 3.6 3.Page Numbers PRINT[X.11 3.6 3.9 3. ..18 3 .9 3.8 3..N.6 3.11 3 .P.16 3 .• • • II • • .2 3.Z .9..20·21 3..Z .Z 3 .1.FILE] SUBR PRIN2[X.9 3.21 3. [ • • • • • • • • • a • • • • .16 3.3.11·12 3.16 3 .11·12 3....11 3 .FILE] SUBR PRINTLEVEL(N] SUBR PRINl[X.22 3.11 3 .1.N.M] SUBR swappable array swapping buffer SWPARRAY[N.9 3 .2 3.11 3.16 3 .2 3.8 3. • (followed by a number) % (escape character) ( () ) (in a floating point number) ] INDEX. 6 3.V] SETO[A.N.7 3.2.V] SETSBSIZE[N] SUBR " shared pages shared system sharing small integers SMALLP[N] space storage allocation string characters string pointers strings SUBSTRING[X..7.16 3..

which is either (1) a list of literal atoms or NIL (fixed number of arguments). respectively. or by compiled machine code. by built-in machine code.1 Exprs Functions defined by INTERLISP expressions are called exprs. b. each function may independently have: a. its arguments evaluated or not evaluated. a fixed number of arguments or an indefinite number of arguments.SECTION 4 FUNCTION TYPES AND IMPLICIT PROGN In INTERLISP.1 . or (2) any literal atom other than NIL. 4. (indefinite number of arguments). c. the term expr is used to refer to either the function. or its definition. be defined by an INTERLISP expression. Each atom 1•••-~-----•••••••••••••••••••••a••••D••••••••••o~•••••••••••••••••••••••••-••• Where unambiguous. Hence there are twelve function types (Z x 2 x 3). 1 indicating whether the arguments function are to be evaluated or not evaluated. Case (1) corresponds to a function with a fixed number of arguments. 4. with either Exprs must begin LAMBDA or NLAMBOA. to tho Following the LAMBDA or NLAMBDA in the expr is the 'argument list'.

~-~~~~~~~~~--b. and then included in the definition itself are the appropriate calls to eval. CL ISP. i f it is desirable to write a function which only evaluates some of its arguments.ii~~~ + + + + + eval. 2 This process is called "spreading" the arguments. indicating its arguments are to be evaluated. that this function in fact does evaluate its arguments. if FOO is defined or by (LAMBDA X --) when (FOO ABC) is evaluated.in the list is the name of an argument for the function defined by this expression. NLAMBDA. and Care evaluated and Xis bound to 3.-. setq.-~.~. DWIM.. even though it is an nlambda. In fact. PRINTSTRUCTURE.~. Case ( 2) corresponds to a function with an indefinite number of arguments. arg[atm. and the function is called a spread· LAMBDA or a spread-NLAMBOA. as dictated by whether the definition begins· with LAMBDA or and then paired with these argument names. In this case. when (FOO THIS IS A TEST) X will be bound to (THIS IS A TEST). If a nospread function begins with a LAMBDA.e..-~h~~--. Ir its definition begins with NLAMBDA.·.-~~~~i!-~~~--. Such a function is called a no spread function.~. For example. A.m). is evaluated. each of its pushdown list. When the function is called. · 4.i.1~. e.g.. its arguments will be evaluated or not evaluated. i. 2---~~~. the atom which constitutes its argument list is bound to the list of arguments to . no arguments are evaluated in the process of calling the function..~~~. is available for computing the value of the mth argument for the lambda-atom variable !!!!!· arg is described in section 8. since the function type can specify only that all arguments are to be evaluated or none are to be evaluated. For example. A built-in function.2 . the user should also put on the property list ..of the function under the property INFO the value EVAL to inform the various system packages such as . etc. arguments n arguments are evaluated and their values stored on the The atom following the LAMBDA is then bound to the number which have been evaluated.~~. the function is defined as an nlambda. if FOO is defined by (ULAMBDA X --). B.the function (unevaluated).

a CFEXPR* is a compiled form of a nospread·NLAMBDA. indicated by the prefix built-in subroutines. example.3 Thus. are referred to as compiled functions. as described in section 18. compiled functions may be resident or swappable. are spread functions. for . In INTERLISP-10.. The value of fntyp is one of the following 12 types: EXPR . The types in tho second column are compiled versions of the types in the first column.3 Function Type The function f!:!m returns the function type of its argument. indicates no evaluation of arguments. "The Compiler and Assembler". In XNTERL ISP· 10. 4.s- expressions or ASSEMBLE directiv0s. as indicated by the The prefix f. whether from. ~· In the third column are the parallel types for Functions of types ii) the first two rows have a fixed number of arguments.2 Compiled functions Functions defined by expressions can be compiled by the INTERLISP compiler. Functions created by the compiler.4. fourth suffix rows have an 11t as Functions in the third and indefinite number of arguments. Le. functions may also be written directly in machine code using the ASSEMBLE directive of the compiler. 4. CEXPR SUBR FEXPR CFEXPR FSUBR EXPR* CEXPR 111 SUBR 11 FEXPR* CFEXPR• FSUBR• The types in the first c~lumn are all defined by expressions. as described in section 3.

it is an extension of the function ~ of LISP 1. e.e. Jn fact.• (FOO) and (FOO 1Vll) are exactly the . IJ a function is called with too Jew arguments. IJ a Junction is called with too many arguments. the extra arguments are evaluated but ignored. 4. i.A standard feature of the INTERLISP system ts that no error occurs if a spread function is called with too many or too Jew arguments.supplied ones will be delivered a.s 1Vll.spread Junctions. 4.5.4 Progn progn is a function of an arbitrary number of arguments. the Junction it.self cannot distinguish between being given 111/l as an argument. and not betng atuen that argument.4 .same for . ~ evaluates tho arguments in order and returns the value of the last.5 Implicit Progn The conditional expression has been generalized so that each clause may contain n forms (n 2 1) which are interpreted as follows: ccorw (Pl Ell E12 E13) (P2 E21 E22) [1] (P3) ( P4 E41)) will be taken as equivalent to (in LISP 1. Thus a clause in a cond with only a predicate and no following expression causes the value of the 4..g .5): (COND (Pl (PROGN Ell E12 E13)) (P2 (PROGN E21 E22)) (P3 P3) ( P4 E41) [2) (T NIL)) Note however that P3 is evaluated only once in [ 1]. while it is evaluated a second time if the expression is written as in [2). Both ~ and lambda/nlambda expressions have been generalized to permit 'implicit progns• as described below. the un.

the function would always return NIL.e. No error is generated. i.predicate itself.5 . the cond 'falls off the end'. 4. In this example. Note also that NIL is returnod if all the predicates have value NIL.!lll..!!'s: thus for example: (LAMBDA (Vl V2) (Fl V!) (F2 V2) NIL) is interpreted as: (LAMBDA (Vl V2) (PROGN (Fl V1) (F2 V2) NIL)) The value of the last expression following LAMBDA (or NLAMBDA) is returned as the value or the entire expression.. to be returned. if non-NIL. LAMBDA and NLAMBOA expressions also allow implicit !!!.

......1-4 4.3 4.M] FSUBR argument evaluation argument list ASSEMBLE CEXPR (function type) CEXPR• (function type) CFEXPR (function type) CFEXPR• (function type) compiled functions compiler CONO[Cl.....C2............1 4... .. 4. 4.... .3 4 .........2 4. .....1 4...3 4. ........ •••• FrHYP[ X] Ill •••••••• . 4. INDEX.......2 4..........2 4...3 4... .3 4.. ...3 4 .1-2 4 .....3 4.....1 4...4 4..4 4.....3 .... ..• .....2 4 ..... . ................3 4. .3 4.....Xn] FSUBR* pushdown list spread functions spreading arguments SUBR (function type) SUBR• (function type) too few arguments too many arguments .. .. .• .1 4.4 4. ~ FSUBR (function type) FSUBR* (function type) function types implicit progn incorrect number of arguments indefinite number of arguments INFO (property name) · LAMBDA ti LAMBDA nospread functions PROGN[Xl...2 ...3 4.X2....3 4..2 4......4 ..3 4 .Index for Section 4 Page Numbers ARG[VAR....4.3 4. ..... ........1-2.5 .... ..4 4...4 4.... .3 4.... ....5 4.. .1-2.3 4.2 4...Cn] FSUBR• EVAL[X] SUBR EXPR (function type) exp rs EXPR• (function type) FEXPR (function type) FEXPR• (function type) fixed number of arguments ..2 4..... ............. . ....

g. cdr[x] cdr gives the rest of a list (all but the first element).1 Primitive Functions car[x] .£!!. To minimize drum accesses the following algorithm 5 . For all other nonlists. = car[car[x]J cadr[x) = car[cdr[x]] cddddr[x] = All 30 combinations of nested cdr[cdr[cdr[cdr[x))]] open by the compiler. and numbers. gives are The value of cdr is undefined for other nonlists. the property If ~ is a literal atom.Q!!! caar[x] ~ and cdrs up to ! deep are included in the system.SECTION 5 PRIMITIVE FUNCTIONS AND PREDICATES 5. the value is undefined (and on some implementations may generate an error). arrays. ~ ~ and X· If x is becomes the first element of that list.!: gives the first element of a list left element of a dotted pair ~. All are compiled constructs a dotted pair of a list. value is top level binding (value) of the atom. list of ~· Property cdr[~J lists usually NIL unless modified by the user.1 . atom.. cons[x:y] £. strings. e. This is also the right member of a dotted pair. o·r the For 11 teral ~.

conscount[) value is the number or £. rplacd is undefined. The only way to get a circular list is by using rplacd to place a pointer to the beginning of a list in a spot at the end of the list. presently 16 LISP words.Q!l! of ~· as which creates a new list element.e.y] will make of !· x be For 5. (except for rplacd[NIL. i.y) is placed 1) on the page with x if xis a list and there is room.2 a literal the property list For all other non-lists. otherwise 4) on any page with a . rplacd[x.Q!l! if there is room.spectJted mtntmum of storage. or the cell pointed to by changes the opposed to Thus it physically ~· internal list structure £. rplacd[x.Q!!. cdr.!es since this INTERLISP was started up. ror finding a page on which to put thf constructed INTERLISP word. ATTEMPT TO RPLAC NIL. otherwise 2) on the page with ! if! is a list and there is room: otherwise 3) on the same page as the last £.y) Places the pointer ·~ in the decrement. The value of rplacd is !· An attempt to rplncd NIL will cause an error. ~ the effect of .NIL]).is used in INTERL lSP· 10. cons[x. atom.

Convention: 1Vaming.safety• error checks. address The value of An attempt to rplaca NIL will cause ATTEMPT rplaca[NIL.. e. the top level value for For all other non-lists. quote[x] This is a function that prevents its arguments from being evaluated.:~:-(o~~~E-E. producing strange and wondrous effects. ill• with :i· rplaca is 2!· an error.-~h. i.e . B)).~-~~.y) will make ~· the TO RPLAC For ~ x be NIL. guote itself PARENTHESIS ERROR.s open and runs without any '. . Its value is~ itself. 1 kwote[x] (LIST (QUOTE QUOTE) x).ast ver. then (KWOTE (CONS x y)): (QUOTE (A . i---.. and one generates an 5.s a J.g.. if ~=A.rplaca[x.~~~. made on ~' Note that no checks are so that a compiled frplacd can clobber NIL. almost always a parentheses undetected.sion of the old. and l=B.NIL]). the effect of rplaca is undefined. one which has the .~~~~-~~~~~~-~~~~.-.. a (except 11 teral for atom.3 that would error in otherwise go this case.y] Has the same definition as rplacd but compiles open as one instruction.same definition but compile.-~~. · frplacd[x.~~-(co~. (QUOTE FOO) is F00. error.sting Junction name with J_ u. but replaces pointer of 2!• Le. a function by prefixing an ext.~~:-. frplaca[x. rplaca[x.y] Similar to frplacd.-~-~>>~-~.y) similar to rplacd.sual ly indicates that the new Junction i.

If !ii is false. be 9 n1 enz ELSEIF e13 The clauses are considered in sequence as follows: the first expression !ti of the clause £ 1 is evaluated and its value is classified as false (equal to NIL) or l!JU! (not equal to NH). considered. value of !ti is that follow ~. . where the first element is the predicate. if i. ~ni> of n ~ Ek• Each clause £1 is a list <£u 1 items.. 1 .£ 1 £ni evaluated in sequence. . tho value of the conditional expression is NIL. and the next £i+t clause If no !ii is true for an~ is clause.4 !u ~· Each x1 is a list !zi . then the remainder of clause £i is ignored.£ 2 . of the (which is evaluated only once). cond. !ki) where ! 1 is the The operation of selectq can be . in If the the expressions !zi clause are .~ 1 selection key. paraphrased as: 5. called clauses.. In particular.e. n=l. if there is only one expression in the clause s:. takes an indefinite number of arguments £ 1 .The conditional function of INTERLISP. and the value or the conditional is the value of !ni' the last expression in the clause.. selects a form or sequence of forms based on the value of its first argument of the form <. conditional the is value of the value !u. and the rest of the elements tho The consequents. operation ezz ELSEIF e1z THEN can cond IF e 11 THEN e 21 as paraphrased of .

and the value of the selectg is the value of the last expression evaluated. etc. the value of i f it is ~ ~ is tested to soe to !i (not evaluated). until all the have been tested.e. ~·s If none is selected. !: must be present. selectg compiles open. the value of the selectg is the value of ! . so.. eki are evaluated in sequence.5 ..IF ~=s 1 THEN e 11 ELSEIF THEN ~=sz If !i is an atom. and is therefore very fast: 5.£g to any one of them. An example of the form of a selectg is: [SELECTQ (CAR X) (0 (PRINT FOO) (FIE X)) ((A E I 0 U) (VOWEL X)) (COND ((NULL X) NIL) (T (QUOTE STOP] which has two cases. i. ~i+! selected in one of the two ways is tested. Q and (A E I 0 U) and a default condition which is a cond. the value of ! is compared with each element (not evaluated) of !i• and if ~ is . If the expressions e 11 . ~ki" If !i is a list. If i 1 is not described. then e 11 to eki are evaluated in turn as above..

) will bind .!l evaluates ea th of its arguments in order.2!.:QJ::. contain lists of form the In this case.g. and returns :5'S original value .however. the e.2. evaluates its arguments in order. and returns the value of its . INTERLISP expressions The first argument.. ( PROGN •..m. fil:.• ) ) allows evaluation of several expressions as the default condition for a selectg.s. (PROG ((X Y) (Y X)) . Each atom in args is treated as the name of a local variable and bound to NIL. (PROG1 X (SETQ X V)) sets ~ to ~.s to the value or ~ and ~ to the (original) value or .g. This function allows the user to write an ALGOLlike program containing (forms) to be executed. it will not work if the value of list.. e.2. args.. and returns the value of its last argument as its value.g.6 . args can also (atom form). . il. first then . or is a ~ point number.s2 . a large integer.$ 1 • first argument !t• e... that is. is a list of local variables (must be NIL i f no variables are used).911 is used to specify more than one computation where the syntax allows only one.. (SELECT() .2!!! is the name of the variable and is bound to the value of f.9. floati~g since selectg uses !9. 5.. The evaluation takes place before any of bindings are performed. etc. for all comparisons..

9.Q.g. the labels serve only as markers.1:!• will not 5. e. 11 the· value of the ~ is NIL.. The value of function If no return is executed.. a illfl• higher If the label is not found.A not A 9. progs found appears.!!lil. or return will be executed in the last interpreted e. within in an the error the same (GO A))).7 . As a corollary. entered if any.t:. or return is executed in an interpreted Junction which is not a proa.2· Its argument is evaluated and is the value of the E. in which 1t appears. if the prog "falls off the erid..!2Jl.U OR ILLEGAL GO. and will cause an error at compile time. otherwise cause an error.. the is usually specified by the ~ return.Q• symbols forms are used as evaluated sequentially. the fJ. is not al lotued.!2. return[x) A return is the normal exit for a Q!. e. the UNDEFINED is E.Q is the function used to cause a transfer in a ~· (GO L) will cause the program to continue at the label L. fl!! or return instde of a compiled Junction that ts not a l!.2.Q. 1. . If the label which generated.£9. (PROG (PROG -.Q will search Junction.The rest of the statements labels (forms) for is a sequence of non-atomic ~ and atomic The 9. If a f1.e.Q can be used at any level in function is in 9. to .r. The two special functions 9.g..2 or return in a functional argument.Q and return alter this flow of control as described below.2. go(x] 9.

~.-.. and B being returned. since nlsetg's and ersetg's compile as separate functions.-~~.~. ARG NOT ATOM ·SET.. If .2 or return cannot be used inside of a compiled nlsetg or ersetq if the corresponding .ii~~~ process. setq except that neither evaluated. If 2S is NIL. then set[x. setqq(x.work compiled. causes an x.g. Note that as a result. typing (SETQ var form) and SETQ(var form) to lispx is equivalent: in both cases ~ is not evaluated.y] Like ..~-l~~bd~·:·n·e·t·t.s is NIL.e-. causes an error.i~~ .y] This function sets is to is not a literal ~· Its value is atom.e. the error ATTEMPT TO SET NIL is generated. the second is. (SETQ X Y) would result in X (not C) being set to B. an error is generated.~~. 2 Thus i f the value of X is c and the value of Y is B. a . i. ~~. ATTEMPT TO SET NIL.~. the nlsetg or ersetg. set[x. ARG NOT ATOM • SET. its arguments are evaluated before it is called. Thus.rul is outside.~·r·g·u~"a·n·t--.. if the value of 2S is £• and the value of ~ is e.s is not a literal atom.!£ is lambda-spread function.e. 5. a normal i. Note that ·. would result in £ having value !?_. If .y] and !! being returned as the value of ill· setq(x. e.-. 2.. If ~ error.y] All nlambda version of set: the first argument is not evaluated.~~~~. ~..·. (SETQO X (A B C)) argument sets is to (A B C).8 . and form is.d· d~. However. above..9. Also. . setg itself calls eval on its second argument.!.tU:.

equivalent to is (RPLACA (QUOTE FOO) form). like .2. generate errors if (Section 8). instead of setting ~· the corresponding value is stored on the property list of x under the property VALUE.. the variable will 5. rpoq derives its name from r.: ALLPROP (and the value of 1$ is other than NOB IND). so that if the user types control D (or equivalently 0 in INTERLISP-10. work on as except GLOBAL variables that must be reset.e.new-value.y) ~ and ~ are used by prettydef (Section 14). i. Both ~ and rpagg Both are affected by the value of dfnflg dfnflg :.Yi!! to a global list. binding of except always i. rebound is is (RETURN designed to the same form)). The evaluation of form is errorset protected so that the value is restored even if an error occurs.lac!! guote. resetvar also adds the old value of .9 . not (see section 18). (RPAQ FOO form) e. rpaqq[x.y] setg.!1. Resetvar and Resetform resetvar[var.e. ~· on works the on value top lave l cell. since it is essentially an nlambda version of rplnca. If ~ is not atomic.g. for top level bindings.E. resetvar resets the and then restores its value after evaluating form. variable (using frplaca).9.form] The effect of resetvar (PROG ((var new-value)) that resetvar variables.il. control·C followed by REENTER) while form is being evaluated.like rpaq(x.

fil:).g.!: of forml to this value.be restored by the top level INTERLISP executive. and temporarily change their "setting". 'then formt is evaluated. linelength. thereby making lispx work on edithistory instead of lispxhistory. The behavior of many system functions is affected by calling certain functions. is evaluated. etc. if no error occurred. resetform[form1. as opposed to resetting variables. nospread. calls lispx to execute edito. For example. formt is properly restored. then form2 form1 (RESETFORM (RADIX 8) (FOO)) while ~ is 'restored'. e. The value of resetform is the value returned by f'orm2. Otherwise. ~. forml must return as its value its "previous setting" so that its effects can be undone by applying£!!.r history commands by performing (RESETVAR LISPXHISTORY EDITHISTORY (LISPX ··)). input. . if 5 .10 no error occurred. radix.g. and then restore the original setting of radix. output. and also records its information on a global list so that after control-D. The value of resetvar is the value returned by form. the editor resetvar compiles open. e. evaluate (FOO) will is 8. resetform is errorset protected lik~ resetvar. Otherwise. resetvnr generates an error (after restoring the value of Y.form2] nlambda. The function resetform enables a program to treat these functions much like variables. printlevel.

otherwise + resetlst generates an.resetform generates forml). or a control-D is typed). Since each call to resetvar or resetform involves a separate errorsot and some + additional overhead. resetvar. to be res~ts ed'ithistory performs (RADIX 8).g. + (or an error occurs.error occurs. + The value of resetlst is the value of the last + form on resetx. function for functions use of under resetvnr a nnd resetform. an error (after restoring resetform compiles open. resetx is a list of forms. If £!! of resetx is atomic. acts like e. + If i l l of resetx is not atomic.11 ~ . nospread resetlst. if no .g. + nlambda. error (after performing the + necessary restorations). nospread. + resetlst sets up the errorset so that any reset + operations performed by resetsave are restored + when the evaluation of resetx has been completed + (or an error occurs. e. resetlst[resetx] resetsave[resetxJ + + nlambda. + efficient (and the functions resetlst and reset save convenient) way or performing several provide a more resetvars and/or resetforms at the same time. (RESETSAVE LISPXHISTORY EOITHISTORV) the + and + provides for the original value of lispxhistory to + be restored when the resetlst completes operation. reset save acts + (RESETSAVE (RADIX 8)) + value like of lispxhistory resetform. and provides for to be + reset to its original value when the resetlst + 5. or a control·D is typed). Combines resetlst compiles open.

"previous setting".(COND (·· (RESETSAVE ··))) -·). 5. + [RESETSAVE(SETBRK •·)(LIST(QUOTE SETBRK)(GETBRK}. NIL otherwise. an atom and not a nomberp(x] number. 3 + (RESETSAVE NIL form) can be used to treat + value of f2rm as a restoration expression. NIL otherwise. NIL otherwise. l i ta tom[ x] is T if 2S is a literal atom.For functions which do not + completes.g. + (RESETLST ·. resetsave can be given + the restoration expression as a second argument.g. e. + resetsave compiles open. + Note + condiUonall11 resetting a variable or form.e. + (RESETSAVE NIL (LIST (QUOTE CLOSEF) FILE)) · the will cause !ll! to be closed when the -resetlst that the + resetsave is under + or a control·D is typed).12 . + + 5. i. is 2S if 2S is a number..g. return + their.Z that completes (or reset save an error occurs provides a Its value way is of e. + •useful' quantity. + e. not a Predicates and Logical Connectives atom[x] is T if! is an atom.

ng.e. null[x] eq[x.Q.NIL] not[x] same as eqp[x. Note that arr~ys and strings are not atoms.13 . see Section 10.NIL]. if ~ is not !9.stp will return lVIL when given an array or a s trt.!1· that is eq[x.y] The value of ~ is T. nlistp[x] not[ listp[xJ] eq(x. ~ and l are !!I• i. Its value is not guaranteed T f'or equal numbers which are not small integers.e. i. Nll otherwise.J?· The value of !!!. they test for some condition.y] See !9. is T. ~ is compiled open by the compiler.Convention: Funcitons that end in 2 are usually predicates. stringp[x] is x if ~ is a string. one created ~is by one or more conses.y] The value of i l l is T if m!. both atom and l i. NIL otherwise.e. i. to ~· and NIL otherwise.. but are also not lists. neq[x. if ~ and l are pointers to the same structure in memory.e. 4------------------------------------------------------------~----------------for other string functions. 4 arrayp[x] is listp(x] is 2f i1f ~ if~ is an array. and NIL otherwise. a listastructure. i. NIL otherwise. 5.

y] The value of egual is T (1) if ~ and ~ are ~. or (2) ill• i. value~· ~. If all of its arguments have non-null value.e. or if ~ and ~ are numbers and are equal in value.pointers to the same structure in memory. or[x:numberp[y)) has its or NIL. i.e.g.14 ~ and ~ are equal if they . 6 I ts value is NIL otherwise. strequal.: of is equal to i l l of ~· and ill of ~ is ~ equal to ill of ~· 6 The value of equal is NIL otherise. 6 A loose description of equal might be to say that print out the same way. otherwise NIL. pointers to the same structure in memory. and[x:member[x. or (4) lists and £!.e. E. Evaluation stops at the first argument whose value is not NIL. numbers with equal value.y]] will have as its value either NIL or a tail of~· and[J=T. strings containing the sam~ sequence of characters.!. or (3) i. Takes an indefinite number of arguments (including O). E. equal[x. Evaluation stops at the first argument whose value is NIL. Note that ~ and do not have to be !!I· ~ Takes an indefinite number of arguments (including O). or[J=NIL. 5. otherwise NIL if all arguments have value NIL.g. its value is the value of its last argument. Its value is that of the first argument whose value is not NIL.

somefnt[car[somex]. !2.everyfn2] ls T if the result of applying everyfnl to each element in everyx is true.somex) is computed. exists. ATOM]=T.-----------------------------~-----------------------------------------------Actually. 7 If this yields NIL.15 . or cdr[ somex] if somefn2=NIL. soll'iefn2[ somex] is computed.somefn1. Value i~ NIL if no such E.somefn2J value is the tail of~ beginning with the first element that satisfies somefn1.. 5 . every compiles open.!!!!. Otherwise. e. is operates At each stage.g. to to every. E. every[x:ATOM:CDDRJ every other element of ~ is true if is atomic.everyx] is computed.(LAMBDA (Z) (EQUAL equivalent analagously element z V))J member[ y. and the process continues. e. and used for the next ~· !.every[everyx..Q!!1! compiles open. for which somefn1 applied to that element is true. ~ is returned as the value of Otherwise. and if this is not NIL. everyfn1[car[everyx]. some[somex. . every immediately returns NIL. otherwise NIL. so for example everyfn1 can look at the next element on everyx if necessary. or cdr[everyx] if everyfn2=NIL.g.everyfni.. every operates by computing everyfn1[car[everyx]J. every[(X V Z). 1. every computes everyfn2[everyx]. some[x. and uses this as the 'new' everyx.x).g.

If ~ is £.!!!:! 2 1 of l• we say! is a proper tail. i. gives Interpreted. if ~ an error. If not.e. to check membership of ! in equal X· The reason for the existence of both memb and member ts that !!I. ~· If so.£ is the first sublist of ~ !_g to some number of cdrs ~ 0 8 i. fmemb[x:yJ Fast version of !!!fill!!? that compiles open as a five instruction loop.y] ~ whose 8------------~------------~------------------····------------------------------. its x starting with that element. terminating on a NULL check.~if! is a list and a tail of~· ~· NIL xis a list of lists (usually dotted pairs). 5.yJ Is ~. ! is of otherwise. its value is NIL.16 . instead of equal.everyfn1:everyfn2)J memb[x. BAD ARGUMENT • FMEHB. and ts therefore considerablv more expenstue..g to some number of s. the user should write (and use> Junctions that use !!I.!!!2. assoc(x. · tailp[x. The value of . ends · in a non· list that uses other than NIL.. . compiles as one instruction but equal requires a Junction call.yJ Determines if! is a member of the list if there is an element of X fill to value is the tail of the list ~.everyfnt:everyfn2J not[every[everyx. Whereuer possible.notany(somex:s~mefn1. member[x:yJ Identical to memb except it instead or !9.somefn2J same as not[some[somex:somefn1:somefn2)J notevery[everyx.e.

Interpreted.((A • 1) (B . ~ (B .y] Fast version of ~ instruction loop.17 tho but uses equal instead of ~· . If such a list is not found. fassoc gives an error if ~ ends in a non-list other than NIL. 3))] fassoc[x. sassoc[x.y] Same as ~ 5. 2).is !S to ~· value is NIL. 2) (C . BAD ARGUMENT . Example: assoc[B.FASSOC. that compiles open as a 6 terminating on a NULL check.

•..•••• ATOM[X] SUBR . ..•..•••••••• ATTEMPT TO RPLAC NIL (error message) •••••••••• ......Y] .. COllD[C1.••..13 5 ..............Cn] FSUBR• cond clause ••••••••••••••••••••••• ....9 5.••••••••••••••••••••••••...........FASSOC (error message) ••••••••••• BAD ARGUMENT ..... LIUELEIJGTH[ IJ] SUBR LIST P[ X ] SU BR lists ••••••••••••••••••••••••• .....Y] Ff1EMB[X.... (system variable/parameter) dot teci pair EO[ X...16 5.FMEMB ~error message) •••••••••••• CAR[ X] SUBR ....8 5.......••••••••••. .. . ...4 5...9 5... ...16 5 .••............. •••• ...9-10 5.........•.•...16 5 ....13 5 ...•••.... .....15 5.... ERSETO[ERSETX] NL ••••••••••••••••••••••••••••••• EVERY[EVERYX. 13 5.••....••••••••••••••••••• CDR[ X] SUBR ......••••. .• EQP[X... ...Y] SUBR ••••••••••••••••••••••••••••••• FRPLACD[X. 1 5. ....•••••••••.... COIJS[ X. • • • large integers ...........•....••.EVERYFN2] •••••••••••••• NULL[X] SUBR •••••••••••••••••••••••••••••••••••• NUMBERP[ X] SUBR ••••••••••••••••••••••••••••••••• INDEX.•••••••••.•.7 5... ASSOC[X...... ...VJ SUBR .... ... 10 5 ....... ......Y] .......9 5...••.......3 5. MEMB[X.....5...12 5...... . ....6 5..••.•••.SOMEFN2] ••••••••••••••••••• NOTEVERY[EVERYX.•. ...SOMEFN1... Y] SlfBR .....••••••..14 5........•••••...••••••• ERRORSET[ U ...•..... ......SET (error message) •••••••••••••• ARRAYP[X] SUBR •••••••••••••••••••••••••••••••••• I arrays .•..•.......Y] ·····················•••••••••••••••• .... Y] SUBR •••••••••••••••••••••••••••••••••• cons algorithm ..••...••.....EVERYFN1.....10 5.. .....•..•.16 5.....14 5.••........4 5. ..•••. .........EVERVFN1.......•••.... CONSCOUNT( N) SUBR control-D OFNFLG ••••••••••••••••••••••••••••••• .•••••••••••••••....... LITATOM[X] SUBR ••••••••••••••••••••••••••••••••• literal atoms .....•••..... -.Y] •. FASSOC[X.•••.17 5 .16 5. .............16 5...•••••.......•••.7 5.13 5..13 5 ......•••••••••••.....13 5.....Y) SUBR EQUAL[X....•... ••••••••••••••••••••••••••••••••••• .••••••••••••••••••••• fJLISTP[X] ..1 5. . local variables ........12 5....... ..C2..••..... ••• .....• IL LE GAL RE TURN (error message) •••••••••••••••••• INPUT[FILE] SUBR •••••••••••••••••••••••••••••••• KWOTE( X] ...•.....•..9 5 . 1 5..13 5 .••....• .2-3 5.....•......13 5.•...13 5 ..•••..... . ... .•••••••••••••••••••••••••••••••••• fJOT[ X] SUBR ••••••••••••••••••••••••••••••••••••• NOTANY[SOMEX.1 5....13 5 ........ ....•.. . .••.•••...12 5.. ...••.Y] SUBR ••••••••••••••••••••••••••••••• GCGAG[MESSAGE] SUBR ••••••••••••••••••••••••••••• global variables GO[ X) f SU BR* ... ATTEMPT TO SET NIL (error message) ·····•···•···· BAD ARGUMENT ...•••• ......16 5 . ••• .•........•••.EVERVFN2] ••••••••••••••••• false .8·9 5 ...............3 5.....9 5.•..•••••••••••. 1 5.....Xn] FSUBR* •••••••••••••••••••••••• ARG NOT ATOM .......X2...•... ....••. ..8 5 ..8 5.2 5......••........•... .. ........... .•••......... ..••••••• AND[Xl. .... .•••••••• FRPLACA[X. to 5..13 5... 17 5 . ... .....Y] ••••••••••••••••••••••••••••••••••••• f·JEO[X.....••. .•.....4 5...Y] ••••••••••••••••••••••••••••••••••••••• MEMBER[X..12 ...•.. ......3 5 .. .•••.•..2 5.•••••• llLSETQ[ NLSETX] NL ••••••••••••••••••••••••••••••• tJOBit·JD . ..Index for Section 5 Page Numbers ALLPROP ............. ...

.....•.....9 5...2 5 .......6 5 ... .....1........ " .......Xn] FSUBRt: •••••••••••••••••••••• PROG1[Xl.. 9 5..............RESETY....16 5.......6 5..............•• 0 II ••••••••••••••••••••••• PRHHLEVEL[N] SUBR ...9 5..• SELECTQ[X....••••............. PRETTYDEF ......•............................ tail of a list .10 5................9 5....... UNDEFINED OR ILLEGAL GO (erro~ message) . TAILP[X:Y] ··························••e••••••••• top level value ...... SOME[SOMEX...•.••....•.•• (UNDEFINED TAG) (compiler error message) ..10 5..••.....•...Y] NL ••••••••••••••••••••••••••••••••••• RPLACA[X..Y1.Y] SUBR . 5.4 5.15 5.............. QUOTE[ xJ NL~ ...•.11 5.......X2.... .......3 5..En] FSUBR" •.......... ·.......3..... ..9 .... OUTPUT[ FILE] SUBR .....••. sm·a11 integers .............. ..16 5.17 5.....Y2........ ....8 5 .....Xn] FSUBRt: .........2 5 ......8 5.....Y] SUBR . . · · · 5 ........•.....•.10 5.•• RPAQ[RPAQX..11 5 ...8 5.E2..........•..............RESETZ] NL •••••••••••••• RESETLST[RESETX] NLR ........ VALUE (property name) ...13 5.Page Numbers ..SOMEFN2) ...7 5................... ... .14 numbers predicates ...• strings .......12 OR[Xl.......... ...... .. ..•..•............•. ..............6 5.•••••••••••••••••••• RESETVAR[RESETX:RESETY...Y] SUBR •••••••••••••••••••••••••••••••• RPLACD[X..•.YSET] NL .............................•• RESETSAVE[RESETX] NLt: ......•. . ....9 5 ..5. INDEX.. .......SOMEFN1....• PROGN[Xl...13 5...............•..............XZ.....••........13 5 ...........•.10 5.....•........3 5.. PROG label .................... .•.X2................9 5.7 5. value cell ...Z] NLt: ••••••••••••••••••• SET(X.. " ....... SETO[X..........Xn] FSUBRtt •••••••••••••••••••••• proper tail ....RESETZ] NL ••••••••••••••• RETURf~[ X] SUBR ...7 5 ......3 5 .......• S TRINGP[ X] SUBR ... .. RESETFORM[RESETX...... RADIX[ NJ SUBR ••••••••••••••••••••••••••••••••••• I ••• I ••••••••••••• REEIHER ( tenex command) ....• PROG[ARGS.. true ..El..7 5........ YSAS] . .. PARENTHESIS ERROR (error message) .....9 5.....16 5 ...Y] FSUBRtt I •••••••••••••••••••••••••••• ·············"·················· SETQQ[XSET............................•.. SASSOC[ XSAS..•.......... ..13 5........... ...... ..•.RPAQY] NL •••••••••••••••••••••••••••• RPAQO[X...•.4-5 5......Yn...... ........... ........•...............••.1......

.

However nai is treated specially: i. append[(A 8 C).D] u (A 8 C .e. D):(E F G)] = (A B C E F G) append[(A B C . D) .g.1 . append[ (A B) ( C D E) ( F G) ] = (A B C D E F G) • . Its value is a list of the values of its arguments. appended to ~n· ~1 ~2 and appends appended to e.-------------------------------------------------------------------~---------- To copy a list to all levels.•. 1 The following examples illustrate the treatment of non-lists. D) append[A:(B C D)] = (8 C D) append[(A B C .SECTION 6 LIST MANIPULATION AND CONCATENATION lambda-nospread function. Note that only the first n· 1 lists are copied . use ~· 6. Copies the top level of the list this to a copy of top level list . 0)] • (A B C . append[x] can be used to copy the top level of a single list.

It does this by keeping a pointer to the end of the list being assembled. ~CRPTO Example: 5 (SETQ FOO {TCONC FOO RPTN))) ((54321)1) 6. but foo + will + collection of pointers to work with. i.!l£ have been changed. if the value of + Note that + foo is NIL. its role similar to that of nconc1. nconcl[ 1st . However.x) The 'problem' is that simply has . and does not know where they originally + came from.Q. does not know that this NIL is the value of !fil?. and while it + is possible to alter list structure using rplaca. with the appropriate modifications to £!!and .2 .£Q. The savings can be considerable for long lists.e. l£lli does not have to search to the end of the list each time it is called. there is no way to change a + non-list to a list.e. and the end of the list. tconc[ptr.!l£. then the value of (NCONC FOO (QUOTE (A 8 C))) is (A 8 C). The cost is the extra word required for storing both the list being assembled.!l! will be on the same page as lst.Returns same value as append but actually modifies the list structure of x1 •. i.2. not !!.x] ll2!!£ is useful for building a list by adding el~ments on~ is at a time at th~ end. cdr[ptr] is last [car[ptr]]. unlike nconcl.!l£ Performs nconc[lst:list[x]J.£ru:. The value of ~ is ptr. a The £. and updating this pointer after each call. ptr is that word: car[ptr] is the list being assembled. In other words.• xn·i· cannot change NIL to a list.

and then call ~ the program to without having to perform setg on its value. rs t If th~ After value of the that.3 list by . lconc[ptr. i t is similar to .g.l!: is initially (NIL). NIL.1£2.!.!!£ is used to add elements at the end of a list.!!£ will make up a ill· ca 11 to ill.!l£ physically changes it. the value of tconc is the same as for ill=NIL.e. i. Thus: FOO (TCONC NIL ~(SET 1)) ((1) 1) 4 (TCONC FOO RPTN)) ~(RPTQ z 1) ((1 4 3 If 1) 1?.!!. ~csETQ (NIL) FOO (CONS)) 5 (TCONC FOO RPTN)) ((5 4 3 2 1) 1) ~(RPTQ The latter method allows initialize..!J:.!l£ instead of nconc1. i l l is In this case.!!£. e. ~csETQ (NIL) FOO (CONS)) ~(LCONC FOO (LIST 1 2)) ((1 2) 2) ~CLCONC FOO (LIST 3 4 5)) ((1 2 3 4 5) 5) ~(LCONC FOO NIL) ((1 2 3 4 5) 5) Note that FOO NIL) ((1 Z 3 4 5 NIL) NIL) ~(TCONC FOO (LIST 3 4 5)) (( 1 Z 3 4 5 NIL ( 3 4 5)) ( 3 4 5)) ~(TCONC) 6.l£2. ill. but tconc changes . lconc is used for building a adding lists at the end.!1£ can be initialized in two ways. tho program must set some variable to f:I. it is unnecessary to reset ptr since l£2.x) Where 1£Q. e.g.

Q is (A).lconc uses the same pointer conventions as tconc for eliminating searching to the end of the list. remove[x.4 description of nconc on ~· The value of ~ is . i. attach[x. 1Vamtng a Junctton by preftxtng 'an ext. and not perform any + conses.2. ~ is to ~· which it be a list. but the value of ill will Utl L be (A) because there is not way to + change a list to a non-list. copy[xJ See disctission For example. 1. + Note that dremove cannot change a list to NIL.l] Removes all occurrences of ~ Con11entton1 of ~ from .!.y] Value is equal to cons[x:y]. e.sting Junctton with d frequently tridtcates the new function ts a ~estructt11e 11erston of the old one. so that the same pointer can be given to 1£2.!1£ and lconc interchangeably.e. More efficient than remove.l] Similar to remove. ~ and actually modifies the list ! when removing ~· and thus does not use any additional storage. + f2. but uses instead of egual. but attaches front of the ~ value ~ to the by doing an rplaca and rplacd. + page 6. ILLEGAL ARG. it does not make anu new structure but cannibalizes its argument(s). dremove[x. if the value of foll~wing Makes a copy of the list 6. of attach physically changes. or an error ~must is generated.!!! !• giving a ! with all elements equal to ~ removed. then ( DREMOVE (QUOTE A) FOO) will return NIL.

not (A D • A). the copy of ~ will contain the same arrays and strings.(C B (X . not copies. The value of subst is a copy of ! with the 2---------------------------------------------------------------D·------------To copy just the top level of x. e.B. reverse[(A B (C D))J = ((CD) BA). 2 the copied list.((B C) DB C)J Q (AD B C).g. subst[x. If 2S is not a list.. reverse[l] Reverses (and copies) the top level of a list. of some both atomic and not NIL and fill to ill of some subexpre·ssion of ~. A)) subst[A. For example: subst[A.y. but dreverse destroys the original list l and thus does not use any additional storage. value is dreverse[l] ~· Value is same as that of reverse. B))J = (C A (X .. More efficient than reverse.zJ Value the is expression expression occurs ~ Y. is Substitution £!. down to non-lists.All levels · of ~ are copied. whenever x is equal subexpression of !• or when to Y. so that i f 2S contains arrays and strings. result for of all substituting the s- of the s- occurrences in the S·expression z. in the ~ ~ is recursive direction only.!:. 6. do append[x).5 .(B C). so that very long lists can be copied.

Like substitutes with a copy of !· More efficient than dsubst ~. Tl\e value of' sub lis[ als t: expr: flg] is the result of substituting each ~ for the corresponding ~ expr.y. v1 ) (u 2 • v2 ) ••• (u 0 • v0 )) with each u 1 atomic.z. but does not copy !• but changes the list structure ! itself.y.onunand (see Section 9).6 = (X 8 Y D) in . if ! is a list~ it is copied at each substitution.y. sublis[alst.expr. but first checks to see i f :t actually appears in !· If not. ~· lsubst[x.(X V Z)] is (X A 8 Z). 3 Example: sublis[((A • X) (C • V)):(A BC O)J 6. dsubst[x.flg] Similar to dsubst.g. or alt-modes as with the R conunand.zJ Like e. Note that 1f ! is NIL.appropriate changes.flgJ !!!! is a list of pairs: ((u 1 . Furthermore. ·-. so that the ~ can use &.z] Similar to ~. produces a copy of ! with all x's deleted.!a=T means print a message of the form is ? This function is actually an implementation of editor's R c. ~ except ! is substituted as a segment. esubst[x. lsubst[(A B):Y. calls error! where !.

subpr1ir and . Similarly.(A 8 CD)] ~ (X B VD) As with sublis. If ~=(A if B • C) ~=CA 8 C) last[x) : then (B • C).substitute copies of the appropriateex. if . Similar to sublis. whereas .st. For example.subli.(X V).expr. if~ 6.Z).19::1. the entire list ill!!! is substituted for it. the value is 2. . value is subpair[old. Value is NIL i f x is not a list.sub. new structure is created only if needed.st. and e.fl.sub. the rest of the elements on ~ are substituted for that atom.sub.s.H=NIL if substitutions. i f old=(A B . If old ends in an atom other than NIL.g. U is substituted for A.flg] ~ and there or if are no to expr. or if e.f.g.!£I=Nil and there are f.!l to expr.new. if old itself is an atom (other than NIL). corresponding &toms of Example: subpair[(A C). except that elements of ~ are substituted for old in expr. C) and ~=(UV X Y . terminating on 5 a null-check. no substitutions. and {X Y Z) for C. Interpreted.New structure is ere a tad only i f IH:Hlded. f.7 ends in other than NIL. generates an error 0 BAD ARGUMENT FlAST. e.s substitute the identical structure (unless tlJL:T).st all . l.!J!~T. .Te. flast(x] Fast version of last that compiles open as a instruction loop..st. last[x] o (C). d.sion. V for B. last[x] Value is a pointer to the last node in the list ~· e. 1Vote that .g.sub.

BAD ARGUMENT - FNTH.n] l· Value is ! does not contain .3] Note that nth[(A .g.cddr[xJJ=(B C 0 E).t. e. is nth[(A B). if ! ends in other than NIL.e.g. 4-----------------------------------------------------------------------------If tail is not NIL. B). beginnin.a generates an error. nleft[x. If u=2.8 looking for tail.!l elements and! is the initial segment. tail] Tail is a tail of the tail of tail. The value of nleft is that contains n more elements than ~=(ABC e. a 3 null-check. 4 ! ! or NIL. value is !• consistency. terminating on . i. is the last .n..n] ! is not a list containing at n elements.yJ where of E).xJ. if cddr[x].n] Fast version of nth that compiles open as instruction Interpreted. - 6. fnth[x. Value is NIL if least nth(x. if DE). NIL if lastn[l. the result is the same as if tail wereNIL. but not a tail of 1. ! element. e. value is cons[NIL. NIL.g. i f n.g. Thus nleft can be used to work backwards through a list.Z]=((A B C) 0 E) lastn[(A B):Z]=(NIL AB).3]=NIL. !l value if rr=O. as iS nth[(A • B). than elements. u=i. nleft operates by sc-anning l computing the lengths of l and tail.2]=(D nleft[x.nleft[ 1 . for If ! has fewer e.=3.g with the nth value is cdr[x]. Value is the tail of. etc. -- not-by .2]=B. lastn[(A BC 0 E).!l more elements than ~ Value is cons[x. loop.

g. . . e. which case the value is ! itself. Thus ~ up the first FOO. generates an error.e. is always new List .xJJ gives all elements in t~ i.1.length[x] Value is the length of the list ~ where length is defined as the number of cdrs required to reach a non°list.9 ~· generates an error. count is like a length that goes to all levels. 1Vote that the value of 1.structure unless y_.ldif'f[x. Value is the number of list words in the structure ~· Thus..e . Interpreted.z] ~ Count of a non°list is O. X must be a tail of~· i.e. the list difference is added at the end of !· If x is not a tail of 6. if count[x] ends in other than NIL.!liJ.y.member[FOO. ldiff[x. length[(A BC)] c length[(A B C D)J 3 =3 length[ A] = 0 flength[x] fast version of length that compiles open as a 4 instruction loop. If ! is not NIL the value of in !!!!ff is effectively nconc[z.y) to ~.r1Vll. terminating on a null-check.!!! to the result of applying some number of cdrs to gives a list of all elements in the list difference of ~ ~· ~up and ldiff[x.y)J. ~· ldiff[x. BAO ARGUMENT FLENGTH. i.

10 . destructive and uses no extra storage. since union[(A). Therefore. It is more efficient to make~ be the shorter list.y) lists a ~ and list ~· or Note that intersection[x:x] gives all members or ~ without any duplications.. ill' s of i terns are given to alphorder. if an element appears twice in X• it will appear twice in union[x. merge.(A A)) (A A). !!!l!. used.ILESSP] will sort a list of integers. sort[x.!l!Od on the front x x of it. Also. 6 sort[data.!::!.terminates LDIFF: NOT A TAIL. alphorder is sort[ data] will alphabetize a list. If thus If comparefn is T.!: of each item. The value of !2. Goodwin.y] Value is a (new) list consisting of all elements included on either of the two original lists. while union[(A A).!:! is the sorted list. 111 6 §2.y).comparefn]6 ~ is a list of i terns to be sorted using comparefn. comparefn is NIL. a predicate function of two arguments which can compare any two items on data and return T if the first one belongs before the second.!! is non-commut~tive.(A)J = (A).. 6 . union[x. on null•check. The sort is The value a··-----------------------------·-------------------------------------------~-The value of union is with all elements of ~ not in £!:!. W.T] will alphabetize by the SJ!. Value is a list whose elements are members of both intersection[x. and alphorder were written by J. thus sort[a·list.2.

FUM) in 2S· sort[x. then the ordering of ! and b mau or may not be pre~erued. strings are character 6 . and are ordered by magnitude (using greaterp). merge aborted be may a ft er control H. Interrupting with control D. cdr[a] ~ to cdr[ b]). For example. where n is length[ data]. The algorithm used by sort is such that tho maximum number of compares is nnlog 2 n. two arguments.b] A predicate function i. but control H may bo used at any time.comparefn] ! and are ~ lists which have sorted using !2£! and previously been is Value comparefn.b] . merge[a.11 ordered codes by in Literal atoms and comparing their the (ASCII) pnames. for Returns T if its arguments are in alphabetizing. FIE) appears before (FOO. Note: if comparefn[a. order. and sort will break at a clean state from which ? or control characters are safe. destructive merging of the two lists. or B may cause loss of data. comparejn[b:a). E.e. of if ~ does not belong before a. i f (FOO. a It does not matter which list is longerAfter merging both n and~ is are equal to the merged list In fact. Numbers come before literal atoms. Of course. Thus .returned is to data but elements have been !_q switched around. alphorder[a.b.T] may or may not reverse the order of these two elements. the user can always specify a more precise comparefn.

cplists is essentially a SRCCOM for structures. If neither ! nor . chcon. i. con.!! are atoms or strings. in order.se.. Atoms and strings are ordered before all other data types. because the character code for the digit Z is greater than the code for 1.stng the.12 list . the value of alphorder is T.e.s. 6. whereas alphorder[A23.s. It i.y] compares ! and x and prints their differences. iVote: alphorder doe.se other Junctions.s.several time.e.s or nthchar.alphorder(23t123J is T. cplists[x.Ster for alphabetizing than an11thtng that can be written u.s .A123] is NIL.s fa.s no unpack. i.

.Y..1 6.COMPAREFN] NCONC[X1..CHARFLGJ FLAST[X] FLENGTH[X] FfHH[X..3·4 6... list manipulation and concatenation LSUBST[X...5-7 6...6-7 6.. .. I G..XnJ SUBR• ..COMPAREFNJ SRCCOM SUBLIS[ALST..5..10 6..Y..B.4 ....6....7 6.Y] destructive functions DREMOVE[X.N] .X2..1·12 6...6 6......Z) LDIFF: NOT A TAIL (error message) LENGTH[L) ' LIST[Xl.6-7 6. ..ERRORFLG..N.Y] 6.....Z. ...2-3 6.L] OREVERSE[L] DSUBST[X.N] ILLEGAL ARG (error message) INTERSECTION[X.• LCONC[PTR.2-3 6. ~ INPEX.FLGJ SUBST[X:Y:ZJ TCONC[PTR.9 6...1 6.X] UNION[X.EXPR.L) REVERSE[L] SORT[OATA...9 6 .. .. ...N) .....9 I 6..1 ().2·4 6.V. ..10 6 ....11 6.4-6 6. null-check R (edit command) REMOVE[X.... ..9 6.....TAIL] fHH[X.6 6...4 6...4 6..... .8 6.8 6...8 6....Z] ERROR![] SUBR ESUBST[X...7·10 6.Index for Section 6 Page Numbers ALPHORDER[A:B] APPEND[ L] >'I ATTACH[X..4 6. ..XnJ SUBR• NCONCl[LST.12 6.8 6.5 6. ..7 6.5 6.. .7 6.....X] LOIFF[X.. .11 6 ...........Y] ATTEMPT TO RPLAC NIL (error message) BAD ARGUMENT FLAST (error message) BAO ARGUMENT FLENGTH (error message) BAD ARGUMENT FNTH (error message) 6....9 6.NEW...10 6. .8 6.. G .....7 .....Y] LAST[X] LASTN[L...10 .6-7 6.7 6..12 6.4 6.Z] MERGE[A....FLGJ SUBPAIR[OLD.. .. ...X2.6-7 6.Y...1..EXPR....4 copy COPY[X] COUNT[X] CPLISTS[X.......X] ULEFT[L.

.

However.· Property List Functions put[atm.prop.e with value val. although no checks are made to eliminate use of non-atoms in an odd position.e. Sometimes the phrase 'to store on the property--· is used.s tsob.2.stored on cdr of the atom. if atm is not a literal atom.searching Junctions all use !!. Searches !!! one looking for an occurrence of 7.s at a time. on this property list.val] puts on the property list of atm. The term ·property name' or •property' is used for the property indicators appearing in the odd positions.so generate an error.s as.sociated with literal atoms..1 Property Lists Property l i.serve this convention by cycling down the property l i.s in cdr of a literal atom.s t..l?!..se Junctions al. Properties are u.!/.val] Value is Y!.s two cdr. property value) although the user can store anything he wi. meaning to place the indicated information on the property list under the property name --.!:..J?. putl[lst. Nost of the.s t.prop. If . ARG 1VOT ATON. and are .suaLLy atoms. !!! replaces any previous value for the property . they cannot be used directly on lists.!· similar to put except operates on lists instead of property lists. the functions which manipulate property l i. However.SECTION 1 PROPERTY LISTS AND HASH LINKS 7. ARG NOT ATOM.Q.she. Generates an error. Property lists are conventionally lists of the form (property value property value . i.s are enti tte. if given an argument which is not a Literal atom.st . the property Lt.1 ~ ~· at a time + one is .. the property .2. and the term 'property value' or 'value of a property' or simply 'value' for the values appearing in the even positions.

be (FIE FUM). ~· fil:Q.21? is not found. the effect put[atm. If !l!!! does not have a property is the same as ~. addprop[atm.!:.Ust[new)). getp[FOO.PROP) will The value of addprop is the (new) If' !!!!! is not a 11 teral atom. in which case. the value is NIL.prop1. generates an ~ is error. otherwise NIL.FIEJ is followed by addprop[FOO. 1 f atm is error.urrences or the property 1!.!:1£.new. changeprop[x. for example. if addprop[FOO. + If J!!:. is T.2.2.PROP.BJ•(A B).JU is not found.prop. generates an error.+ found.flgJ ~ replaces the next element in the list. to the list which is the value ~ of property I!£.l! on property list of atm. generates an ARG NOT ATOM.prop2) Changes name of property list of of the property).prop. ARG NOT ATOM. property value.PROP. putl[NIL:A.B.2 x on list ~· If x is .Q!!.y) Gets the item after the atom 7. adds + the end of lst. Value is J!!:. ARG NOT ATOM.f. If not a literal on atom.21?• otherwise it is . + putl[(A BC O).Q.X)=(A B X 0). not a literal atom.19 is consed onto the front of value of ~ J!!:. get[x.IU property to prop2 (but does not affect the value Value is ~· unless J2!.prop] removes all occ.21? if any were found. remprop[atm. adds the value ~ followed by For example.£ed on the end (nconct). at ~ If .FUM).1!• (and 1 ts vallJe) from the property list of atm.

to search a property ·11st. £lil.!2.not on the list ~· get[(A BC D).3 . get[atom1anythi11g] is iVll.!?. For example. ( PROPl A PROP2 B A C). 1Vote: since fl!il.!:.ops that it finds e. in which case i t is searched as above. .s NIL H ~ is not a literal atom. value :!. terminates on a non•list. if there ts an occurrence of l!.Q. or get applied to cdr[atom].A] = PROP2.s NIL. getlis[ x. Note however that get[cdr[atm).so be iVIL. get ara and putl inverse operations. getp may al. getp[atm.(PROP2 PROP3))=(PROP3 B A C) Value is NIL if no element on ~ is found.B]=C.£ but the corresponding property value ts NIL.s then getp(atm.£ if not found. props J searches the property list of ~· and returns the property list as of the first property on pr. 1Vote: the value oJ Note: Since time.A] = C. getlis[x. ~ from the property The value of flill :l.• if the property list of~ is (PROPl A PROP3 B AC). e.prop] gets the property value for list of atm. x can also be a list itself. Therefore.g . 7.. or 2..g. should be used. if tho property list of atm :l. the ~ searches a list two i terns at a same object can be used as both a property name and a property value.

sed by the .e. etc. /Vote: 7.st of the property name. i. stored in cdr of the atom. The lialue of .prop) on the property lists of several atoms. The value of deflist is NIL.sv. Property lists are Hash links are implemented by computing an address.st. the break pack. is then called the hash-link . ! is a The first element of each is a literal atom.system already have property Li.s gives the complete ii. the hash-value and hash-item. (atoms.age. in a specified array. arrays. A hash link is an association between any INTERLISP pointer. storing the hash-value and the hash•item into the cell with that address~ and The contents of that cell.4 total number of . strings. A property list provides a way of associating information with a particular atom. Nany atoms in the .is used to put values under the same property name deflist[ 1 . et al) called the hash-item.su.sed by the compiler.sprop. with propertie. 1 Since the hash-array is obviously inuch smaller than the 7. and the second element is the property value for the property · lli. DWI/ol. lists. and any other INTERLISP pointer called the hash-value. called the hash-address. called the hash-array.s.sg.stem properties.s u.l!. numbers.such .s u.stem. Be careful not to clobber .2 Hash Links The description of the hash link facility in INTERLISP is included in the chapter on property lists because of the similarities in the ways the two features are used. list of two-element lists.

the hash array should be ten to twenty percent larger than the maximum number of hash links to be made to it. 4 or a cell containing a etc. j-----------------------------------------------------------------------------which is the total number of INTERLISP. the hash-address is computed using the same algorithm as that employed for malting the hash linlc corresponding cell 'is empty. 2 the hash-address computed from item may already contain a hash-link. Hash Link Functions In the description of the functions below. i. !l!!!!. H If the it contains a Otherwise. another hash-address must be computed.a the new hash-value simply replaces the Otherwise. be coraputed. 2561(.Jhen a hash link for i tern is being retrieved. and the array is either enlarged. the argument array has one of throe forms: (1) NIL. 6 Note that more than one hash link can be associated with a given hash-item by using more than one hash-array. in lNTERLlSP-10. the hash-value is returned. 5 For reasonable operation. hash-link from item. 3 ~ is used for comparing .link from i tern. hash. 4 After a certain number of iterations (the exact algorithm is complicated).possible hash-items. If this link is from old hash-value. \. as described below in the discussion of overflow.e. in which case the hash-array provided by the system. or an error is generated. there is no hash link for item. 7.5 . and so forth.!!fill! with the hash-item in the cell. another hash-address (in the same hash-array) must until an empty cell is' found. the hash-array is considered to be full.pointers.

e. equivalent to clrhash[array(n)]. gethash[item.maphfn) Value is ~· maphfn is a function of two.g.array] Value is array. 6 (2) a hash-array created by the function harra~: or (3) a list fl!.val.rnl ly aren't) the same size. . arguments. maphfn will be applied to the hash-value 7. If val=NIL any old link is removed.newar) hashes all items and values in oldar into new«r.!: of which is a hash-array. Replaces previous link from same item. . as described below. For each hash·link in array. lli. puts into array a hash link from 0 item to val.!!! in array.6 and hash· item.syshasharray. The two arrays do not have to be (and us1. and returns Value is NIL if no link exists. puthash[item. clrhash[array) sets all elements of array to 0 and sets left half of first word of header to -1. (hence a Value is val. maphash[array. gethash compiles open.array] finds hash-link from the hash-value. rehash[oldar.. harray[n] creates a hash-array of size n. hash-value of NIL is not allowed). if any . The latter form is used for specifying what is to be done on overflow. is used. Note that 9ethash makes no legality checks on either argument.

floating point number.!!. f). is equivalent to (hash•array . n).g. or (hash-array). by e.st by dumping and loading because read will create. iVote: all !I!f. is full and an attempt is made to store a hash link into it.sub.st.(ed back. Thus if two li. the user can provide for automatic enlargement of a hashmarray when it overflows. If a hash-array overflows. when they are dumped and loa<. 0 case. new .s containan !!. ( E ( DMPHASH SYSHASHARRAV)) as a prettydef command will dump the system hash-array. a new hash-array is more cells than the current hash-array.e.structures while equal are no longer £!!.structure. the corresponding . dmphash[arrayname] The value of maphash is array.5). the form (hash-array . 7. i. In the second case.maphash[a. the now hash-array is rplacaed into the dotted pair. and the array argument used was not one of these 7-------------•-••--•••••••••••a•a•••••••••-•••••G•-•••o-•m•••-••••••••--••-••- Circlprint and circlmaker (Section 21) provide a way of dumping and reloading structures containing !!! substructures so that these identities are preserved. and the computation continues. ..1 . Nlambda-nospread that prints on the primary output file a loadable form which will restore what is in the hash-array specified arrayname. the new hash array will be f times the size of the current hash array. The third In each case. created with rr The array argument is either of or (hash-array .structure for each item. identities except atoms and . 1. f a In the first case.· 1 Hash Overflow By using an array argument of a special form.sub.(LAMBDA(X V) (AND(LISTP V) (PRINT X)))] will print the hash-value for all hash-links from lists.small integers are lo. in. (hash-array). rr a positive integer.

t. 7.8 .three forms.5 when it is full. The system hash array. which will either cause a break or unwind to the last error. syshasharray.set~ as per treatment or errors described in Section 16. is automatically enlarged by t.he error HASH TABLE FULL is generated.

. .4·6 7. .6 7......7....7 7.....8 7..4 7 ...... 7.•..••••••••...4 ....... . . ...... 7 7..6 ....7 7..VAL] PUTHASH[ITEM..... PROP] OMPHASH[L] NL 111 ERRORSET[U. PROPS] GET P[ ATM ... . . .... i. .......7 7.8 7...PRINTFLG...MAPHFN] property property list property name property value PUT[ATM:PROP.PROP:NEW...2 7 .PROP2] CIRCLMAKER[LJ CIRCLPRINT[L...2 ...4 7.ARRAYJ SUBR PUTL[LST. .6..1.• hash-link hash-value MAPHASH[ARRAY.1 INDEX...4 7. ...4-5. .7 7.••...............4 7..1-2 7.....PROP] •..6 7.4-6 7......PROP.NEWARJ SUBR • REMPROP[ATM.5-6 7.3 7.RLKNTJ CLRHASH[ARRAY] SUBR DEF LIST[ l. ..1-2 7...1•4 1. PROP J HARRAY[LEN] hash link functions hash links hash overflow HASH TABLE FULL (error message) hash-address hash-array hash-item ..6 7..6 7....4-6 7.....•••••••••••• SYSHASHARRAY (system variable/parameter) SYSPROPS (system variable/parameter) value of a property ..PROP1. .....7 7......VAL] REHASH[OLDAR.1 7...3 7.. 7..........8 7.....4-5.VAL...1 7.FLGJ ARG NOT ATOM (error message) CHANGEPROP[X.V) SUBR GET[X..Index for Section 7 Page Numbers AODPROP[ATM...Y] GETHASH[ITEM...1 7.. 7.ARRAYJ SUBR GET LIS[ X.2 7.....6 7..2 7..

.

and getd which gets the . arglist. 2. in which case they obtain the function definition from the atom's definition cell~ or a function definition itself. 1. ccodep. an expr. its~ begins with F or Cf).. i. compiled Exprp. exprp.Qefinition in the cell. depending on whether the function is a spread or nospread (i. the function ~ returns the function type. arglist returns the list of arguments.QefiniUcm from the cell. described in Section 4.e.SECTION 8 FUNCTXON DEFINITION AND EVALUATION General Conunents A function definition in INTERLISP is stored in a special call called the function definition cell. 1 are called in a special wayD their definitions are stored 8 . or 3. argtype. Sub rs Because subrs. FSUBRlll as EXPR~ are true if the function is respectively. or and subr subr~ Xn addition. ~. argtype returns O. its fntyp ends in~). which is associated with each literal atom. or evaluate or no-evaluate (i. and nargs can be given either a literal atom.. which puts a . function. This cell is directly accessible via the two functions putd. ccode~.e. EXPR. subrp.. and nargs returns the number of arguments.1 .e.

2. a call to this function would transfer to the corresponding address. address of the first instruction of the subr.D. i. and produce random results i f the array were not compiled function. 1. Thus i f putd is given an array pointer. it treats it as compiled code. or 3. getd will then return the array pointer. compiled code. Similarly.) to tho expression originally given putd. stores the definition as a subr. or 3.! apart and stores f!. and address is in tho appropriate range. a call to that function will simply transfer to what would normally be the entry point for the function. takes the £2. address). Finally.. Similarly.e.2 A call to interpreter as described in the . if putd is given a dotted pair of the form (number . this function would then go through the appendix. putd assumes it is a subr and stores it away as described earlier.. or subrs.differently than those of compiled or interpreted functions. each Similarly.. i. where number gotcl ~. address) where number is O. of a subr returns a dotted pair of argtype and address. 2. or 3.£2.!l!· (number . Le.!: in the left half of the definition cell and ill in the right half. putd of a definition of the form = 0. 1. getd would then return ~ of the left and right half. putd and getd do not make thorough checks on the validity of definitions that "look like" exprs. and address falls in the subr range. 8. a dotted pair egual (but not !_9. Validity of Definitions in INTERLISP-10 Although the function definition cell is intended for function definitions. and simply stores the array pointer in the definition cell. if putd is given any other list. but a new getd of a subr performs a .e. and in the left half its argtype: 0. 2. in the right half of the definition cell is the In INTERLISP-10. 1. it simply stores it away. Similarly. Note that this is not the same word as appears in the definition cell.

if ~ is not a literal atom. not the dotted pair returned by getd. 2. page 8. Therefore.Q!!!· 8. number = O. 3 Value is NIL i f 2£ is not a literal atom. exprp is true i f a definition is a list and not of the form (number .£. getd of a subr performs a £2!!. 2 In other words.on cell. begins with LAMBDA or NLAMBDA. i. Similarly. open. subrp is true if it is of this form. getd will return this value.2.Note that putd does not actually check to see H the s-expression is valid def in i t ion. 4 2---------•--••-•••Ga••••••••••••••a•••-••••••••••e•-•••••-••-•••••••-••••••••• These functions have different value on LAMBDAs and NLAMBDAs and hence must check.s a definition. or has no definition. or 3 and address a subr address. exprp will return T. and nargs i. Only fnt:rQ and argtype check function definitions further than that described above: both argtype and ~ return NIL when exprp is true but ~ of the definition is not LAMBDA or NLAMBDA.e. fgetd[x] fast version of getd that compiles Interpreted. fgetd returns just the address of the function definition. arglist and nargs worlt correspondingly. 3 Note that in INTERLISP·10. arglist B. generates . getd[x] gets the function gefini ti. thereby saving the .. See footnote on fgetd below.!• as described on page 8. BAD ARGUMENT - FGETO. address).2. ccodep and subrp NIL. The compiler and interpreter also take different actions for LAHBDAs and NLAMBDAs. for subrs. 4 Fgetd is intended primarily to check whether a function ha. the editor and prettyprint will both treat it as a definition. rather than to obtain the definition. and therefore generate errors if the definition is neither. an error. 1.3 .on of ~. i f the user uses putd to put (A B C) in a function defini t:l. Value is tho definition.

definition of f!:. of the copyflg=T is only although ~ compiled functions and subrs as well.putd(x. if ~ x into function cell.Qm is used. ~·s Generates an error.. and argl ist. or x is a string. or a definition. Otherwise fntyp returns one of the following as defined in the section on function types: EXPR CEXPR SUBR FEXPR CFEXPR FSUBR EXPR• CEXPR• SUBR• FEXPR• CFEXPR• FSUBR* The prefix f indicates unevaluated arguments. nargs.y) version nlambda of considered quoted.copyflg] Moves the redefines putd. lf both are ~· of from copyflg=T. Value is definition !Q.y) l!.e.ElJJJ!.• argtype. the prefix £ indicates compiled code~ and the suffix • indicates an indefinite number of arguments.!:!!S the ~efinition Value is ~. movd(from. ILLEGAL ARG is not a literal atom. 8. or literal atom other than NIL. ~ i. fntyp( fn] Value is NIL if fn is not a function definition or the name of a defined function. meaningful for exprs. putdq(x... number. ill!J!. 1\fote: /. all can be gtven either the name of a Junction. ccodep. arguments to a !£. works for The value of movd is !Q. PUTO.to.4 . subrp.

SUBR) 1 no-eval/spread functions (FEXPR. 0. FSUBR*) i.. subrp[fn] is true if and only if fntyp[fn] is either SUBR.ts definition. 8. or FSUBRn. FEXPR. 1. or FEXPRtt. exprp is not quite as selective as fntyp. The interpretation of the argtype is: 0 eval/spread function (EXPR. but does not begin with either LAMBDA or NLAMBDA. FSUBR) 2 eval/nospread functions (EXPR*. exprp[fn] is true i f fntyp[ fn] is either EXPR. or CFEKPRQ.5 . argtype[fn] fn is the name of a function or :I. second column of fntyp•s. SUBR". SUBR~) 3 no-eval/nospread functions (FEXPR*. also true i f fn is (has) a list definition that is not a SUBR. exprp[ fn] h first column of fntyp's. See Section 11. or NIL i f fn is not a function. 2. ccodep[fn] is true if and only if fntyp[fn] is either CEXPR. argtype corresponds to the rows of fntyps.. CFEXPR*.~returns FUNARG if fn is a funarg expression. o . i. CEXPR.. EXPR"'. CFEXPR. i. or 3. The value of argtype is the argtype of fn.e. i. FSUBR..e. However. i.e. CFEXPR. In other words. CEXPRa.. the third column of fntyp•s. CEXPR*.e.

so If fn not is a nospread function. do not actually store the names of ~ or (U V). exprp. i f a SUBRit This is merely a 'feature' or arglist. As an example. 6 If fn is a SUBR or FSUBR. if fn is not a function. FSUBR 114 .!XJ?. If fn is.a compiled function. arglist[fn] the 'argument list' an is atom for Note that nospread Since NIL is a possible value functions. value is the 'argument list 1 for fn. the argument list is constructed. depending on the number of arguments. arglist.. consider the following two equivalent expressions for defining the function null. (U V W). each calY-to arglist requires making a new list. 8. the argument list is simply . the value of nargs is 1..value is the number of arguments of fn. an error for generated. or NIL if nargs[fn] fn is not a function. 1) (NULL (LAMBDA (X) (EQ X NIL))) ~------------------------------~----------------------------------------------1. ). define[x] The argument of define is a list. the value of arglist is (U). following 'arguments' is the body of the definition. However.£!.6 . the value is U. etc. that nargs[ (A ( B C) D) ]=2. i. these will be the argument names used when an equivalent EXPR definition is constructed.e.. and subrp are all NIL. if the user breaks or traces a SUBR (Section 15).e. Each element of the list is itself a list either of the form (name definition) or (name arguments •. For interpreted functions. ccodep. of getd. their arguments(s) on the.stack. In the second case. if~.9£. is ARGS NOT AVAILABLE. 5 nargs uses fn.

nlambda nospread version of define. (ALLPROP affects the operation of rpaqg and~. of the form described in define. or broken-in. This situation can arise when a function is redefined which was originally defined with LAMBDA misspelled or omitted. If If dfnflg=PROP or ALLPROP. redefined. dfnflg is initially NIL.7 .. section 5). If getd[fn] is non-NIL. If dfnflg=NIL. so dfnflg affects its operation the same as define. 8. Value is the property name used. arguments which are not defineg calls define.!!.lli. savedef[ fn) Saves the definition of fn on its property list under property EXPR. dfnflg=T. the user will not reset dfnflg directly himself. advised. Each x1 must be a list. but fntyp[fn] is NIL. saves on property name LIST. 1Vote: define will operate correctly if the Junction is alreadJI defined and broken. the function is simply the new definition is stored on the property list under the property EXPR..2) (NULL (X) (EQ X NIL)) define will generate an error on encountering an atom where a defining list is expected.e. dfnflg is reset by load to enable various ways of handling the defining or functions and setting of variables when loading a file. i. CODE. or SUBR depending on its f. For most applications. an attempt to redefine a function fn will cause define to print the message (fn REDEFINED) and to save the old definition of fn using savedef before redefining it. takes an indefinite number of evaluated.

CODE. unsavedef looks under EXPR. returns (prop NOT FOUND). unsavedef[fn. nothing is found and fn is a function. keeping one on its property list and the other in the function definition cell. is saved using savedef. list of the individual values. the current definition of fn. i. If ~ is not given. savedef operates on each function in the list.QJ!· above). otherwise generates an error.If fn is a list.Q£ (see savedef If nothing saved under ru:. in that order.a . is (NOTHING FOUND). any. a.e. Tho or if the value otherwise generates an error.prop) Restores the definition of fn from its property list under Value is property J!!. and its value is a list of the individual values. if Thus one can use unsavedef to switch back and forth between two definitions of the same function. NOT A FUNCTION. NIL. unsavedef operates on each function of the list. and its value is a. and SUBR. value of unsavedef is the property name. NOT A FUNCTION. If dfnflg=NIL. ~· and fn is defined. If fn is a list.

so tts argument is first evaluated.eval[ xf ~ eval evaluates the expression value and returns th is i. eval provides a way of calling tho Note that eval is itself a lambda interpreter.g . may still explicitly evaluate one or more of its arguments the case of setg. nlambda's same.E_lli applies the args. 8 Note that fn itself. the user can evaluated. eval[xJ. i.9 . is to The individual elements of . type function. (See Section 3.) !.e. Thus it eliminates the extra pair of parentheses for the list apply[fn. args evaluated by x and like Thus for the purposes of lambda's ~.• 7----------------------------0------------------------------------------------eval is a subr so that the 'name' ~ does not actually appear on the stack.' o-SET(FOO (ADD! 3)) (ADD1 3) o-(EVAL FOO) 4 o-EVAL(FOO) or (EVAL (QUOTE FOO)) (ADD1 3) e[x] nlambda nospread version of eval. 8 ~.. e. are ~ treated is a the lambda function so its arguments are evaluated before it is called e. Note however type just arguments equivalent to INTERLISP. However that in get ~ to the arguments are not fn is simply called with args as its argument list.e.args] of for eval. whereas SET) (QUOTE (FOO (ADD1 3)))) will set FOO to the expression 8. Thus SETQ) (QUOTE (FOO (ADD1 3)))) will set FOO to 4. as Til (APPLY (QUOTE (APPLY (QUOTE ( ADDl 3). function fn ~ e ~.g.

Here. FN is not defined. FN will not be evaluated.e.) evala[x. At any point.rptf] Evaluates the expression rptf rptn times.5. name ~ and is Note of ~· a for functional one can write equivalent that to (FN X V) specifies a call to the function FN itself. rptn is the number of evaluations yet to 8 . and will cause an error if. Compare with: .. 1. and then ~ is evaluated. . rpt[rptn.SET(FOOZ (SUB1 5)) (SUBl 5) .. (APPLY (QUOTE IPLUS) (LIST FOOl FOOZ) 7 .SET(F001 3) 3 .. Section 16.list[arg 1 . . (APPLY FN which (LIST X Y))....10 .argn)) equivalent to example. ! is a list of dotted pairs of variable namo and value. any variables appearing free in ~· that also appears as £!!: of an element of will be given the value in the £ru: of ~ that element.. ~is a form. fool and foo2 were evaluated when the second argument to~ was evaluated. · if fn · is the argument to be applied to (APPLY• FN X Y)... (APPLY (QUOTE !PLUS) (LIST FOOl FOOZ] NON·NUMERIC ARG (ADD1 2) apply[fn..SET(FOOl (ADD1 2)) (ADDl Z) .a) (See Simulates a-list evaluation as in LISP 1. ! is 'spread' on the stack.SET(FOOZ 4) 4 .

P.s.19. compiles open. i. the value of tho last If rptn i O. rptf is not.!:. the user wtll probably want to u. Used to access the lambda nospread individual arguments function. so both tt. e. argument.se !.!Jl an of a nlambda function used like ill· Yfil: is the name of the atomic argument list to a function.g. 1Vote: !. [LAMBDA X ( PROG ((M 0) (N 0)) LP (COND ((EON X) (RETURN H)) ) (SETO N (ADDl N)) [SETO H (PLUS H (ARG X N))) (GO LP] The value of arg is undefined for m less than or equal to O or greater than the 11alue of Yfil:· 9 8. is !. i. rptf is not evaluated. rptq[rptn. consider the and lambda-no~pread m is the number of is evaluated.. and is not evaluated: the desired example.P.PJ.s a lambda junctton.s arguments are e11aluated before W.take Returns place..I!! is NIL..!L.s called.st appltcatton.m] !.11 . For mo.rptf] nlambda version of rpt: rptn is evaluated. arg[var. (RPTQ 10 (READ)) will perform ten calls to read. and the value of !:. evaluation. following definition For of iplus in terms of plus.

8. setarg[var.ariable should never bo reset.x] !!!§. Note that the lambda v. individual arguments can be reset using setarg described below. and arg[X. e. e. arg[X:Z]•the value of B.t]•the value of A.g.g. (SETARG X (A001 N)(MINUS M)) would be an example of the correct setarg.12 form for . arg(X.m. However.3]•the value of c. in the previous example. mand is ~· Y.Lower numbered arguments appear earlier in the form.!U: is ! are evaluated. for (IPLUS A B C).· to ! the mth argument for the lambda nospread function whose argument list considered quoted.

...........7 ..5 8 .....4·6 8..7 8..8.............1-3............1•4 8...6 BAD ARGUMENT ... . a-list EVAL[X] SUBR EVALA(X. 0 ..6-7 8.7 8.... PUTDQ[ X.4-5 8.3•7 8.......7-8 8....7 8.......1.......6 8..6 8..4-5 8.............1........... .....1-2 8 ..3-4.......5...4-5 8..ARGS] SUBR APPLY"'[FN....3.....Y] SUBR • 8............FGETD (error message) BROKEN (property name) BROKEN-IN (property name) CCODEP[FN] SUBR CEXPR (function type) CEXPR~ (function type) • • • o • • • • • • • • • CFEXPR (function type) CFEXPR* (function type) CODE (property name) DEFINE[ X] DEFINEQ(XJ NLti DFNFLG (system variable/parameter) FGETD[X) • • e • 8...10 8. ......A] SUBR EXPR (function type) EXPR (property name) EXPRP( Fin SUBR EXPR"' (function type) FEXPR (function type) FEXPR"' (function type) • • • • • • • • • • • • e 8...7 ...Index for Section 8 Page Numbers ADVISED (property name) ALL PROP APPLY[FN.4 8.....7 8...PUTO (error message) INCORRECT DEFINING FORM (error messa~e) interpreter LAMBDA LIST (property name) MOVO[FROM.....9 8...................9 8... FMTYP[ X] FSUBR (function type) FSUBR~ (function type) FUNARG (function type) function definition and evaluation function definition cell functional arguments GETD[ X] SUBR ILLEGAL ARG ..1.. .......7-8 ~ .M] FSUBR ARGLIST[X] ARGS NOT AVAILABLE (error message) ARGTYPE[FN] SUBR argument list • • • • • • • • o e • • • e • • • • • "........5 8.7 6.7 8... .....TO.7 8.........10 8......... .3.ARGn] SUBR~ ARG[VAR..1-12 6 ..............7 .4-6 8.. 3-5 8.4 8..... INDEX......1.10 6....ARG1......3-4...7-8 8.9 8...4-5 6......... .1......... .COPYFLG] NARGS[X] NLAMBOA nospread functions NOT A FUNCTION (error message) (NOT FOUND) (value of unsavedef) (NOTHrnG FOUND) PROP[X............Y) PUTD(X. REDEFINED (typed by system) ...10 6..........3 8..........11 8...........9 8 ...............3-6 8. E( XEEEE J NL* 8..i 8 . Y] Nl.8 8..... ...8 8.. 1m5 8 ..1 a...... ... • • • • ·• • • • e • I • • • • • e .a 8.....3 8..... ........4-5 B..4-5 8....4 8.1 8 .7 8.4-5 8.....4-6 8...

. INDEX.rage Numbers RPT[ RPTN.1.3·5 .. RPTF] RPTQ[RPTN....10·11 8.7-8 8.11 8. 8.TYP] .4-6 8...8...M.4•6 8.1 8... 8.8 ..1 8.7-8 8 .6 8. .X] FSUBR spread fuhctions SUBR (function type) SUBR (property name) SUBRP[FN] SUBR subrs SUBR* (function type) U (value of ARGLIST) UNSAVEDEF[X...12 8 .2 ..RPTF] NL SAVEDEF[X] SETARG[VAR.. .

9.SECTION 9 THE INTERLISP EDITOR 1 The INTERLISP editor allows rapid. to edit a property list. 9. e. via editp. The reference portion begins on page 9. (often while the function itself is running) via the function editf. tho editor can also be used to edit the value of a variable. This chapter begins with a lengthy introduction intended for the new user.15. However. EDITF(FOO).1 .1 Introduction !----------------------------------~--------------------------------------------- The editor was written by and is the responsibility of W.g. convenient modification of list structures. or to edit an arbitrary expression. via editv. via edite.. an It is important feature which allows good on-line interaction in the INTERLISP system. Teitelrnan. Most often it is used to edit function definitions.

sublists of sublists are printed as &.. the current expression is the top level one.[LAMBDA (X) y (COND ((NUL X) Z) (T (CONS (CAR) (APPEND (CDR X Y] We call the editor via the function . The command ? will print the current expression as though printlevel were 1000.!!!: .!£!. Thus: •P (LAMBDA (X) Y (COND & &)) It Note that the editor prints the current expression as though printlevel were set to 2. the entire expression being edited. i.2 . lll? (LAMBDA (X) Y (COND ((NUL X) Z) (T (CONS (CAR) (APPEND (COR X Y)))))) lll and the cor.e. the editor's attention is centered on some substructure of the expression being edited.e. 2-------------------------··-··-------·······---------------·-----·-----------In other wQrds. i.e.. it signifies t~at the editor is ready to accept conunands.. EDITF(APPEND) EDIT Ill The editor responds by typing EDIT followed by *• which is the editor's prompt character. 2 At any given moment.unand PP will prettyprint the current expression. Initially. for print. i. tho rest by the editor. 9. and it is what the user sees when he gives the editor the command P.. all lines beginning with • were typed by the user. This substructure is called the current expression..

there are con di ti on al commands which branch on efrors.e . · 9. 3 the editor types the faulty command followed by a ? . thoy never cause breaks or even go through the error machinery but are direct cal ls to error! indicating that a command is in some way faulty. . and then another * The current expression is never changed when a command causes an error.. For example.structure being edited. Instead. -1 refers element in the current expression. In most situations.A positive integer is interpreted by the editor as a command to descend into the correspondingly numbered element of the current expression. but counting begins from the end or the current expression and proceeds backward. an error occurs. W'h« t happens next depends on the context in which the command was being executed. to the last For either positive integer or negative integer.3 . i. the old the editor actually operates by 3-----------------------------------------------------------------------------'Editor errors• are not of the flavor described in Section 16. an error will cause the editor to type the faul tY command followed by a ? and wait for more input.e. Thus: tip (X) i:iz phrase of the form 'the current expression is changed' or 'the current expression becomes' refers to a shift in the editor'. -2 the next to the last.. not to a modification of the .4 When the user changes the current expression by descending into it.s attention. Note that typing control-E while a command is being executed aborts the corrunand exactly as though it had caused an error. etc. though. i f there is no such element. i. current expression is not lost. Thus: A negative integer has a similar effect.

maintaining a chain of expressions leading to the current one. By now we have forgotten where we are in the function definition.~·. expression.-~~. and in fact there is a MOVE command in the editor. thereby making the previou$ link be' the current expression. its current position to a new position. for the purposes of this introduction.~:-... change Z to Y..-. However... a---~~. .. it removes the last link of the chain.~i~·~.::·~~~~-..·..:.. add Y to the end of the argument list. either by a carriage return... a~d insert a right parenthesis following COR X.·. Thus no command is actually seen by the editor. Tho editor operates in a line buffered mode.. the same as he does for inputs to evalgt. we will make the following corrections to append: delete Y from where it appears.. The user can thus use control-A and control·Q for line-editing edit commands. we will confine ourselves to the simpler edit corrunands..·.. which ascends through the enti~e chain of expressions to the top level expression... 4 change NUL to NULL. First we will delete Y.-~.-..4 . but we want to be at the "top" so we use the command t.~.~.~. add Z after CAR. 9. The current Descending adds the indicated thereby making it be the current The command O is used to ascend the chain. or executed. until the line is terminated. expression is simply the last link in the chain... In our editing session... subexpression onto the end of the chain. or a matching right parenthesis. the same as evalqt..-. Thus: *P x *O p (X) 111 0 -1 p ( COND ( & Z) (T & )) Ill Note the use of several commands on a single line in the previous output.

em. it is a NOP.5 .stcally change the . n. *(2 . *P Y) (CONp & &)) All .which then becomes the current expression. em before the nth element in the current expres~ion~ Thus: )'( p (LAMBDA (X) V (COND & &)) )'( e3) ex v)) . tq p (LAMBDA (X) V (CONO & &)) i:i Note that if we are already at the top. i.m ~ 1 replaces the nth element in the current expresdon with el ~ •. i.• em) n." The basic structure modification commands in the editor are: n (n) 1 deletes the corresponding ~ element from the current expression. Note that all three of the above commands perform their operation with respect 9. v means "go to the top.se. O would generate an error..s rplaca and rplacd to phy.structure modiftcatfon done by the editor t3 de3tr'ucttve..e . In other words. t has no effect. i." while O means "ascend one link. (LAMBDA ex . the edttor u.e..e. ( n e 1 •..structure tt w~s gtuen. However. t removes all links except the first one.m 2 1 inserts et •.

£Q. Instead. we will use F. "treat your next command as an expression to be searchod for. F says to the editor. and then replace it with NULL.!!S).g. the new current 9. to find NUL: *P . If the search is successful. e. If the target expression is not found there.n to the nth element from the front of the current expression: the sign of used to specify whether the operation is replacement or insertion. we use the command N (for !1. Similarly. counting out !11!! position from Thus. Rather than specify the sequence of descent commands necessary to reach NUL.unands. the find command. Thus we could have performed the above changes instead by: *P (LAMBDA (X) Y (COND & &)) *(3) 111 2 (N Y) *P (x fl f y) p *(LAMBDA (X Y) (COND & &)) * Now 1-1e are ready to change Nl)L to NULL. is no way to specify deletion or replacement of the the current without expression." The search is carried out in printout order in the current expression. F automatically ascends and searches those portions of the higher expressions that would appear after (in a printout) the current expression.. (LAMBDA (XV) (COND & &)) "'F NUL ll!p (NUL X) " ( 1 NULL) "0 p ((NULLX) 4) " Note that F is special in that it corresponds to two inputs. 3 2 l ( l NULL). wo cannot attach something at the end of the current expression using the above cor. In other words. thoro element from the end of or insertion before the nth element that element's is the front from of the the ond list. because we cannot specify insertion after a particular element.6 .

. all commands on the line. It can be restored. F NUL. Section 14).ich caused the error (and all commands that may have been typed ahead while the editor was computi~g) are forgotten. example illustrates another facet of the error recovery mechanism: This last to avoid further confusion when an error occurs. . described in Section . and neither the current expression nor the chain is changed: 6 "'p ((NULL X) Z) "'F COND P corm ? "'p "'((NULL X) Z) "' Here the search failed to find a cond following the current expression.· the· current expression after the search will never be the same as the current expression before the search. an error occurs. e. 6 and tho chain will be the same as one resulting from the appropriate sequence of ascent and descent commands. and the type-ahead recovered via the command $BUFS (alt-mode BUFS). if successful. i. 7 We could also have used the R command (for replace) to change NUL to NULL. Thus F expr repeated without intervening commands that change· tho edit chain can be used to find successive instances of expr. A command of the form ( R e 1 e 2 ) will replace all occurrences: of e 1 in the current expression by e 2 • There must be at least one such occurrence or the R command will generate an error.expression will be the structure where the expression was found.7 . 9. If the search is not successful. Let us use the R command to change all Z's (even though there is only one) in append to V: 5------------------------------------------------------------~----------------If the search is for an ato~. th~ current expression will be the structure containing the atom.e.. the input buffer is cleared (and saved) (see clearbuf. i. al though of course a cond does appear earlier in the structure. 6 7 F is never a NOP. 22.g.e. beyond the one wh.

we will always have the same number of left parentheses as right parentheses. parentheses. deleting the Y. or (2 (CDR X)) and (NY).LO. or by: •F CAR • ( N X) wp (CAR X) Ill The expression we now want to change is the next expression after the current expression. if V were a complex expression.(R Z V) i:tt "'F Z z ? *PP [LAMBDA (X Y) (COND ((NULL X) Y) ( T ( CONS The next task is to ( CAR) (APPEND (CDR X Y] change (CAR) to (CAR X).. or we can use the co1M1and NX.LI. we could perform (2 (CDR X) Y). because the parentheses are just a notational guide to 9.e. which does both operations: ftp (CAR X) *NX P (APPEND (CDR X Y)) * Finally. to change (APPEND (CDR X Y)) to (APPEND (CDR X) Y). i. However. we could use a command which effectively inserts and/or left and right BI. for ~ight 2ut. and RO. !eft !n.8 . [i9ht !n. and Of course. or 2 and (3). we are currently looking at (CAR X) in (CONS (CAR X) (APPEND (CDR X Y))). and then 0 (N Y).BO. removes Instead. We could do this by (R (CAR) (CAR X)).RI. ~oth !n. We could get to the append expression by typing 0 and then 3 or -1. ~oth There are six of these commands: QUt. we would not want to have to retype it. left QUt.

by using the E conunand: *E APPEND((A B) (CD E)) (A B C D E) It The E cor. to test append. the input is evaluated ( eval). and can exit from the editor.unand causes the next input to be given to evalgt. which means parentheses after the second element in the second ~lement insert a right (of the current expression): !lip (APPEND (CDR XV)) ""(RI 2 2) •P (APPEND (CDR X) V) 111 We have now finished our editing.structure that is provided by our print program. as in the above example. but this is very suggestive of what actually happens. and leave the editor. Otherwise. and right out actually do not insert or remove just one parenthesis. or we could test it while still inside of the editor. left out. We prettyprint append. If there is another input following it. left in. Therefore. 9.9 . In this case. right in. the first will be applied (apply) to the second. 8 Thus. we would like a right parenthesis to appear folldwing X in (CDR X Y). we use the command (RI 2 2).

i.· They are not presented in any particular order. the \. no matter how complex. UNDO undoes the last modification to the structure being edited. because he can always reverse the effect of the command. BF Qackwards find.g. UNDO will restore it. and the remainder of this chapter is organized and presented accordingly. except backwards. BK like NX.10 searches .le include here as part of introduction a list of those commands which are not only frequently applicable but also easy to use. if the user deletes the wrong element. · \.. and are all discussed in detail in the reference portion of the chapter. 9.111pp [LAMBDA (X Y) (COtm ((NULL X) Y) *OK APPEND (T (CONS (CAR X) (APPEND (CDR X) Y] . there are many situations in which knowing the right command(s) can save the user considerable effort. Like F.. the user could perform any and all editing operations using Just those commands. in invetse print order./hile the commands introduced in the previous scenario constitute a complete set. e. except makes the expression immediately before the current expression become current.. i:e. 9. the INTERLISP manual is intended primarily as a reference manual.e. Of UNDO should give the The availability user confidence to experiment with any and all editing commands.l Commands for the New User As mentioned earlier.

'\ would tnko him batk to trie CONO.e. but not F (COR &). either by P. incorrect definitiori of append Thus. \P restores it to its state as of tho printing· before that one. \P will take him back to tho first P. and -. two chains aro always saved. For example. types F COND. \P like \ except it restores the edit chain to its state as of the last print. Note that & and -.. i.. if tho us or and then · F CAR. An6ther \ would take him back to the CAR. & &). e. can be anywhere within ihis pattern to match with it use cl any single element of a list.can be nested arbitrarily deeply in the pattern. Thus i f the user types P followed by 3 Z 1 P. ?. to find (CDR X Y). 9 .g. ·Another \P would then take him back to the second P. would be equivalent to 0 0 0.· Restores the current expression to the exprossion before the last "big jump".er can use \P to flip back.can be used to match with any segment of a list. &. Thus the us. pat tern. and forth between two current expressions. The symbol & Instead. or PP.. -- The search expression given to the F or BF command be 'need not can be a a ii teral S~expresSion. If the edit chain has not been changed since the l~st print.e. an t. tised · F ( NUL & ) could have been used to find and F (CDR --) or F'(tDR in tho earlier. ( NUL X). i.11 For . a find comrnancl. or another \.

. if there are many places where the variable X is set. VERS will match with VERVLONGATOM. However •. e. In other words. inside F (SETQ VERS (CONS ··)). In this case. he may not know what that number is. the user must be abo11e the current expression.• em). F SETQ may not find the desired expression.at the ch•racter level. SLONGS. e.. In order to do this using a command of the form ( n e 1 .12 . It may be necessary to uso F (SETO X (LIST--)). e. he would have to perform a 0 followed by a command with tho appropriate number. if he has reached the current expression via an F command. higher current Then he could perform the desired operation via (1 e 1 ••. as will $ATOM.•. •F (SETO VERS &) . of nested $ lf the search is successful. em) or (-1 e 1 . 9.g. em>· UP is provided for this purpose. the usual technique in such a case is to pick out a unique atom which occurs prior to the desired expression.. This "homing in" process seems to be more convenient than ultra· precise specification of the pattern. or insert something before it. nor may F (SETQ X &). the user would like a command whose effect would be to modify the edit chain so that the current expression expression.g..example. and perform two F commands. VERVLONGATOM * Frequently the user will want to replace the en'tire current expression. became the first element in a new. can be a pattern..g. (but not $LONG) and SV$NSMS. the editor will print = followed by the atom which matched with the $· atom. S (alt-mode) $ is equivalent to -. However.• em) or (·n e 1 •.

e.• em after the current express ion. (APPEND & Y)) 111 no p (CONS (CAR X) (APPEND & Y)) Ill The •. 9. i.e. Note that if the current expression happens to bo the first element in the next higher expression.13 . member) of the next higher expression.. i. ( B e 1 ••• em) inserts e 1 •. then UP is exactly the same as O..e . .. UP has no effect. Otherwise. does an UP and then a -1. (A e 1 ••• em) inserts e1 •.• a . does an UP and then either a (·2 e 1 . em). .UP after UP operates. em ·before . an element ( 1. is used by the editor to indicate that tho current expression is a tail of the next higher expression as opposed to being. the current expression. UP modifies ·the edit chain so that the new current expression is & tai1 9 of the next higher expression: F APPEND P (APPEND (CDR X) Y) *UP P ..... ttie current e·xpression is al ready a tail.. Note: i f .. if the current expression is the last one in the next higher expression. the old current expression is the first elemerit of the new current expression. em) or an (N e 1 ••.

does an UP and then a (1 e 1 ••• em>· DELETE deletes current expression: equivalent to ( :). and the user wants to replace it by (COND (FLG (PRINT bigexpression))). In addition. LO.. the commands MBD and XTR can be used to combine the effec1. and (LO 1) or i>Y a single XTR command. LI. extracting the PRINT expression from the above CONO . (Ll 1). used to embed the current expression in a larger expression. and RO.14 ..47. (-1 FLG).e. The rest of the corrunands in this family: BI.. BO. The new user is encouraged to include XTR and HBO in his repertoire as soon as he is familiar with the more basic corrunands. For example. ••• em) i.. we.(: el replaces current expression by e 1 • • • em.could be accomplished by (1).. if the current expression is (PRINT bigexpression). or by a single MBO command. -. This ends the introductory material. 9. MBD is For example. and (·1 CONO). perform similar functions and are useful in certain situations. introduced the RI command in the append example. page 9.s of several commands of the BI•BO family. he could accomplish this by (LI 1). Earlier. (LO 1). XTR is used to extract an expression from the current expression. (1).

big jumps. \P. small steps versus open ended.15 . UP.3 Attention Changing Commands Commands to the editor fall into three classes: commands that change tho current expression (i. o.e. (2) those which depend on the contents of the structure. \... change the edit chain) thereby "shifting the editor's attention. 0. e.15·21. NX.1 UP Local Attention-Changing Commands ( 1) If a P command would cause the editor to typo before typing the current expression. UP has no effect. and miscellaneous commands." conunands that modify the structure being edited.e. Within the distinguish context of commands among ( 1) those that shift the editor's a1. commands that search. and (3) those commands which simply restore the edit chain to some previous state. (1) and ( 2) can also be thought of as local. evaluating expressions.e. and type (3) on page 9.g.g... otherwise (2) UP modifies the edit chain so that the old current expression (i..structure of the edit chain. Otherwise UP adds the corresponding tail to 9. etc..tention. e.34-36. e. Commands of type ( 1) are discussed on page 9 .g. i. 9. 10 10----------------------------------------------------------------------------· If the current expression is the first element in the next highor expression UP simply does a the edit chain. the one at the time UP was called) is the first element in the new current expression. exiting from the editor.3.e.9. i. tho current expression is a tail of the next higher expression. type ( 2) on pago 9.21-34. printing. commands whose operation depends only we con on tho .

Examples: The current expression in each case is (CONO ((NULL X) (RETURN Y))).16 . 1..~~-.~. "-1 p ((NULL X) (RETURN Y)) 1111 UP P ((NULL X) (RETURN Y)) •uP P ../hen UP is Thus after called.. lastail is (NIL C NIL). 9. UP generates an error.~.·. UP is finished. ((NULL X) (RETURN Y))) 3. this tail is the the current correct one. Otherwise.-~~. For example.. for example the user has directly (and incorrectly) manipulated the edit chain. the current expression should then be . UP can determine which tail is the correct one because the commands that descend save the last command tail on an· internal editor variable. *F NULL P (NULL X) *UP P ((NULL X) (RETURN Y)) *UP P ((NULL X) (RETURN Y))) The execution of UP is straightforward. ii--. If it is.~~~~~-~~~~i~-~~~~~~-~~-~~~~~~--.-~.. lastail.·. if the current expression is (A NIL B NIL C NIL) and the user performs 4 followed by UP. 1q p corm UP P ( COND (& &)) 111 2.... UP computes memb[current-expression. If i t is neither.~~. except in those cases where the current expression appears more than once in the next higher expression. is executed.~~...~~-~f-~h~ next higher expression.~. the 4 it first determines if the current expression is a tail of the next higher expression. \. NIL C NIL).next-higher-expressionJ to obtain a tail beginning with the current expression expression • 11 in the next If there are no other instances of higher expression.

for example if there were two non-atomic structures in the same expression that were ~· and the user descended more than one level into one of them and then tried to come back out using UP. -n (n > adds the !lth element from the end of the current 1) expression to the front of the edit chain. 0 making the next higher current expression. thereby making it be the new current expression. thereby making it bo the new current. has no detrimental effects. In this case.expression. Sots Generates an error if tho current expression is not a list that contains at least n elements. this would bo a costly solution to a situation that arises infrequently. lastail for use by UP. Of course. Sets edit chain to cdr of edit chain.Otherwise UP uses lastail to select the correct tail. Note that 0 usually corresponds to going back to the next higher left i2----------------------------------------------------------------------------0ccasionally the user can get the edit chain into a state where last<1il cannot resolve the ambiguity. UP prints LOCATION UNCERTAIN and generates an error. 9. cdr of edit chain is NIL. we could have solved this problem completely in our implementation by saving at each descent both elements and tails. The las tail solution is cheap and resolves 99% of the ambiguities. expression be thor(lby the now Generates an error if there is no higher expression. and when it does. Generates an Sets lastail for uso error if the current expression is not a list that contains at least n elements. i. However. by UP.17 . 12 > n (n adds the nth element of the current expression to 1) the front of the edit chain.e.

the command !O can be used. 9. c 0 E F G) •3 UP P ••• E F G) •o P . i.ere would be if NX operated by performing an UP followed by a 2. effectively does an UP followed by a 2. if the current expression is performs~ •3 UP P . NX Never generates an error. 14 Both NX and BK operate by performing a !O followed by an appropriate number. thereby making the top level expression be the current expression.. but not always. (However.18 .. regardless of any intervening tails.e.e. expression be the next Generates an error i f the current expression is the last one in a list. c 0 E F G) If the intention is to go back to the next higher left parenthesis. i. 't sets edit chain to last of edit cha in.. !NX described below will handle this case. (A B C D E F B).) BK makes the current expression be the previous ii--------------------------------------------------------------~-------------! O is pronounced bang-zero.. there won't be an extra tail above the new current expression. as th. 14 the~eby making the current expression. 13 !0 does tepeated O's until it reaches a point where the current expression is not a tail of the next higher expression.parenthesis. always goes back to tho next higher left parenthesis.. and the user For example.

makes current expression be the next expression at a higher level.expression in the next higher expression. and vice versa. the edit chain is not changed. For example. if the current expression is (COND ((NULL'X) (RETURN V))): RETURN P (RETURN Y) ~BK P (NULL X) ""'F ( NX n) n > 1 equivalent to .e. Note: !NX (NX -n) is equivalent tb (BK n). . except i f an error occurs.!! NX ccimmands. (BK n) n > 1 equivalent to !! BK commands. the edit chain is not changed.19 ~et to the next expression. goes through any number of right parentheses to 9 . except i f an error occurs. 1.. Generates an error H the current expression is the first expression in a list.

. i. i.e.. Thus !NX always goes through at least one unmatched right parenthesis. causes tho list starting with the nth element of the current expression (or nth from the end 9. and the new current expression is always on a different level. and then does a NX. !NX and NX alwnys produce different results. For example using the previous current expression: "'F CAR P (CAR L) "'!NX P (GO LP) *\P p (CAR L) lltfJX p (CAOR L) lit (NTH n) n ~ 0 equivalent to !! followed by UP.20 if n < O) to .e.for example: •pp ( PROG ((L l) ( UF L)) LP <corm ((NULL (SETQ L (COR L))) (ERROR! )) ([NULL (COR (FMEMB (CAR L) (CADR L) (GO LP))) (EDITCOM (QUOTE NX)) (SETQ UNFIND UF) (RETURN L)) *F CDR P (CDR L) *NX NX ? "!NX P (ERROR!) "!NX P ((NULL&) (GO LP)) *!NX P (EDITCOM (QUOTE NX)) It !NX operates by doing O's until it reaches a stage where the current expression is not the last expression in the next higher expression.

become the current expression . 16 We will therefore begin our discussion of searching by describing the pattern match mechanism. VER$ matches both of e. 15 Causes an error i f current expression does not have at least !! elements. A generalized form of NTH using location specifications is described on page 9.~.2 Commands That Search All of the editor commands that search use the same pattern matching routine. and $V$L$ T$. as is (NTH -n) where n is the length of the current expression.il matches with :s if: 1.21 .32. ~ is a number 4. i l l is a literal atom or string containing one or more alt- modes. each $ can match an indefinite number (including 0) contiguous characters in a literal atom or string.il is 3. 9. VERYLONGATOM and "VERYLONGSTRING" as do $LONG$ (but not $LONG). If car[pat] is the atom &.89. 16 This routine is available to the user directly. If x. E. 5.x] is true.3. 9. A pattern 2. and~ to :S· ~ANY~. ~ is a string and strequal[pat. ~is~ to~· 2. cdr[pat] is a list of patterns and pat matches x i f and only if one of the patterns on cdr[pat] matches 6a. ]5----------------------------------------------------------------------------~ (NTH 1) is a NOP. and is described on page 9.

. However.g. E. If pat is a literal atom or string ending in two alt-modes. . =VERYLONGATOH. CONSSSS matches with CONS. i.1 7 e. and cdr[patJ matches cdr[xJ. cdr(pat] matches with some tail . b. -. Otherwise if ~ can match any interior segment or a list.22 . i1------------------------------------------·----·----------------·-----------unless editquietflg=T.e. B) ·In other words. When the editor is searching.I:@. 8. (A ~· (&)) will match with (A B C (D)). (A ·-) matches (A) (A B C) and (A . note that (A -- (&) --) will match with (A B·C (0) E).. If car[pat] is the atom is~ to ~. 18 Pattern 8 is for use by programs that call the editor as a subroutine.of e. 7. 9.PJil --. -. but not (ABC 0).g. since any non-atomic expression in a command typed in by the user obviously cannot be~ to already existing structure. or (ABC (0) E). in which case cdr of the pattern is matched against proper tails in the structure. matches~ is a list. e.g. 18 9. Thus if the current expression is (A B C (B C)). pnt matches with the first atom or string that is "close" to pat. In other words. ~ if cdr(pat]=NIL.g. If car[patJ is the atom ·-.P!! matches ~ if and only if cdr[patJ if car(pat] matches car[x). CNONCSS with NCONC or NCONC1. The patter~ matching routine always types a message of the form =x to inform the user of the object matched by a pattern of typo 6a or Gb.6b.can match any tail of a list. unless the pattern begins with •. . the pattern matching routine is called to match with elements in the structure.! matches a. pat=(-·). in the sense used by the spelling corrector (Section 17).

. The pattern NIL will only match with NIL as an element. c) Although the current expression is the atom C after the final conunand. in which case it is matched against the next tail of the expression. unless the pattern begins with . '1 Thus p (A (B • C)) "'F C "'P . it will not match in (A B). Search Algorithm Searching begins with the current expression and proceeds Searching usually consequently a means match is find not the next attempted instance that would of in print order. •. whereas ( . the edit and chain unchanged... BC (BC)) Matching is also attempted with atomic tails (except for NIL). B -.>'IF (B --) >'<P (B C) "'0 F ( . e.•. ( •.. not an Note that the pattern C will match with either instance of C in (AC (B • C)).g.. 19 At each step. .•• NIL) will match with cdr of the third subexpression of (~A . there is a version of the find command which can succeed and leave the current expression unchanged (see page 9.ly the second C. B) (C . . )) may be used to specify a NIL tail.26). C) will match on. i. this leave pattern..23 . D) (E))..) "'P ••.e.. NIL) (or equivalently ( . 9.. C) to alert the user to the fact that C is a tail. evon though cddr of (A B) is NIL. However. the pattern is matched against the next element in the expression currently being searched.. element. ( . . j9----------------------------------------------------------------------------However. . it is printed as .

Q!s descended into) allowed to exceed the value of the variable maxlevel. This process· continues until the entire edit chain has been searched. 22 and continues searching there on the next expression after the expression it just finished searching. i.24 . it ascends again. the search descends into that list before attempting to match with other elements (or tails) at the same leve1... At that point.. 21 a successful match is not found in the current expression. If the search is successful. exactly as though the element or tail had been completely searched with out finding a match. if the element undor examination is a list. does not descend into elements.e. what is equivalent.27) which only attempts matches at the top level of the current expression.e.£.. at no point is the total recursive depth of the search (sum of numbor of £i!. If there is none. i. 20 However.§. 21 rnaxlevel can also be set to NIL. an expression is found that the pattern -------------------------------------------------------------~----------------20 There is also a version of the find command (see page 9.!: direction and then in the .!!!: direction. If maxlevel is initially set to 300. etc. and an error is generated..e.24.If the match is not successful. which is equivalent to infinity. This feature is designed to enable tho user to search circular list structures (by setting maxlevel small). as woll as protecting him from accidentally encountering a circular list structure in tho course of normal editing. the edit chain is not changed (nor are any conses performed).l:S and f. If the search fails (or. the search operation is recursive first in the f. and the search continues with the element or tail for which the recursive depth is below maxlevel.. 9. or ascend to higher expressions. i. the search automatically ascends to the next higher expression. at which point the search fails. is aborted by control-E). 22 See footnote on page 9. the search of that element or tail is abandoned.

24 Unless upfindflg=NIL (initially set 9.. is not a list. two commands: the F informs the editor that the ne~t pattern. In this case. 8). F pattern means find the next instance of pattern. 35). i. 23 i.. and do not change the edit chain or perform any conses if they are unsuccessful or aborted. the search effectively does an UP. for discussion.. In other words.current-expression) is true. If the expression that matched was a list. e.e. see pago . the edit chain is set to the value i t would have had had the us or reached that expression via a sequence of integer commands. the current expression will be B.43-44. that atom will be the first element in the new current expression. the edit chain always chlmges.25 to T).. it will be the final link in tho edit chain..e.g. F pattern i. F invokes the search algorithm described earlier.matches. F If the value of the memb is NIL.e.. is an atom. of the command is to be interpreted as a This is the most conunon and useful form find command. If successful. If memb[pattern.g.. but will print as . If the expression that matchod the current expression will be the tail beginning with that atom. B in (A . the new current expression. set unfind for use by \ (page 9.. 23----------------------------------------------------------------------------Unless the atom is a tail. e. 9.e. 24 Search Commands All of the commands below set lastail for use by UP. does not proceed with a full recursive search. B). i.

and does not perform the m~mb check. (F pattern T) Similar to F pattern.•• LPl ••. followed by F LPl would find the first LPl. ). F COND will look for the next COND. it just has to match n times. If the pattern does not match successfully !! times. F LPl will find the prog label. Each by time pattern successfully matches. 9. Thus if the current expression is ( FOOi FOOZ f003).. (F pattern N) same as F pattern. but (F CONO T) will 'stay here'.Thus if the current expression is (PROG NIL LP (COND (-• (GO LPl))) . !! is decremented by 1. and the search continues. not the LPl inside of the GO expression. except may succeed without changing edit chain. Note that 1 (making the atom PROG be the current expression). Thus i f the current expression is (COND •• ). (F pattern n) n 1 1 Finds the nth Equivalent (F pattern to N) place (F that pattern repeated n-1 pattern matches. finds the next instance of pattern. even though the latter appears first (in print order) jn the current expression. followed T) times. except the ~ check of F pattern is not performed. i.26 . until n reaches O. an error is generated and the edit chain is unchanged (even if the pattern matched n-1 times). ( F FOOS 3) wil 1 find F003. Note that the pattern does not have to match with !! identical expressions.e.

e. F COND will find the COND inside the SETO. (F= expression x) equivalent to (F C== expression) searches for a structure fill to expression.e... 9. {ORF pattern 1 . nor will it go outside of the curront May succeed without expression.• patternn) N). whereas (F (CONO -·))will find the top level CONO..27 .. For example...e. in which case BF searches the entire expression. edit chain followed is left by F at place x).. beginning with expression immediately before the current expression (unless the current expression is the top level expression. search wi 11 not descend into i. searches for an expression that is matched by either pattern 1 . i. patternm-l matched. Searches in reverse print order.. BF pattern ~ackwards find. i.e. the second one. the tho curront expression.(F pattern) or only matches with elements at the (F pattern NIL) top level of the current expression.22. changing edit chain. . ).21. if the current expression is (PROG NIL (SETO X (COND & &)) (COND &) . in reverse order).. pattern 0 ) equivalent to (F (~ANY~ pattern 1 . i. pattern 2 ... see page 9. (FS pattern 1 ••• patternn) equivalent to pattern 2 followed by F patternn' so that if F patternm pattern 1 F fails. or pattern 11 • See page 9.

then ascends and backs up. and descends into each element before attempting to match that element. Location Specification ~lany of th. F LIST SETQ. i..BF uses the same pattern match routine as F. First. etc. F CONO followed by (BF SETQ T) would find the (SETO W --) expression.. at which point BF ascends and backs up. etc. but the searching begins at the end of each list. A location specification 1S a list of edit commands that are executed in the normal fashion with two exceptions. (BF pattern) (BF pattern NIL) same as BF pattern. If unsuccessful. until the front or the list is reached.e. tho so arch continues with the next previous element.e more sophisticated commands described later in this chapter uso a more general method or specifying position called a location specification. (BF pattern T) search always includes current expression. if the current expression is (PROG NIL (SETO followed by ~F X (SETQ Y (LIST Z))) (CONO ((SETQ W ··) --)) -·). Thus in the previous example. For example. all commands not recognized by tho 9. starts at the end of current expression and works backward. will leave the current expression as (SETO Y (LIST Z)). as will F COND followed by BF SETQ. where F COND followed by BF SETO found (SETO Y (LIST Z)). etc. and maxlevel and upfindflg have the same effect.28 .

and so the entire location operation would fail. i. the location specification (COND 2 3) specifies the 3rd element in the first clause of the next CONo. 9. of the location In other words. tho execution of the command 3 would cause an error. The search would thon continue by looking for the next COND. would cause the error. and the first clause of the next COND contained only two elements. then the first command. will be described in detail later in the chapter. However. specification. and cause an error. @ can also be atomic.e. Thus. the edit chain would not have been changed.editor are interpreted as though they had been preceded by F. the meta-symbol @ is used to denote a locatio11 Thus @ is a list of conunands interpreted as described above. COND. in which case it is interpreted as list[@]. if an error occurs while evaluating one of the commands in tho location specification. Throughout this chapter. along IF and with ## examples illustrating their use in location specifications. 25 For example. at which point it gives up. ir a point were reached whore there were no further CONDs. 26 Note that the user could always write F COND followed by 2 and 3 for (corm 2 3) 1f he were not sure whether or not COND was the name of an atomic command. tho location operation keeps going unless it reaches a state where it detects that it is 'looping•.29 . was not tho same as it specification. was the at the beginning of that execution location operation will continue. if (COND 2 3) is being located.26 Secondly. and the edit chain had been changed. The IF command in conjunction with the ## function provide a way of using arbitrary predicates applied to elements in the current expression..

27 27-----------------------------·--·--·-------$·-----------·----------·--------If pattern is of the form (IF expression). it keeps doing gets to a specified point.. @) that if followed the first by another succeeds (LC . to find a COND containing a RETURN. example. 9. @) and second fails. (3RO . ascends the edit chain looking for a link which matches pattern. If pattern is atomic. the edit chain rebound during the search so that it is looks as though the editor were called on just the current For expression. (LC COND 2 3) will perform the tho search described above. expression is evaluated at each link. O's until it In other words. or the evaluation causes an error.(LC .e. otherwise with the entire link. and i f its value is NIL. i. @) provides a way of explicitly invoking tho location operation. and make the final current expression be the COND. one might use the locntion specification (COND (LCL RETURN) \) where the \ would reverse the effects of the LCL command. e. (LCL • @) Same as LC except the search is confined to the current expression. no change is made to the edit chain. it is matched with the first element of each link. ascent continues.30 the . @) (o- pattern) Similar to ZND..g. (2ND • @) Same as except (LC .

not the higher COND. i t simply ascends.g. If no match is found. not tails. 29 1. e. 9. and then backs off (BELOW com) a (BELOW COND) will cause the cond clause containing the current to become the new current expression. (BELOW com ascends x) the specified by that. Thus in the above example. edit chain ££!!!. (BELOW com (IPLUS X Y)). e. same as (BELOW com 1). and the edit chain is unchanged.. and looking stops x28 for links below ~ O's.For example: i:ipp [ PROG NIL (COND [(NULL (SETQ L (CDR L))) ( COIJD "'F CADR ( FLG (RETURN L] ([NULL (CDR (FMEMB (CAR L) (CADR L]] "'< ~ corm> "'P ( COND ( & & ) ( & & )) >'! Note that this command differs from BF in that it does not search i11. For example.31 . expression link BELOW keeps doing O's until it gets to a specified point. F CADR followed by BF COND would find (COND (FLG (RETURN l))). Thus if the current expression is as shown above.sicle of each link. an error is generated. F CADR followed by (BELOW COND) will make tho new 28----------------------------------------------------------------------------x is evaluated. 29 Only links that are elements are counted.

Effectively performs (LCL . expression that was the.that contains a FOO (at any depth). and wants to find a sublist ..expression be ([NULL (CDR (FMEMB (CARL) (CADR L] (GO LP)). if the user is inside of a SELECTQ claus•. suppose the user is editing a list of lists. For example.J4) the chain he can use NEX to step through the sublists. same as ( NEX . he can advance to ~eep the next clause wiih (NEX SE(ECTQ). He simply executes F FOO (BELOW \). x). NTH locates ~· using a search restricted to the current expression.terminus of the location operation. however deeply. By simply MARKing page 9.32 the . (NEX X) For example. and then backs up to the current level. The BELOW command is useful for locating a substructure by specifying somethihg it contains. followed by UP. "'P (PROG (& &) LP (COND *(NTH UF) For example: & &) (EDITCOM &) (SETQ UNFIND UF) (RETURN L)) •p (SETQ UNFIND UF) (RETURN L)) 9. generalized x) (see NTH command. foliowed by (BELOW \). ) • NEX The atomic form of NEX iS useful if the user will be performing repeated executions of corresponding to (NTH (NEX ~· x). same as (BELOW x) followed by NX. and is therefore equivalent to 0 0 0 0. where the new current expression is the tail whose first element contains. In other words.

' is not a meta-symbol. (pattern . RETURN) • contains a return.If the search is unsuccessful. Note that it is the innermost COND that is found.. In other words. if the current expression is (PROG NIL [COND ((NULL L) (COND (FLG (RETURN L] ·-). RETURN) will make ( COND ( FLG (RETURN L))) be the current expression. g. which will locate the first COND that contains a RETURN that contains a CONO. Thus can be used to find the RETURN which contains a COND whose first clause contains (at least) three elements. and in· fact. @) 30 e . (RETURN •• COND)). Note that (NTH n) is just a special case of (NTH x). followed by (LCL . Finds ( COND . . NTH generates nn error and the edit chain is not changed.then (COND . permits just alwuys conunand. @) is not equivalent to (F pattern N). both conunands are executed identically. For example. 9. @) followed by c~ pattern).. because this is the first COND encountered when ascending from the RETURN. 30-----------------------------------------------------------~--~-------------An infix command. at any depth. not any edit a pattirn. no special check is made for~ anumber. (LCL ... @ is cddr of the conunand. Note @ that (RETURN •• is a COND z 3) location specification..33 ..s the name of the command. it t. • .. a cond tlHlt Equivalent to (but more efficient than) (F pattern N). @) followed by\. (pattern . the user can write Note also that since @ corrunands of the form (corm .

performs (SETQ MARKLST (CDR MARKLST)).. makes the current edit chain become the value of ilQ!!!.... and . which marks the current chain for future reference. . i. .. and wishes to return to the first chain.3 Commands That Save and Restore The Edit Chain Several facilities are available for saving the current edit chain and lntor retrieving it: MARK. or all i. If the user wants to be able to return to either of two (or more) chains. Note that if the user has two chains marked. he must perform .34 ... 51----------------------------------------------------------------------------An atomic command..3.... 31 which returns to the last mark without destroying it. 9. have ... and then . MARKs have been performed... similar to . the second mark is then no longer accessible.. which removes the second mark.. which returns to the last mark and also erases it. makes the new edit chain be (CAR MARK LS T) Generates an error if marklst is NIL. However..e.. but also erases the MARK. pattern). he can use the following generalized MARK: (MARK atom) (\ atom) sets atom to the current edit chain. . ..9.. do not confuse . with the list command ( ..e. no beon erased.. . . MARK adds the current edit chain to the front of tho list marklst.

i f the user types P followed by 3 2 1 P.e. namely t. two chains are always s. etc. he may still be able to return to that chain with a single command by using \ or \P. 1.35 .e.g. to the COND. of\ and \Pare independent. and tHen F CAR. For example. LC. !NX. i. ~.e.. since this cou. unfind is set to the current edit chain by each command that makes a jump". ~~. Note that if the user had typed P followed by F CONO. \P restores it to its state as of the printing before that one. would be equivalent to O O back to the second P. et al and\ and \P themselves... take him back. he could use either \ or \P to return to the P.e. P. changed or PP. Generates an error if unfind=NIL. i. makes \ the edit chain be the value of unfind.ld always be returned to via the 33 t command. e. \P will return to the first P. 32 For example. the ac~~on. since If tho the last printing. Another \ would take him back to the CAR.. 33 Another \P would then tako him the user could use \P to flip back and forth between the two edit chains. i. i. if the user types F CONO. 9. all commands that involve a search.e.. .e. ~dit chain has not i. \ would. a2----------------------------------------------------------------------------Except that unfind is not reset when the current edit chain is the top level expression. ?. BELOW.aved. 11 big a command that usually performs more than a single ascont or descent. . o.. \P restores the edit chain to its state as of the last print operation.If the user did not prepare in advance for returning to a particular odi t chain. F..

36 .(S var . n. the editor uses rplaca and rplacd to physicallg change the structure it was given.e. ml 1 attaches e 1 ••• em at the end of the current expression. 9.m l 1 replaces the nth element in the current expression with e 1 ••• em. @) Sets Y!!: (using setq) to the current expression after performing (LC • @). (S FOO ·1 1) will set foo to the first element in the last element of the current expression.• em before th.m l 1 inserts e 1 •." 9 . see UNDO page 9. However. Th is ends the section on "Attention Changing Conunands.78. i. ( -n e 1 ••• em) n. As mentioned earlier: all structure modifi~ation done by the editor is de~tructive.4 Commands That Modify Structure The basic structure modification conunands in the editor are: (n) n ~ 1 deletes the corresponding element from the current expression. Edit chain is not changed. all structure modification is undooble. Thus (S FOO) will set foo to the current expression.e nth element in the current expression.

the conunand (1 (CAR FOO)) is not considered to have been "typed in" even though the LP command itself may have been typed in.structure u.!l elements. et al. i. e. or cor:u:tands given to the editor as arguments to editf. the remark. or in the case of the first three commands. delete or attach .g. Similarly. e.se the .e. (LP F FOO (1 (CAR FOO))).ie editor commands take as arguments a list of edit commnnds. replace. via (LIST 1 FOO). Or. EDITF(FOO F corm (N ··)) are not considered typecfiii":"' · 36 The user can circumvent thi's by using the I command. 9.s made here are val id for all .same low level editor functions. same list structure) might be used again. 36 34----------------------------------------------------------------------------However. the form of the command would be (I l FOO).62. and then deleting the second element.g. because of the possibility that the exact same command. delete the first element. insertion. deleting the first element when there is only one element would require changing a list to an atom (i.. if the list· contains fewor than .1 Note: Implementation of Structure Modification Commands Since all commands that insert. to NIL) which cannot be done. editv. 36 copies of the corresponding structure are used.All of the above commands generate errors if the current expression is not n list.structure changing commands. to look. (i. the command DELETE will work even i f there is only one element in the current expression. In addition. and gives this command to the editor. since deleting the first element must be done by replacing it with· the second element.e. which computes tho structure to be used.e. the (ABC) used for the replacement will not be !_g to foo. and attaching at the end of a list. unless tho command was typed in directly to the editor.34 9.4. since it will ascend to a point where it can do tho deletion. In the above example. For all replacement.g. 35 Sor. will cause an error i f there is only one element.at it another way. See page 9. commands originating from macros.37 . the conunand (1). which would replace the first element with the value of foo itself. In this case. Thus if a program constructs the command (1 (ABC)) e.

(A B C D). fie will still be (B C D) even though the current expression and foo are now (A C 0). (ABC 0). etc. and lli Thus i f f22 is !S to the current is·· cdr of · foo.e known in order to predict the effect that vario. after (1 X Y Z). as it would require being able to make two lists . then after (-1 X Y Z). (J).g to each other that were originally different. after executing (2) fie will. after executing tho command (1). Thus. expression which is (A B C 0). do to foo? Deletion of replacing the first it with patching around it. i.!!. fie be £. if foo were . i. be unchanged. . and pointers into that data structure are stored elsewhere. under the same initial conditions. · - 9. Thus if fie is cdr of the current expression. what will the commands (2). Think about it. For example.e.!!. However. (-2 X Y Z). i f the value of foo is cdr of the current expression.9 to fun if all subsequent operation~ were to update both fie and furn correctly.. f22 would be (X Y Z BC 0). foo will be ( B C D) (which is equal but not !S to fie).!: and cdr of the corresponding tail.The rest of this section is incl.In these cases. th• mechani~s actual of structure modification must b. Similarly.e.us commands may have on these outside pointers. the element in the second element current expression and deleting the is performod second element by by Deletion of any other element is done by patching around the previous tail is altered.g to the current expression.uded for applications wherein the editor is used to modify a data structure.. 37 Both replacement and insertion are accomplished by smashing both fl!. foo would be (XYZABCO). The N conunand is accomplished by smashing the last £S!r of the current i~---------------------------·--·----~-------~----------~--~~-----------------A general solution of the problem just isn't possible. performing (2) would have to make. if. it.. and furn is cddr of the current expression. foo were ~ to the current expression.38 . (2 X Y Z).

em) whichever is appropriate. i..4. B.s of the structure..2 In The A.. 9. In summary. followed. the edit operation will alway.e . after executing an N command... integer is used to indicate the operation. Commands (n e 1 . .. and the operation is deletion.39 or . the corresponding expressions would also appear at the end of foo.. 9. em>· For example. If all external pointers are to element. Equivalent to UP followed by (-2 .. the sign of the a result.expression a la !!. and the (n). re~lac~ments.the current expression.unand). the user cannot specify deletion or replacement of the nth element from the end of a list without first converting !l to the corresponding pos'i tive integer . to car of some node..ssi ty for a separate N cor..s have the sa'me effect on an external pointer as it does on the current expression. Similarly.• em) inserts e 1 .(hence .!2£• Thus i f foo were !51 to any tail of the currant expression. em) inserts e 1 em _!fter the current expression. element. the only situation in which an edit operation wi 11 not change an external pointer occurs when the external pointer is to a proper tail of tho data structure.e 1 .. we have: ( B e 1 •.£2. em) (N e 1 . (A e 1 ••.. Accordingly.• to cdr of some node in the structure. perform -1 and tben (B FOO).. there is no direct way As to express insertion after a particular. i.the nece. em) commands.e. to insert FOO before the last element in .. em Equivalent to U~ ~efore the current expression. or attachments are performed. or if onl~ itis~rtions. em)' and (·n e 1 .by (~1 e 1 •.

UP. This works in most cases. DELETE performs UP..40 leaving the current expression .replaces ( : e 1 . will is the be X Y))) However. and DELETE all work exactly the same as though the current expression were the first element in that tail.. if the current expression is (COND ((MEMS X Y)) (TY)) and the user performs F HEMB and then DELETE. em>· DELETE or(:) deletes the current expression. BK-UP-(2) ((MEMB method is example. 9. NIL (TY)) and the original expression would now be (COND NIL (TY)).e. I f the current expression is a tail. (2). the new current expression will be ••.. then 8. ()or NIL. if after performing new current expression contains only one element. i.. A.starts over and performs a BK. (PRINT X) (PRINT Y) (PRINTZ)). DELETE first tries to delete the current expression by performing an UP and then a ( 1). the and new tho the command ( 1) will not DELETE . followed by For (COND {(MEMB X Y)) (TY)). expression and then expression DELETE.e. i. BK will not work. the if current and the user performs -1... fOllowed by ( : NIL). However. (PRINTY) (PRINTZ)). em. For example. Equivalent to UP followed by (1 e 1 . em) the current expression by o 1 .. it replaces the higher expression by NIL.. Therefore. . work. used. . : . Thus would if the current expression were insert (PRINT X) before . current followed by UP. (B (PRINT X)) (PRINT Y). i f the next higher expression contains only one element. .. The rationale behind thi~ is that deleting (MEHB X Y) from ((MEMB X Y)) changes a list of one element to a list of no elements.. So in this case.

. aa-------------------·---------------------------------------------------u·---i .29.e. @ is cdr[member[BEFORE. . 40 Sudden termination of output followed by a blank line return indicates printing was aborted by control·E. em BEFORE .e. B. @)Similar to INSERT BEFORE except uses A instead of B. the location process does not continue as described on page 9. i. l«P (PROG (& & X) **COMMENT~= (SELECTQ ATM & NIL) (OR & &) (PRINl & T) (PRitH & T) (SETO X & J!!(lNSERT LABEL BEFORE PRIN1) lllP (PROG (& & X) **COMMENT** (SELECTQ ATM & NIL) (OR & &) LABEL (PRINl & T) ( 40 * Current edit chain is not changed. Noto that the user can always Write (LC CONO 3) if he intends the search to continue. em AFTER .command]] 39 except that if @ causes an error.the edit chain after the B was performod.. @) similar to INSERT BEFORE except uses for B.The following forms of the A. .. commands incorporate a and location specification: ( IIJSERT el . · 9. the search stops and the INSERT fails. (INSERT e 1 .\ will make the edit chain be that chain where the insertion was performed. For example if @=(COND 3) and the next CONO does not have a 3rd ele~ent.. (INSERT e 1 .41 . @) 38 Similar to (LC .@ )39 followed by (B e 1 ••• em). em FOR . but unfind is set to .

e. Current and (INSERT e 1 ••• em FOR .41. REPLACE. (C). HERE is also permitted. (DELETE . @).spondtng operation is performed here (on the current edit chain). X) X)). e. (REPLACE WITH (CAR X)) is equivalent to (: (CAR readability.. does a (LC .segment of the command betwoon REPLACE WITH. i. Same as followed by DELETE.g. (DELETE COND 3) Note: if 13' is it'll (i. it is perfectly legal to ascend to INSERT. 44 Unless the current expression is no longer a p~rt of the expression being edited. 42 See footnote on page 9. 9. 44 but unfind is set to the edit chain after the DELETE was performed. Example: (REPLACE CONO -1 WITH (T (RETURN L))) Same as REPLACE WITH.(REPLACE @ WITH e 1 . @) @) 43 edit chain is not changed. i f the current expression is . the tail. For example..41. For added BEFORE HERE) will before the current expression (but not change the edit chain). C) and the user performs (DELETE 1).. em> 41 Here @42 is the . i f the current expression is (CDR Y) and the user performs (REPLACE WITH (CAR X)). or DELETE 41----------------------------------------------------------------------------BY can be used for WITH. e. Note: @does not have to specify a location w1thtn the current ex~ression. (INSERT (PRINT insert (PRINT X). Example: (DELETE -1).g.. Similarly. 43 See footnote on page 9. the corre.42 .been cut off. empty). will have .e.

and not change the current edit chain. Similarly. B. 46 Not (INSERT F COND -1 (## ·1) AFTER 3).! does not change the current edit chain. and then DELETE. conunands. REPLACE.For example. In both cases. and insert a (RETURN) at its end. In this case. B. CHANGE. and DELETE commands after the location portion of the operation has been performed. if the user types F SETO. all make special checks in e 1 thru em for expressions of the form (-• . and : conunands. which inser~s four elements after the third element. variable~ whereas deletes just the variable X. (INSERT (RETURN) AFTER 9 PROG -1) will go to the top. REPLACE. (DELETE X) if X is a he will delete the entire SETO expression. he means before the SETO expression. 9.3 Form Oriented Editing and the Role of UP The UP that is performed before A. (and consequently INSERT.4. and in both cases is probably what the user intended.43 .£2. not 45----------------------------------------------------------------------------The execution of . the expression used for inserting or replacing is a of the current expression after executing~· a list of edit corrunands. 9. tho operation is performed on the corresponding form. or (DELETE SETO). (INSERT (## F CONO -1 -1) AFTER 3) 46 will make a copy of the last form in the last clause of the next cond. namely F. 45 copy For example. and insert it a. and : commands47 makes these operations form-oriented. find tho first PROG. and a copy of the last element in the current expression. -1. COND. simply For example. if the user types (INSERT (RETURN V) BEFORE SETO). The A.!!!.fter the third element of the current expression. corns). and CHANGE). 47 and therefore in INSERT.

and thus achieve the desired effect. and usually. 4a·---------------------------------------------------------------------------rhere is some ambiguity in (INSERT expr AFTER functionname). whether or not it is £i!. versus know those whether Thus. 60 Initially. B. In this case. he simply uses instead the pattern (FOO 0 -). he means before the atom FOO. following F FOO. however.Y --) be the same. 9. and : operations will operate with respect to the atom FOO. as INTERLISP attaches to atoms that appear as !:.. for example. appearing elsewhere in a list. Occasionally. a user may have a data structure in which no special significance or meaning is attached to the position of an atom in a list. the A. as simply an elaboration and further refinement Thus (INSERT (RETURN Y) BEFORE and SETQ) (INSERT {RETURN Y) BEFORE (SETQ Y ··)) perform the same operation49 and.!: of a list. With upfindflg=NIL.before the atom SETQ. 60 the user can suppress the implicit UP that follows searches for atoms. the user may not even a particular atom is at the head of a list or not. the user cannot write (REPLACE SETQ WITH SETQQ) meaning change the name of the function. The user must in these cases. as the user might mean make expr be the function's first argument.44 . and F (SETQ.!: of a list. By setting the variable upfindflg to NIL. when he writes (INSERT expression BEFORE FOO). If the user intends the operation to refer to the list which FOO heads. set to T. and (REPLACE SETQ 1 WITH SETQQ). In general. the current expression will be the atom FOO. 48 A consequent of this procedure is that a pattern of the form (SETO Y --) can be of the pattern vie~ed SETQ.(INSERT expr AFTER functioname 1). this is one of the motivations behind making the current expression after F SETQ. in fact. write .!. 49 assuming the next SETO is of the form (SETO Y ••). Similarly.

51 For example. then after XTR has finished. If the current expression after ( LCL • @) is a tail of a higher expression. its first element is used. then with V. in the first example. the current expression will be that list. 6i·--------------------------------------------------------------------------·See footnote on page 9. For example.4. or (XTR 2 2) will replace the cond by the print.45 . the current expression after the XTR would be (PRINTY). Thus.•• V). if the current expression is (CONO ((NULL X) (PRINTY))). replaces the original current expression with tho (XTR • @) expression that is current after performing (LCL • @). (XTR PRINT). if the current expression is (XTR Y) will replace the ~ (CONO ((NULL X) Y) (T Z)). If the extracted expression is a list.9. 9.4 Extract and Embed Extraction involves replacing the current expression with one of its subexpressions (from any depth). even though the current expression after performing (LCL Y) is .41.

If the current expression initial tu is· a tail. then (XTR PRINT) will replace the cond by the print.. Thus if the current expression is •. leaving (PRINT Y) as the current expression~ The extract command can also incorporate a location specification: Performs (LC • @2 )63 and then (XTR . will all produce the same result. extraction works exactly tho same as though the current expression were the first element in that tail. the now C\lrrent expression will be a tail whose first element is that non-list. but unfind is set to the edit chain after the XTR was performed. Current edit chain is not changed.41. in the second example. 53 See footnote on page 9. @1 ).If the extracted expression is not a list.. Y followed by whatever followed the CONO. (PRINT (CONO ((NULL X) Y) (T Z))) the current expression will be (EXTRACT 2 -1 FROM CONO).46 . (EXTRACT Y FROM 2). 9. (CONO ((NULL X) (PRINTY))) (RETURN Z)).. ~~----------------------------------------~-----------------------------------@1 is the segment between EXTRACT and FROM. Example: If the current expression is following (EXTRACT Y FROM COND). (EXTRACT Z -1 FROM Z) then (PRINT V). Thus. the current expression after the XTR would bo .

_ Examples: If the current expression is (PRINTY).47 ... Examples: If the current expression is (PRINT V). em• the MBD is interpreted as (MBD (e 1 ••• em R)). 54----------------------------------------------------------------------------as with subst. embedding replaces the current expression with one containing it as a subexpressio~~ MBD subs ti tutes 64 the current expression for a 11 instances of the atom R in e 1 . If the current expression is (PRINT V)..While extracting replaces the current expression by a subexpression. (MBD (COND ((NULL X) ~) ((NULL (CAR V)) R (GO LP)))) would replace (PRINT V) with (COND ((NULL X) (PRINTY)) ((NULL (CAR V)) (PRINTY) (GO LP))). If a does not appear in e 1 . if the (RETURN X) appeared in the cond clause (l (RETURN X)).. the clause would be (l (PRINTY) (AND FLG (RETURN X))). MBD leaves the edit chain so that the larger expression is the new current expression. tMBD RETURN) will replace it with (RETURN (PRINT Y)). a fresh copy is used for each substitution. after the MBD.e. 9. (MBD (PRINT Y) (AND FLG R)) would replace it with the two expressions (PRINT V) and (AND FLG (RETURN X)) i. then (MBO SETO X) will replace it with (SETQ X (PRINTY)).• em• and replaces the current expression with the result of that subs ti tu ti on. If the current expression is (RETURN X).

replace. WITH can be used for IN. or the name of a list . (MBD SETQ X) Thus if would replace (PRINT Y) with (SETQ X (PRINT Y)).5 The MOVE Command The MOVE command allows the user to specify ( 1) the expression to be moved.66 57 See footnote on page 9.. (EMBED COND 3 1 IN (OR * (NULL X))). @) 66 and then (MBD . ( 2) the place it is to be moved to.. x). insert it after. 9. where £2!!! is BEFORE. The embed command can also incorporate a location specification: (EMBED @ IN .48 . Example: (EMBED PRINT . the current (PRINTY) expression were (PRINT Z)). @ 1 is the segment b_etween MOVE and T. not changed. insert it before. (SURROUND NUMBERP WITH (AND • (fllNUSP X))). and (3) the operation to be performed there. x) 55 does (LC . (EMBED 3 Z IN RETURN).O. AFTER. e.g. 9. etc.4.g. e.IN SETQ X). and SURROUND can be used for EMBED. embedding works exactly the samo as though the current expression were the first element in that tail. but unfind is set ~o Edit chain is the edit chain after the MBD was performed.41.If the current expression tnttially is a tail.

For example. etc. 59 then goes back expr. Note that 4 was executed as of the original edit chain 0 and that the second element had not yet boon removed. a message is printed and an error is generated. (MOVE 2 TO AFTER 4) will make the new current expression be (A C D B). 9. performs @1). where X is contained inside of the second element. N.g . the MOVE command is an extremely versatile and powerful feature of the editor. call expr. (MOVE 2 TO AFTER X). MOVE chain. 58 (LC and obtains the current expression there (or its first eleraent. then goes back to performs (LC .command.41.• . e. 'f(? (PROG ((LL)) (EDLOC (COOR C)) (RETURN (CARL))) 3 TO : CAR) ~(MOVE (PROG ((LL)) (RETURN {EDLOC (COOR C)))) "' (SELECTQ OBJPR & &) (RETURN &) LP2 (COND & &)) "'(MOVE 2 TON 1) i:cp (SELECTQ OBJPR & & &) LP2 (COND & &)) 53----------------------------------------------------------------------------see footnote on page 9. 60 If @2 specifies a location inside of the expression to be moved.49 . which we wi 11 @2 the fol lowed ) to Edit chain is not changed. e.. 69 Setting an internal flag so expr is not copied. (com expr).g. i f the current expression is (A B C 0). origi1rnl @1 and by deletes Unfind is sot to edit chain after (com expr) was performed. 60 As the following examples taken from actual editing will show. edit i f it is a tail).

@1 • For example: t><p (TENEX) t><(MOVE t F APPLY TO N HERE) "'P (TENEX (APPLY & &)) "" 9.e.50 . thus creating the structure that will receive the expression being moved. "'P ((COR &) **COMMENT** (SETO CL&) (EDITSMASH Cl & &)) *MOVE 4 TON 0 (N (T)) -1] 1< p ((COR &) **COMMENT** (SETQ CL&)) •\ p *(T (EDITSMASH CL & &)) • If @2 is NIL. the user could have added the prog label NXT and moved the cond in one operation by performing (MOVE 4 TON( .*P (OR (EQ X LASTAIL) (NOT&) (AND & *(MOVE 4 TO AFTER (BELOW COND)) & &)) *P (OR (EQ X LASTAIL) (NOT &)) *\ p (AND & & (& &) 1< &) (T & & )) p ((NULL X) **COMMENT** (COND & &)) "'(-3 (GO NXT] •(MOVE 4 TO N (~ ll<P PROG)) ((NULL X) **COMMENT** (GO NXT)) "'\ p (PROG (&) ••COMMENT** (COND & & &) (CONO & & &) (COND & &)) •(INSERT NXT BEFORE -1) lllP (PROG (&) **COMMENT** (COND & & &) (CONO & & &) NXT (COND & &)) Note that in the last example. the current position specifies where the operation is to take place. via (N (T)). the user also performs a structure modification. in the next example. i.. unfind is set to where the expression that was moved was originally located. or (HERE). Similarly. the location where the expression was to be moved to. In this case. PROG) (N NXT)). in the course of specifying @2 .

6 The Cor. as opposed to modifying components thereof. and is the chain where the current expression was moved to.it p (PROG (& & & ATM IND VAL) (OR & &) PRINl & T) (SETO IND (OR & &) (PRIN1 & T) ( 61 *(MOVE ~ TO BEFORE HERE) *P (PROG (& & & ATM IND VAL) (OR & &) (OR & &) (PRINl & i>:p (T (PRINl C-EXP T)) "'(MOVE t BF PR!Nl TO N HERE) *P (T (PR!Nl C-EXP T) (PRINl & T)) "' Finally. Thus. the MOVE command allows the user to specify where tho @ current expression is to be moved to. no command can insert or remove just on~ parenthesis. unfind is set to where it was.. (SELECTQ OBJPR & &) LOOP (FRPLACA DFPRP &) (FRPLACD DFPRP & ) ( SELECTQ tc 9. 6i·---------------------------------------------------------------------------Sudden termination of output followed by a blank line indicates printing was aborted by control-E..4. there will always be the same number of left parentheses as right parentheses in any list structure.unands That "Move Parentheses" cor:unands presented in this section permit modification structure itself.51 . but this is suggestive of what actually happens. Of course. if 1 is NIL. "'P (SELECTQ OBJPR (&) (PROGN & &)) *(MOVE TO BEFORE LOOP) *P . 9. or pair of left and right parentheses. the edit chain is changed. of the list Their effect can be described as inserting or removing a single left or right parenthesis. since the parentheses are just a notational guide to the structure provided by print. In this case.

to find their element(s). modify it to be (BO n) n). all six commands use the generalized NTH command. !l and !!! are usually posit! ve or negative integers with the obvious interpretation. the NTH fails. 9. and (BI X Z) all specify the exact same opetation. e. (BI same as (BI n n) Example: If the current expression is (AB (COE) F G).52 then (BO 0) will . the mth element must be "to the right" of the nth element. All are undoable. modify it to be (ABC DEF G). (BI X ·1). then (BI 2 CONS). i. if the current expression is (LIST (CAR X) (SETO Y (CONS W Z))). 1. In other words.In all six commands. !l and !!! are used to specify an element of a list. is not contained in the nth tail. Removes both parentheses from the nth Generates an error if nth element is not a list. element. inserts a left parentheses before the nth (BI n m) element and after the mth element in the current Generates an error if the mth element expression. then (BI -2) will (A B ( C D E) ( F) G) • QOth gut. All six commands generate an error if the element is not found. Example: If the current· expressfon is (AB (CD E) F G). However. then (BI Z 4) will modify it to be (A (B (C DE) F) G).e. In practice. QOth 1n. usually of the current· expression. so that nth element means the first element of the tail found by performing (NTH n)..32. Examplei If the current expression is (AB (CD E) F G). page 9.

Another way of thinking about RI is to read it as "move the right parenthesis at the end of the nth element in to after its mth element. moving it to the end of the current expression. All element are moved elements inside following of the nth the nth element. inserts a left parenthesis before tho nth (LI n) element (and a matching right parenthesis at the end of the current expression). then (LI 2) will modify it to be (A (B (C 0 E) F G)). (RI n m) r_ight _!n. then (LO 3) will modify it to be (AB C OE). equivalent to (BI n ·1). Example: if the current expression is (A 8 (C 0 E) F G). i. removes the right parenthesis from the nth element.e. (RI 2 Z) will modify it to be (A (B C) 0 E F G). i'lll elements following the !!. Generates an error if nth element is not a list.left !n. 9. Generates an error if nth element is not a list.th element are deleted. (LO left 2ut. Example: If the current expression is (AB (C 0 E) F G). Example: If the current expression is (A (BC 0 E) F G). removes a left parenthesis from the nth n) element. inserts a right parenthesis after the mth element of the nth element. 11 (RO n) right £Ut. The rest of the nth element is brought up to the level of the current expression.53 .

if ( 3 THRU 5) means ( C THRU E) not (C THRU G). i. After THRU they set an internal editor flag informing the above 9.e. Another way of thinking about RO is to read it as "move the right parenthesis at the end of the uth element the current 9. and @2 is greater than @1 .. Same as THRU except last element not included. @1 • In other words. THRU arid . @1 ). If both @1 and @2 are numbers. REPLACE. they are intended to be used in . an (RI 1 -2) is performed.. does a (LC • (BI 1 @2 ).conjunction with EXTRACT. and then thereby grouping the segment into ll a single element. In this case. i f the current expression is (A (B (C D) (E) (F G H) I) J K).Example: If the current expression is (A B (C O E) F G). then @2 counts from the beginning of· the current expression. For example. the same as the current expression is (A B C D E F G).e. the corresponding BI command is CBI 1 @2 -@ 1+1). a segment of a list. and TO have operated. DELETE. the current expression will be ((C 0) (E) (F G H)). i. EMBED. and MOVE. (RO 3) will modify it to be (A B ( C O E F G)).4.. followed by an UP.~ TO and iHRU EXTRACT.. and HOVE can be made to operate on several contiguous elements. following (C THRU ~). and finally does a 1.TO are not very useful conunands by themselves. REPLACE. after the BI.7 out to the end of expression. EMBED.54 . DELETE. by using in their respective location specifications the TO or THRU command. making the final current expression be that element.

USER SHOULD NOTE THE VALUES OF SOURCEXPR J\tJD CURREIHFORM. and that the extra pair of parentheses should be removed when the operation is complete. CURRENTFORM IS THE LAST FORM IN SOURCEXPR WHICH WILL HAVE BEEN TRANSLATED.commands that the element they are operating on is actually a segment.) ~(DELETE (USER THRU CURR$)) =CURREtHFORM.55 (SETQ TEMP2 &) . Thus: i:tp (PROG (& & ATM IND VAL WORD) (PRINl & T) (PRIN1 & T) (SETQ IND "'"'COMMENT•• (SETQQ &) (SETO VAL &) "'(MOVE (3 THRU 4) TO BEFORE 7) •p (PROG (& & ATM IND VAL WORD) (SETQ IND&) (SETQ VAL&) (PRINl & T) "'"'COMMENT"'"' (PRIN1 & T) "'P ("' FAIL RETURr~ FROM EDITOR. "'P (* FAIL RETURN FROM EDITOR. CURRENTFORM IS LP (SELECTO & & & & NIL) (SETQ Y &) OUT (SETQ FLG &) (RETURN V)) •(MOVE (1 TO OUT) TON HERE] *P OUT (SETO FLG &) (RETURN Y) LP (SELECTQ & & & & NIL) (SETQ Y &)) i:>:pp [PROG (RF TEMP1 TEMP2) ccorw ((NOT (MEMS REMARG LISTING)) (SETO TEMPl (ASSOC REMARG NAMEOREMARKS)) (SETO TEMP2 (CADR TEMP1)) (GO SKIP)) (T ·~coMMENT•ft (SETQ TEMPI REMARG))) (NCONC1 LISTING REMARG) <corm ((NOT (SETQ TEMP2 (SASSOC R*COMMENT~• n(EXTRACT (SETO THRU CADR) FROM COND) "'P (PROG (RF TEMPI TEMP2) (SETO TEMP! &) (NCONCl LISTING REMARG) (COND & & *~COMMENT•• 9. AND IT CAUSED THE ERROR.

from @1 through the end of the list. Examples: 1< p (VALUE (RPLACA DEPRP &) (RPLACD &) (RPLACA VARSWORD &) (RETURN)) *(MOVE (2 TO) TON (~ PROG)) *(N (GO VAR)) *P (VALUE (GO VAR)) wp (T *~COMMENT** (COND &) *(-3 (GO REPLACE)) *(MOVE (COND TO) TO N ftp t ~ACOMMENT"" PROG (N (EDITSMASH CL & &) (COND &)) REPLACE)) (T *•COMMENT** (GO REPLACE)) "'\ p (PROG (&) **COMMENT** (COND & & &) (COND & & &) DELETE (COND & &) REPLACE (COND &) •~COMMENT** (EDITSMASH CL & &) (COND &)) lll: 62----------------------------------------------------------------------------Because XTR involves a location specification while A. 1. he could have used (XTR (SETO THRU CADR)) to perform the extraction.TO and THRU can also be used directly with XTR. both same as (@ 1 THRU -1). e. MBD do not. if the current expression had been the COND. B..56 . the user had first performed F COND. : • and. 62 Thus in the previous example.g. 9. e.

21-23.• 0)). D).s matches a tail of the · For example.4. NIL) D) to (A (BC ~ ( .. ( R ( • • • • C ) D) to (A ( B C) ( B {R c (D E)) (R ( •••• to (A ( B ( 0 E)) ( B D E )).. the tail is replaced by ~~ copy of) ~· . The R command operates in conjunction with the search mechanism of the editor.C) . 9. ·. {R C D) will change it to (A {B D) (B . e. and (B . D)."'PP [LAMBDA (CLAUSALA X) ( PROG (A D) (SETO A CLAUSALA) (corm LP ((IJULL A) (RETURN))) (SERCH X A) (RUMARK (CDR A)) (IJOTICECL (CAR A)) (SETO A (CDR A)) (GO LP] "'(EXTRACT (SERCH THRU NOT$) FROM PROG) =NOTICECL "'P (LAMBDA (CLAUSALA X) (SERCH X A) (RUMARK &) (NOTICECL &)) "'(EMBED (SERCH TO} IN (MAP CLAUSALA (FUNCTION (LAMBDA (A) •] *PP [LAMBDA (CLAUSALA X) (MAP CLAUSALA (FUNCTION (LAMBDA (A) (SERCH X A) (RUMARK (CDR A)) (NOTICECL (CAR AJ 9. in the current ( R x y) expression. structure..8 The R Command replaces all instances of ! by ::. each time .g.23·25. Each time ~matches an element of the structure.. and ! can employ any of the patterns on page 9. if the current expression is (A (BC) (B • C))._ 0) ) . The search proceeds as described on page 9. (R CAADR CADAR).. Gener~tes an error if there is not at least one instance.57 . the element is replaced by (a copy of) }'.

alt-modes appearing in for the characters matched by the corresponding alt-mode in·!• x stand For example. Note also that x will never match with a number. CADR·>CAAR. if an alt-mode in ! does not have a mate the characters matched by the 3 are effectively deleted. and (R 11 $0$ 11 11 SAS 11 ) equivalent. (R $0$ "SAS"). e.the replace them. ( R FOOS FIES) means for all atoms or strings that begin with FOO.g . (R SOS SAS) list and will change (LIST (CADR X) (CADDR Y)) to (LIST (CAAR X) (CAADR)). (R $/S S) alt-mocles• as well as For example. but replace the first D in every atom or string by A.e. it will be replaced by a string. . in characte~s. there is no similar operation for changing AND/OR to OR. i.e. Note that . (R $1 $)will delete the terminating i's from all literal atoms and strings.58 . can change For example. 64 The user ~ill be informed . 66 will l'. the (FIE FIEZ XF001). $ appearing in x refers to the entire ai·~--------------------------------------------------------------------------1r x matche~ a string. Note that it docs whether. If ! does not contain alt-modes. x x 9.If ! is an atom or string containing alt-modes. (R FOOS FIE$) (R $FOO$ $FIE$) would produce to Applied produce would (FIE FIEZ XFIE1). 64 Note that CADDR was not changed to CAAAR. feature can be used to delete or add $ ~· Similarly. (R $1 $2) will not change 11 to-12. he could perform (LP (R $0$ SAS)). will change AND/OR to e. 65 However. since the first $ in always co~responds to th~ first $ in !• the second $ in to the second in ~· etc. ! or ~ themselves are strings. (R SOS SAS) does not moan replace every D with A. If the user wanted to replace every 0 by A. (R i. also be a list containing to FOOl (CAR FOO). Similarly.e. replace tho characters 'FIE I .of all such alt-mode replacements by a message of tho form x->y.63 by 'FOO' (FOO F002 XF001). CR $1 (CAR$)) ANo. are i. not- matter (R $0$ $A$).g. 11 $0$ 11 $A$). FIE1 to (CAR FIE).

a la the F command. while R and RC only operate within the current expression. (SW 3 2) and (SW 2 3) are equivalent.e. (R (SETO X &) (PRINT$)) changes every (SETQ X &) to (PRINT (SETQ X &)). e. (SW 2 3) will modify it to be (LIST (CONS (CDR X) (CDR Y)) (CONS (CAR X) (CAR V))).59 it. 60 Since (R SxS Sy$) is a frequently used operatiori for replacing £haracters. switches the nth and mth elements of the current (SW nm) expression.expression matched by . i. ~~----------------------------~------------------------------------------------ If x is a pattern containing an alt-mode pattern somewhere within characters matched by the alt-modes are not available.g. For example. R1 and RC1 will continue searching. (R LONGATOM 1 $) changes LONGATOM to 1 LONGATOM. tho purposes any altsecond $ . the effect is the same as though x did not contain modes. if the current expression is (LIST (COl~S (CAR X) (CARY)) (CONS (CDR X) (CDR V))). 9. the will refer to the entire expression matched by (CAR FS).s. the first) instance of~ to~· (Rl x y) find the first instance of (RCl x y) ( R1 $x$ $y$) • ~ and replace it by ~· In addition.e. if the user types (R (CAR FSl (PRINTS)). tho following conunand is provided: (RC x equivalent to (R $x$ $y$) y) R and RC change all instances of ~ to ~· The commands Rl and RCl are available for changing just one. For example. until they find an instance of ~.. The relative order of n and m is not important. even if the search carries them beyond the current expression. and for tho of replacement. (i.

( p 0) same as P ( P m n) prints mth elem~nt of current expression as though printlevel were set to U· prints current expression as (P 0 n) though printlevcl were set to U· same as (P O 100) ? Both ( P m} and ( P m n) use the generalized NTH command to obtain corresponding element. PP causes all comments to be printed as °COMMENT 0 9.60 COND tho 3) (see Section .SW uses the generalized NTH command to find the nth and mth elements. prints mth element of current expression as though ( P m) printlevel were set to 2. ( P will work. PP prettyprints the current expression. Commands That Print. Thus in the previous 9. e. P prints the current expression as though printlevcl were set to 2. so that !!! does. (SW CAR CDR) would produce the same result.g.5 ~xample. a la the BI-BO commands. not have to be a number.

All record the current edit chain for. 67 prettyprints PP* current including expression. COND. it is defined as (RESETVAR ucoMMENTUflG Nll PP). Le . CLISP printing translations.terminal.. .14). All printing functions print to the . page 9. see page 9.61 . p.regardles·s of. the. P and ? print as l.y output file. . No printing function ever changes the edit chain. no' special treatment for LAMBDA.use by \P. PP* is equivalent to PP except that it first resets ucornment**flg to NIL ( soo Section 14).i prettyprints current :.. SETQ.. comments. 77. expression as a variAb1e. All use the readtable T. PPT prettyprints current expression.'ll!ICOMMENTtii:t only those comments that are (top levol) elements of the current expression. etc.35 . All can be aborted with control-E. 9. In fact.rimar. . or for CLISP.. PPV ·.i f any. I " .

.9. x 0 ) Example: (I 3 ( GETD (QUOTE FOO))) will replace the 3rd element of the current expression with the definition of !gE_. In both cases... lispx prints the result. 69 Example: E SREAK(FIE FUM) (FlE FUM) 111 E (FOO) 111 (FIE BROKEN) evaluates · (E X) ~. and prints the result on 'he terminal. (I c x 1 ·· . lispx applies it to the next input. i. lisp:< evaluates its argument. Otherwise.e.iching.6 Comr:iands That Evaluate only when typed in. performs eval[x]. used tw evalgt and ~ for processing terminal inputs. the user would probably type in a form for ·evaluation using the more convenient format of the (atomic) E command. 70 The I command sets an internal flag to indicate to the structure modification commands not to copy expreS$ion(s) when inserting. and search for E.62 . and ( E x T) commands are mainly intended for use by macros and subroutine calls to ·the editor. --------------------~~-------·--------·------------------------------~--------e~g. (E x T) ihe ( E x) same as (E x) but does not print. If nothing else is typed on the same line. 9. 68 causes the editor to call E lispx giving it the next input as argumont. 69 1 ispx is. and Sections 2 and 22. 70 (I N FOO (C(\R FIE)) will attach the 68 . (INSERT O BEFORE E) will treat E as a pattern. replacing. See above example.. . or att.

:. 71 Example: (I R (QUOTE X) (## (CONS •• Z))) expression by the first -~ replaces all X's in the current containing a Z. c is evaluated also.43).QUOTE ·1)) (T 1)) FOO). ed. . otherwise replaces the first element by the value. use. . . NOSPREAD function . Each xi is evaluat.. comn starting from t)le present edit chain. (I (COND ((NULL FLG) (. Als_o. ~. The following two commands provide· mo. is NIL.t be. and CHANGE make special checks for ## forms in the expressions used for inserting or replacing. 7i·-------------------------------------------------------~-------------------Recall that A.$e errors.. of the current expression.· flg. the. of foo. Its value is what the current expression would bo after executing the edit commands com 1 • .d to compute an.value of foo and £!. expression.!-).re ge_neral ways of computing .'it: command for execution.~qmn· -~~U.!: of the value of fie to the end of the current. atom.o before the firs. B. since it computes the command name· and its arguments separately.: . (I F= FOO T) will search for an expression !Ul to the value_ . (INSERT· (!II• 3 2)AFTER1) is equivalent to (I INSERT (COPY (## 3 2)) (QUOTE AFTER). 9..f foo. The current edit chain is never changed.. If £ is Example: no~ an. Thus. • The I command is not very convenient for computing' an' entire. -if inserts the value of fo.63 . I command canno.ed and· its value i"s executed as a command. atomic: command. REPLACE. INSERT. ' is -an NLAMBDA. o.t element. an error if any of corni thru Generutes . (not a· conunand).commands. and use a copy of ## form instead (see page 9.

COMSQ is mainly useful in conjunction with the COMS command.g.For example~ (COMS (COND (X (LIST 1 X)))) will replace the first element of tho current expression with the value of ~ if non•NIL. 9.and non-NIL. e. . For some editor cominf!.7 ·Commands That Test (IF ~enerates X) true. For examplo. otherwise do nothing. if eval[xJ ~alue causes of eval[x] is an error or eval[xJ=NIL.. He would then write (COM$ (CONS (QUOTE COMSQ) x)) wbere x computed the list of commands.e.s to branch on. suppose the user wishes to compute an entire list of commands for evaluation. (COMS (CONS (QUOTE COMSO) ( GETP FOO (QUOTE COMMANDS)))). see page 9.. IF will cause an error. natural way The IF command. an error unless the 1..e.theY use error. 72 ( COMSQ com 1 ~ •• ·· comn) executes com 1 . i.s one. examp~e. of accomplishing by equating NIL the same location specification ts (IPLUS (IF (NUMBERP (** result. an error condition in a location specification may simply mean "not thi. to error. ---··-----------------·--·~~-----~----------------------------~----------------72 because NIL u a command is a NOP. as opposed ~o c'omputing each command one at a time as does the COMS command. an 3)))).70 •. Thus.nds." Thus the location specification (IPLUS (E (OR (NUMBERP (II 3)) (ERROR!)) T)) specifies the first IPLUS whoso second argument provide$ a equiv~lent more is a number. For .64 . 9. as gru! uses NIL . try the next. the occurrence of an error has a well defined meaning.•• com0 .

(IF x coms 1 coms 2 ) If eval[x] causes an is true.e. (LP F PRINT (N T)) will attach a T at the end of every print (LP F PRINT (IF (## 3) NIL ((N T)))) will attach a T at the end of each print expression which does not already have a second argument. repeatedly executes (LP . The IF could also be written as (IF (COOR (~-)) NIL ((N T))). a list of corrunands. For example.65 . LP prints n OCCURRENCES. execute coms 1 . 73----------------------------------------------------------------------------Thus IF is equivalent to (COMS (CONS (QUOTE COMSQ) (COND ((CAR (NLSETQ (EVAL X))) (OMSl) ( T COMS2 ) )) ) . 9. expression.The IF command can also be used to select between two alternate lists of commands for execution. 74 i. corns) corns. the form (## 3) will cause an error if the edit command 3 causes an error. 73 For e:<ample. error execute coms 1 . otherwise generate an error. thereby selecting ((N T)) as the list of commands to be executed. exocuto the current coms 2 . IF can also be written as: if (IF x coms 1 ) eval[x] is true. or is equal to if oval[x] NIL. 74 When an error occurs. until an error occurs. the command (IF (REAOP T) NIL (P)) will print expression provided the input buffer is empty.

.e. 75 Since the edit chain is left as of the last successful completion of the loop. both LP and LPQ terminate when the number of iterations reaches ma:doop. If nono of the command lists execute without errors.g. Generates an error i f there aren't any instances of the expression(s).Q. x) ~ is a list of patterns.66 . ~~---------------------------------------------~-------------------~----------maxloop can also be set to NIL.!:!l!· (LPQ . i. all instances of the SHOW does a LPQ printing indicated expression(s). ORR restores the edit chain to its original value. a list of corrunands. corns) same as LP but does not print the message n OCCURRENCES. (ORR coms 1 ••. ORR is finished. e. the user can simply continue the LP command with REDO (Section 22). (SHOW . In order to prevent non-terminating loops. and continues by executing coms 2 ~ etc. initially set to 30. of times £. 9. comsn) ORR begins by executing coms 1 . (EXAM • x) like SHOW except calls the (via the TTY: editor recursively command described on page 9. (SHOW FOO (SETQ FIE&)) Will print all F00 1 s and all (SETQ FIE &) 's.70) on each instance of the indicated espression( s) so that the user can examine and/or change them.~ was The edit chain is left as of the last complete successful execution of £2. If no error occurs. which is equivalent to i~finity. Otherwise.where n is the number successfully executed.

(ORR (NX) ( !NX) NIL) will perform a NX. IF. i. Macros can use commands defined by macros 76--~1~--~. if possible. the above example could be written as (OR NX !NX NIL). such as ORR.. corns) For£ an atom. and UP. If a macro is redefined.--~--. if possible. DELETE could be written as (ORR (UP (1)) (BK UP (2)) (UP(: NIL))). The macro feature permits the user to define new commands and thereby expand the editor's repertoire.-~~~f~~~i. ORR generates an error. making the last 'argument' to ORR be NIL will insure that the ORR never causes an error.-·.e. M defines£ as an atomic command. Thus.. its new definition replaces its old.~ci--i.~~~~~~ successfully. 76 For example. are most often used in conjunction with edit macros. the editor's repertoire can be expanded. 77 Macros are defined by using the M corrunand.67 . (M BP BK UP P) will define BP as an atomic command which does three things..e. 77 78 However built in corrunands always take precedence over macros. a BK.. 78 Executing £ is then the same as executing the list of corrunands ££!!!!· For example. 9... otherwise a !NX. the edit chain is left as of the completion of the first command list which executes without an error. 9.~~. otherwise do nothing.--i~~~i~--~~~--~~ii--. Otherwise.13 Macros Many of the more sophisticated branching commands in the editor. and a P. but not redefined. Similarly. Any other atom is treated as (atom).i~~~~--. CM c . 1. etc.the ORR "drops off the end".

and ZZZ by (M ZZZ ·1 •1 Z) or (H ZZZ ·1 ZZ). as with spread vs. (c e 1 Executing substituting For example. defines .as well as built in commands in their definitions.e . the command. 9. a For example.30. for executing ~· command 2ND. nospread functions. corns) . Macros can also define list commands.. i.•• en) e1 ~· for is then performed by arg 1 . e 1 . If the •argument list' atomic. defined by (M Z -1 (IF (READP T) NIL (P))). (BP 3) would perform (BK 3).• throughout be defined performed by of tho cdr and ££!!!!· as a then macro by . X)))). (M (2ND) X (ORR ((LC. p. as indicated by its argument list. ( M ( c) ( arg 1 • • • argn) . The form given above specified a macro with a fixed number of arguments.. Z does a -1. i. followed by an UP.£• arg both atoms. M defines f an atom.68 arg can en) is en)' i. A list comnand can be defined via a macro so as to take a fixed or indefinite number of 'arguments'. commands that take arguments. followed by a P.list corrunand. we could define a more general BP by (M (BP) (N) (BK N) UP P). suppose Z is we Now can and define then if zz by CM ZZ -1 Z). coms) f Executing (c substituting throughout as a . is the command takes an indefinite number of arguments.e.£ as a list corrunand. nothing has been typed. Thus. page (el 9. X) (LC. 79 (M (c) arg . ''.e.' en and then executing ££!!!!· For example.

and a P. wo would have to be careful to make up unique names for dummy variables used in edit macros. but this would still use one free variable. using SW may have undesirable side effects. Note also that once . Thus (INSERT •• BEFORE BP) would not search for BP.£ is defined as an atomic command via a macro definition. Tho corresponding also holds true for list commands. two entirely different definitions can be used. an atomic command. Furthermore. 80----------------------------------------------------------------------------A more elegant definition would be: (NM) (NTH N) MARK 0 (NTH H) (S FIE 1) (I 1 (U °" 1)) °"°" (I 1 FIE)). 'built in' commands as well as conunands atomic definitions and list definitions are complctelv In other words. £can be used as the name of either or a list command. it will not be searched for when used in a location specification. but instead perform a BK. the user will want to employ the S command in a macro to save some temporary result. and then do the insert ion. unless it is preceded by an F. (M (SW) 9. Occasionally. and the existence of a list definition for £ in no way affects the treatment of £ when it appears as an atom. and UP. The BIND command solves both problems. which is bothersome. In particular.Note that for all editor commands. For example. especially when the editor was called from deep in a computation. or both. the existence of an atomic definition for £ in no way affects the treatment of £ when it appears as £fil: of a list command. it would be impossible to define a command that called itself recursively while setting free variables.69 . the SW command could be defined as: (M (SW) (NH) (NTH N) (S FOO 1) HARK 0 (NTH H) (S FIE 1) (I 1 FOO) ~~ (I 1 FIE)) 80 Since this version of SW sets foo and fie. independent. In the latter case. defined by macros.

81 Thus we could now write SW safely as: (M (SW (N M) (BIND (NTH N) (S #1 1) MARK 0 (NTH M) (S #2 1) (I 1 #1) ~~ (I 1 #2)))). lii2. (initialized to NIL). 12. corns) binds three dummy variables 1111. The user can thon type in commands. User macros are stored on a list usermacros. The TTY: command is extremely useful. 9. and editcoms function which executes a list of commands. is available for dumping all or selected user macros. !!13. TTY: calls the editor recursively. is always a NOP. and 13 each time it is invoked. Thus extra right parentheses or square brackets at tho ends of commands are ignored. 9 IHL Niscellaneous Commands unless preceded by F or BF. and have them executed. (see OK and STOP below). and that BIND can be used recursively.(BIND . It enables the user to set up a comp lox operation. The prettydef command USERMACROS (Section 14).70 is an internal editor . it will rebind 11. The TTY: command is completed when the user exits from the lower editor. 9. and then executes the edit commands ~· Note that these bindings nro only in effect while the commands are being executed. and perform interactive attention-changing corrunands part way through si·---------------------a·----------------------------------------------------BlfJD is implemented by (PROG (#1 #2 #3) (EDITCOMS (CDR COM))) whore com corresponds to the BIND command.

-· .. as.... the user must exit from the editor via a command.if the user is executing (MOVE 3 TO AFTER COND TTY: ) ....~ ." In effect...... TTY: says "I'll tell you what you should do when you got there..-..it...-...~..-.. it will perform the necessary 'wrapup' to insure that the changes made while editing will be undoable (see Section 22). STOP is preferred even if the user is editin~ at the evalgt level..-... these will modify the structure in both editors... since it is the same structure.. the MOVE command will then 82 . Since all of the commands in the editor are errorset protected. i f the user performs any structure modification commands while under a TTY: command. use in conjunction with TTY: Mainly for conunands that the user wants to abort... 9.......-• .... Thus he can verify for himsolf that the correct location has been found. 82 When the TTY: command finishes.-. . Until the user exits from tho lower editor.." The TTY: command operates by printing TTY: and then calling the editor. and he exits from the lower editor with an 'OK... For example..-... Of course.71 .. OK exits from the editor STOP exits from the editor with an error. Tho initial edit chain in the lower editor is the one that existed in the highor editor at the time the TTY: command was entered.. 83 STOP provides a way of distinguishing between a successful and unsuccessful (from the user's standpoint) editing session... For example the command (MOVE 3 TO AFTER COND 3 P TTY:) allows the user to interact. within the MOVE command.. 83 Or by typing a control~D.-. in effect. any attention changing commands he executes only affect the lowor editor's edit chain. or complete the specification "by hand...-..... the lower editor's edit chain becomes the edit chain or the higher editor.

e . 9. it restores the mark . SAVE exits from the editor and saves the 'state of the edit 1 on the property list of the function variable being edited under or property the EDIT-SAVE. "continued. the higher editor's edit chain wi 11 not be changed by the TTY: command.• the editing is edit chain. . effectively mark list.. he must make the TTY: command generate an error. If the editor is called again on tho same structure. For example: *P (NULL X) *F COND P (COND (& &) (T &)) l'ISAVE FOO . 84 Whenever the editor is entered.complete its operation.72 In this cas•." the i. value of unfind and undolst are restored. If the user wants to abort the MOVE command. it checks to see if it is editing the same expression as the last one edited. an exit from the editor via OK always saves the state of the edit of that call to the editor. He does this by exiting from tho In this case. EDITF( FOO) EDIT *P (CONO (& &) (T &)) •\ p (NULL X) Ill SAVE is necessary only if the user is editing many different expressions. lower editor with a STOP command.

. the undolst. as a result of the history feature (section 22). regardless of how many othor expressions may have been edited in th~ meantime~ 86----------------------------------------------------------------------------Namely. 9. if the editor is called on the same expression within a certain number of lispx inputs. 85 tho state of the edit of that expression is restored. EDITF(FOO) EDIT "'P (LAMBDA (X) (PROG & & LP & & & &)) l'I p {COND & &) ~OK FOO any number of lispx inputs except for calls to the editor .. the size of the history list. ED ITF (FOO) EDIT l'IP (LAMBDA (X) (PROG & & LP & & & &)) ~\ p (COND & &) ~ Furthermore. For example: .list.73 . initially but it can be increased 3~~ by the user.. and sets unfind to be the edit chain as of the previous exit from the editor..

. less than 30 lispx inputs.. or ( 3) It was ended with a SAVE coliU'iland. as it UP followod by raises to upper- case the current expression.e. 86----------------------------------------------------------------------------Since saving takes place at exit time. i. including editing .. EOITF (FOO) EDIT "\ p (COND (& &) (& &) (&) (T &)) . including undoing changes from a previous editing session.. intervening calls that were abortod via control-D or exited via STOP will not affect the this last session. or i f a ta 11. tho first element of the current expression. 9.For example: . * RAISE is an edit (I 1 (U-CASE macro defined (## 1))). LOWER Similar to RAISE.. Thus the user can always continue editing. except uses 1-case.. if other expressions have been edited since that session: 86 or (1) No (2) That session was 'sufficiently' recent..ED ITF (FOO) EOIT Ill "P (CONO (& &) (& &) (&) (T &)) *OK FOO ..74 e~itor's memory of .

IEOIT p (T H I S % I S % A % L 0 G N % S T R I N G) *(SW G N) •OK "THIS IS A LONG STRING" 87 REPACK operates by calling the editor recursively on unpack of the current 9. except performs (I Rx (L- CASE x)). and then lowers all but the first character. A'ote: R.e.s already in that state. i. For example: "THIS IS A LOGN STRING") REPACK l'. and CAI' are all 1VOl'. if the corresponding atom or ..USE. the first character is loft capitalized.string i. REPACK ~ is typed in in upper case. Note in both (RAISE x) and (LOWER x). Permits the 'editing' of an atom or string.1£R.e. changes every lower-case x to upper-case in the current expression. (LOWER similar x) to RAISE.s (RAISE to equivalent x) (IR (L-CASE x) x).CAP First does a RAISE. l01>. i.75 .

CALL FACT RECURSIVELY) would insert (* CALL FACT RECURSIVELY) bef ote the itimes expression.g. was not being used. does not change the edit chain. REPACK. However.g. if example.i:. Le. e. and hence its valu. . (REPACK @) does @) (LC followed by e. via OK as opposed to STOP. 1 safe 1 place to insert tho in a cond clause. tho list of atoms is made into a single at6m or string. 9.' The new atom or string is always printed.76 . e.e. If the lowor editor is exited successfully. Statement.g.expression.. i f the cond was itself a fil:Q.BB . For expression is (FACT (SUB1 N)) in [COND (( ZEROP N) 1) (T (ITIMES N (FACT (SUB! N] (.O statement. but unfind is set to where the comment was actually inserted. which replaces the atom or string being 'repacked. is chain looking for a comment. point. Jome is used to join two neighboring COND's together. or if it is a list. the comment could be (and would be) inserted ·after the itimes expression. on unpack of its first element. (REPACK THI SS). ( : • x) the text of a comment. etc. the comment would then be (incorrectly) returned as the value of the cond. 1 and inserts (ft possible. (COND clause 1 clause 2 ) followed by ii--------------------------------------------·--------------~----------------1f inserted after the i times. if : ascends the edit the o otherwise current after a prog after that X) before.

JO INC does an (F COND T) first so that you don't have to be at the first CONO.s specifies tho last clause in the first COND. meaning split after the clnuso c9ntaining RETU~N. SPLITC also does an (F COND T) first. (RESETVAR var form . Uses generalized NTH conunand. corns) executes form. 77 .. ow Dwimifies current expression. 9.g. e. ( SPLITC x) splits one COND into two. effectively calls the function resetvar (Sectio~ 5). See Section 17 and 23. (SPLITC 3) splits (COND clause 1 clause 2 clause 3 clause 4 ) (COND clause 1 clause 2 ) into (COND clause 3 clause 4 ). CL Clispifies current expression.becomos (COND clause 3 clause 4 ) (COND clause 1 clause 2 clause 3 clause 4 ).the user can say (SPLITC RETURN).g. ~ while i l l is reset to the value of and then restores ill• i.e.s does not have to be a number. so that . See Section 23. . e.

90 If there are no conunands to undo.78 . UNDO types NOTHING SAVED. he can undo an UNDO command. See discussion of UNDO in Section 22. undoing an S (Note cor:u:iand will undo the set. /NCONC would automatically be substituted for NCONC as described in Section 22.e. and the second will undo the INSERT. e. However. In this case.g. e. and then an MBD. undoes UNDO the modification last.. e. the user can also specify precisely which commands he wants undone by identifying tho corresponding entry on the history list as described in Section 22.10 Each command that causes structure modification automatically adds an ontry to the front of undolst that contains the information required to restore all pointers that were changed by that command.e. they ~lso add an entry to undolst. E. performed during this this call to the editor. structure yet boon that corrunand.) 9.. its name is printed a la UNDO. Similarly. or •S command will al so undo the s 1do effects of the evaluation(s). by typing UNDO UNDO. ! UNDO prints NOTHING SAVED. command most that recent. As each command is undone. HBO UNDONE. if the user performs an INSERT. UNDO and !UNDO entries are skipped by UNDO. 89 and prints the name of e~g. !UfWO undoes all modifications editing session. i. However. The edit chain is then c~actlu what it was before the 'undone' conunand had beon performed. i. or undo a command other than that most recently performed. or undo a !UNDO corrunand. that i f the I command was typed directly to the editor.g. undoing (I 3 (/NCONC FOO FIE)) will not only restore the 3rd element but also restore FOO. has not undone.g. i~----------------------------------------------------------------------------Since UNDO and !UNDO cause structure modification.U~DO 9. If there is nothing to be undone. the first UNDO will undo the MBD. 90 Undoing an event containing an I.

insorting a This undo-block will terminate the operation of a !UNDO. Thus.ed state. if the user enters the editor continuing a session. and will similarly prevent an UNDO corrunand from operating on cor:unands executed in the previous session. 9. i. Similarly. and then undo all of them with a single !UNDO command. i f the user executes several commands and then undoos them allf another UNDO or !UNDO will also cause BLOCKED to be typed. types NOT BLOCKED. thereby confining its effect to tho current session. Note that TEST together with !UNDO provide a 'tentative' mode for editing. called an undo-block. the user can perform a number of changes. the undo information of the previous session is protected by special blip.W'henever the user continues an editing session as described on pago 9. UNBLOCK removes an undo-block. executes an UNDO or !UNDO. on the front of undolst.e. 72-74. TEST adds an undo-block at the front of undolst.e. i.79 . the editor will and immedia to ly BLOCKED type instead of MOTHirJG SAVED. block. If if executed at UNDO or !UNDO a noncould operate.

to determine. ~]----------------------------------------------------------------------------- Since editdefault is part of the edit block.9. 94 the correct conunand name is rplacaed into the corrunand. The prettydef conunand USERHACROS (Section 14). edi tdefaul t calls the function edi tuserfn giving it the cor:unand as an argument. the user will be asked to approve th~ spelling correction. 93 lf spelling correction is successful. tho user can accomplish this via . the procedure followed is a little more elaborate. i. Otherwise. depending on whether it is an atomic or 1 ist cor. However. edituserfn. the editor calls an internal function. an error is to HBO. a list of all !1st edit commands./hen a macro is defined via the H conunand. if the command was not typed . (LP F PRINT (HBBD ANO (NULL FLG))). 91 If a location specification is being executed. if the user types spellinsi continues by executing the command. is not 'built in' or defined as a macro.11 Editdefault Whenever a command is not recognized.e. If the command is a list. what action to take.. 94 Throughout this discussion. If spelling generated~ If the command is atomic. an internal flag informs editdefault to treat the conunand as though it had been preceded by an F. · 92 unless dwimflg=NIL. If edi tuserfn returns a non-NIL value. the error correction procedure described below is performed. the user cannot advise or redefine it as a means of augmenting or extending the editor. editdefault. only one correction will be necessary to change HBBO correction is not successful. is aware of this.80 . the command name is added to edi tcomsa or edi tcomsl.in directly. its value is interpreted as a single command and executed. See Section 17. 93 \.unand. 9. and the editor In other words. and provides for restoring editcomsa and editcomsl. an attempt is made to perform spelling correction on ~ of the command 92 using editcomsl. See Section 17 for discussion of spelling correction. If the value of the variable erJi tuserfn is T.

i.g. i:rp (COND MOVE (& &) (T &)) ti MOVE? iii If the command is on editcomsl. e. treat the on t iro line as a single list command.g. e. Thus the line can bo ter~inated space. an error is generated. not execute it.g. editdefnult does not get thiS far. BK). 95----------------------------------------------------------------------------The line is read using readline (Section 14). and not typed in directly. (MOVE TO AFTER CONO (XTR 3)) will work. a member of editcomsl. e. for exa~ple. ·(LP F (COND (T &)) XTR 2 2). a. 95 Thus.. the procedure is similar.9 6 2) If the command was typed in and the first character in the command is an 8.e. t:tp ( COND (& &) (T &)) i:ixrn 3 2J nMOVE TO AFTER LP i:c If the command is on the list editcomsl but no additional input is on tho terminal line. with the rest of the command stream at that level being treated as "the terminal line". the user may omit parenthosos for any list command typed in at the top level (provided the command is not also an atomic command.81 . and there is addition al input on the same terminal line. However. 96 by a square bracket.g. it appears as one of the commands in a LP command.1) If the command is one of the list commands. NX. or by a carriage return not preceded by a Note that if the command is being executed in location context. (MOVE' TO AFTER CONO XTR 3) will s'earch for XTR. e.g. 9.

assume that the user intended two commands. *BREAK( FOO) =E BREAK (FOO) • 4) If the last character in the command is P.~.g. *P ( COND ( & & ) ( T & )) *OP =O p (SETQ X (COND & &)) 5) Attempt spelling correction using editcomsa. e.~:-------·------·---------------------------------- 9.. g7·-..g. is the name of a function. 6) Otherwise.. if there is addition al input on the same line. or command stream.-.-~~-.g...g. and and the rest of the line as the arguments to the conunand. and is followed by NIL or a list i l l of which is not an edit command.-9:.. e. 97 execute the corrected command. e. spelling correct using editcomsl as a spelling list.82 . assume the user forgot to type E and means to apply the function to its arguments.treat the 8 as a mistyped left parenthesis. and the first n-1 characters comprise a number. and perform the indicated computation.~~~~~~. e. *P ( CONO ( & & ) ( T & )) *8-2 (Y (RETURN Z))) =(-2 *P ( COND ( V 8c) ( & 3) & ) (T & ) ) If the command was typed in. type =E and the function name. and i f successfui.

Editor Functions edite[expr.83 tho TTY:· . 99 an' optional list of interactive editing. 9.. For In this case. editl 98 i.tiMBBD SETO )( =MBD SI 7) 9:12 Otherwise. Its first argumont is tho edit chain. T lOO l f mess is not NIL. For is equivalent to· (E (SETO L (LAST L)) T).coms:atm] edits· expression:: an Its value is tho element of editl[list[expr]. the usor should only manipulate or examine l directly as a last resort. ga-------------------u-----------~------------------D-------------------------- edit-ell.coms. SAVE command. editl types it instead of EDIT. generate an error. co171r.eneratos is not a list. and thon with caution. Exit occurs only via an OK. for input from terminai. and so can be examined or set by edit commands.! is a specvar.1and is essentially (SETQ L (EDITL l NIL NIL (QUOT.ime editl is exited.atm. ·corns is NIL. 99 . edi tl types EDIT and.s the editor.mess] mr lllst C. not edit-one. and its value is an edit chain.coms. 100 All input is done with editrdtbl as a ~ or "' read table. For example. then waits commands.atm). an error if editl[l. - example.£ TTY:))). However. STOP. namely the value of corns is ! at th0e t.

e. function.coms. editf[x~ m~rklst.! is cdr[x]. no message is typed. when editing arbitrary expressions via edi te or edi tl directly.cdr[x] For the rest of the discussion.mess.If ~ member is not NIL.editlflg) 101 like edi tl except does not rebind · or initialize the editor's various state variables. the edited. If ed. atom whose property list is being The property list of atm is used by the SAVE conunand for saving the state of the edit. on calls from editv.il!!J is optional.!!!!=NIL. etc. car[x] is the riame of the optional list of corrunands. cor:is is treated as a corrunand and If an error occurs in the execution of one of the com.itl returns !· On calls from editf.£2!!!. all conunands execute successfully. and . i. unfind. it is tho name of the function being edited.o. no error message is printed.Jands. and ocli tl exits with an error. i. nospread function for editing a function. the effect is the same as though a STOP corrunand had been executed. the rest of the corrunands are ignored. nlambda. Thus SAVE will not save anything i f !!.84 an . the current value of .r. and calls from editp. fn is car[x]. undolst. the name of the variable. 9. editlO{l. and each of executed. such as lastail.

the· function . If edite returns (i.85 . tho · user may have called the editor to examine· the advice fo~ a compiled. and some changes were made. editf prints PROP. i f fn is an expr by virtue or its being broken or advised. + ( 3) i f fn is neither an expr nor has an EXPR property. an expr. approval. the expr definition + 9. but has an EXPR property. and then putd[fn:value-of-editeJ.coms.fn]]. performs unsavedef[fnJ.fn].The value of editf is fn. --). a warning message is printed to alert th~ (lb) the original definition is not an expr. fn is putd[fn. + affect the destructive). e. edite(getp[fn:EXPRJ. (1) In the most common case. and there is no EXPR property. then a warning message is printed. prints UNSAVED. function. and (la) the original + definition is given to edite to be edited (since any changos thoro + will aro + user + that he must first position himself correctly -before he can begin + typing commands such as (-3 --). only with the + and • is not an expr. is + the brolten/adVisocl also definition + also original an expr. if editing is not terminated by a STOP). since • is expr~ and there is an unbroken/unadvised (latter EXP~ propo~ty. and editf simply performs However. and the edit proceeds.g.e. (N. then definition because all changes However.edite[getd[fn].coms. and + the + cditf + does + performs the user may really want to edit user's • advice) proceed as in (2) If fn • + (le) the original definition is n6t an then + (2). etc. and the file package + (see section 14) 'knows' which file fn is contained in.

(soo + section + functions in the block to be loaded at the same time. If fn=IHL. See Section 17.e. 104 and i f successful. e. of tho but i t does have a definition. don't do it. 103 + ( 4) If fn 18)..86 . and then type EDIT. the editor will assume he meant foo. ask about loading the bTock. the first of \~hich (i. 104 Unless dwimfl9=NIL. but its top level valuo is a list. + (5) If fn i. editf attempts spelling correction using the spelling list userwords. 103 The editor's behaviour in case (3) is controlled by the valuo of edi tloadfnsflg. i f fn is a member of a block.+ of fn is automatically loaded (using loadfns) onto its property list.s neither defined. by defineg. the user will be asked whether he wishes the rest is neither an expr nor has an EXPR property. ( 6) If fn is neither a function. prints =EDITV. - 9. editf generates an fn NOT EDITABLE error. which is a dotted pair of two flags. Spelling correction is performed using the function misspelled?. this operation is extremely fast. if fn has a non-NIL property list. 11 a value of T means 11 don 1 t ask. 102 In addition. Otherwise. goos back to (1). editf[ ]. calls editp and returns. editf. nor has an EXPR property. nor a top lovo l value that is a list. and tho second the loading of the block. and + proceed to (2) above. nor a non-NIL property list. type =FOO. Thus i f the user defines foo and then types.g. essentially requiring only the time to perform the READ to obtain the actual definition. editf generates an fn NOT EDITABLE error. calls edi tv and returns. A value of NIL for either flag moans "load but ask first. + + + + + + + + + + 102---------------------------------------------------------------------------Because of the existence of the file map (see section 14). edit f prints =EDITP. just do it 11 and anything else means 11 don't ask.!:. meaning load the function without asking. prettyprint etc. editf assumes the user meant to call editv." The initial value of editloadfnsflq is (T). Similarly. nor has an EXPR property. misspelled? returns the last •word' referenced. of edi tloadfnsflg) controls the loading of the function. £!!.

87 so + + + + . In this case. 9. i. atomic. and adds fn to the appropriate spelling lists. 105 Addspell 'notices' fn. e. and the user performs (EDITV FOO). car[editvx] is a variable name. does not exit by calling editv or editp.age to mark the function as being changed. editf calls the function addspell after editing has been completed. no spelling correction will occur. 107 Then editv will call edite on the valuo of car[editvx) (or the corrected spelling thereof). Thus.ipleted.e. if the value of foo is NIL. it has a value.If editf ultimately succeeds in finding a function to edit. for most applications. as in EDITV(FOO). nospread function. If car[editvx] is a list.user meant to call edi_!. Misspelled? is also called i f car[editvx) is NIL. the value of cditv is T. Otherwise.g. EDITV((CDR (ASSOC (QUOTE FOO) DICTIONARY)))).e. calls edi tf and returns.:1lls the file pack. editv at tempts spelling correction using the list userwords. user•~ system.e. 106 Even though the call to newfile? does not occur until after the editing is cor. 107 Unless dwimflg=fHL. i. for editing yalues. as described in. If any changes were made. similar to cditf. sets lastword to fn.106 editv[editvx) nlambda.f. nevertheless the function is effectively marked as changed as soon as the fir. i.also c. so that even 1f the edit is aborted via control-D. However. i. that EDITV() will edit lastword. since foo is the name of a variable in the. and .. prints =EDITF. If the value of this variable is NOBIND.s performed. editf . assumes the .e. cdr[editvx] is an optional list of commands. soction 14.st change i.if so. newfile? will still be called. it is evaluated and its value given to edite. editv checks to see if it is the name of a function. car[editvx] specifies the value.

property list Then editE cal ls of spelling thereof). car[x]. Note that this may still result in an error if the value of foo is not a list. The value of editv is the name of the variable whose value was edited. editp attempts spelling correction using userwords. editv also calls the file package to mark the variable as being changed. car[x] is evaluated to obtain a list of functions. edite will generate an error. editfns[x] nlambda. editp rplacd 1 s car[x) with the value returned. editp[x] n lambda. of each function.88 . If the user performs (EDITV FOOO).However. and foo is on the user's spelling list. same nospread function. edit fns mnps prints the name. editing operations on used to perform tho several functions. similar· to eel it f for editing J. down the list of functions. Then ~ will be called on the value of foo. editv sets the variable to the value returned. If the property list of car[x] is NIL. where the value of fooo is NOBIND. When (if) edi te returns. The value of editp is the atom whose property list was edited. the spelling corrector will correct FOOO to FOO. «nd hence not editable. and calls addspell.!roperty lists. cdr[x] is a list of edit commands. since foo•s value is not a list. and calls the editor (via eclitf) on 9. (or ~ the on tho correctocl When (if) edite returns. If any changes were made. and calls adds pell. nospread function.

that function. the R but editing would continue with the next function. only those functions whi~h contained a FIE~ ·i. would be unsaved. editfns will proceed to causes an the next function . 109 Thus in the above example.21-23 for definition of 'match' .~.:-~~.89 . the function would not be unsaved.changeflg] is the pattern match routine.. if an err6r occurred while editing a function via its EXPR property. only those actually changed. The call to the editor is error set protec tad.1~~~-b.~1~.:·---------------------------------- [MAPc (EVAL (CAR X)) (FUNCTION (LAMBDA (Y) (APPLY (QUOTE EDITF) (CONS (PRINT Y T) (CDR X] 109 In particular. EDITFNS(FOOFNS (R FIE FUM)) will change every FIE to FUM in each of the functions on foofns.1~1~1~~-~. if command would cause an ~ne error. The value of editfns is NIL. 108 For example. the entire pattern is scanned for atoms or strings containing alt-modes. edit4e[pat. so that if the editing of one function error. · 110 changeflg is for internal use by the editor. in the abovo example. 110 Note: before each search operation in the editor begins.-. In other words.-.x. These are replaced by iaa·~:. 9. pat-matches ~· Its value is T i f See page 9.-~.e. of the functions did not cont~in a FIE.

expression. pattern type 6a is indicated by car[ pat) being the atom $ ($ is alt-mode) and pattern type 6b by car[patJ being tho atom $$ (double alt-mode). the atom or string up to but not including the final two-alt-modes.JJJ Thus from the standpoint of edi t4e.pat.patterns of the form (CONS (QUOTE S) (UNPACK atoin/string)) for (CONS (QUOTE $$) (CONS (NCHARS atom/string) (UNPACK atom/string))). 112 editfindp[x.lo. edi tfpat[ pat: flg] This is done with the function editfpat. is T if the otherwise. command 25 is an The value of editfindp F pat would succeed. and for 6b. 111------------------------------~-------·------------------------------------In latter case. possible. atom/string corresponds to. Thus. 9. he must first convort any patterns which contain atoms or strings ending in alt-modes to the form recognized by edit4e. i f the user wishes to call edit4e directly. makes a copy of pat with all patterns of typo 6 converted to the form expected by edit4e. unless f. dunpack is used wherever 112 flo=T is used for internal use by the editor.90 .flg] allows a program to use the edit find command as a pure predicate from outside the editor. pat a pattern. In both cases. Therefore.=T. it will is applying expressions be more edi tf indp using efficient to tho samo to call editfpat once. if the several program different pattern. and then call editfindp with tho converted pattern and f!9=T. 6a. edi tfindp calls edi tfpat NIL to convert pat to the form expected by edit4e.

the call will also be relinked to calrto instead. See page 9. getd[ fn]]]. esubst is always undoable.errorflg.1 16 The value of changename is fn if at least one instance of from was found. changename is used by break and advise for changing calls to fn1 to calls to fnl·IU-fn2. 9.Jill succeed even i f from is called from fn via a linked call.esubst[x.from. 1. 114 of the type that never causes a break. replacing each occurrence of from with to.59.y. 115 \. If fn from by is an expr.to] replaces all occurrences of definition of fn.91 In this . changename[fn. in If fn changename searches the literals of all Of its compiler generated subfunctiows). to (and tho changenamo performs nlsetq[ esubst[ to.z. case. esubst is the modified !· if found in !· ~·not order of Note that y_ The value of Generat~s an error 11 ~ If errorflg=T. is compiled. jj3---------------------------------------------------------------------------unless charflg=T. also prints an error message of the form y ?. the arguments· is the same as for subst. otherwise NIL. from. and/or ~ can employ alt-modes. in which case it is equivalent to (RC y x).charflg) the equivalent to performing (R y x) 113 with ~ as current expression. e.

92 is Tho . If edi tracefn=BREAK. the same information printed. editracefn is initially NIL.editracefn[comJ is available to ~elp the user debug complex edit macros. BREAK options However. or subroutine calls to the editor. the name of tho . If editracefn is set to T.corrunand and the current expression are printed. If edi tracefn is set to TRACE. user can then examine the state of the editor.:orrunand as its argument. giving it that c. 9. and the editor goes in to a break. the TRACE and described below are probllbly sufficient for most applications. the function editraccfn is called whenever a corrunand that was not typed in by the user is about to be executed.

....••••••••••••••••• EDITE[EXPR.... cot1trol-E .•.••..•••. .•••...11-21.••......••••••.••.....•••••••••• ( CHAIJGE @ TO . edit command) ••••. ·-·· ...........•• edit chain ..••••. (80 n) (edit command) •.42 9•51 17 9... .84 ..67-70 9..unand) .•.......•••........•....41 9.•••••... DESTifJATIOtJ IS INSIDE EXPRESSION BEING MOVED (typed by editor) .52 9.•..3 9...83..••••••••••• commands that move parentheses (in editor) •••••• (COMS xl ....64 9. . ADDS PELL[ X ...•••.• CAI~' T .. (BF pattern T) (edit command) .41 9..••••.9.• AFTER (in MOVE command) (in editor) ......•.28 9...•..15-21...••••••.•.•••••••..86-87 9..•••• BY (in REPLACE command) (in editor) •...•••• EDITCOMSA (editor variable/parameter) ...••.••....•.75 9.•......••....••.....FLG] •••••••••••••••••••• .••......PAT.TO] •••••••••••••••••••••••••• CL (edit cor....COMS.. . xn) (edit command) •••••••••.. em) (edit command) .....•.80-83 9..62 9..4.••••. ..•..• (E x) (edit command) .39-40 9 .•.....7. BEFORE (in INSERT command) (in editor) ••••. •••••••••• editing compiled functions •••••......86-87 9.•........•..•••......••••...•...•••.•••••..... EDIT (typed by editor) •.•••.72-74 9.•..•••••••••• EDITCOMSL (editor variable/parameter) ••••.8 7-88 control-D 9. (BI n) (edit command) ..42 9.64 9.........•..•••.•.••..•••...iand) •••...••. em) (edit command) ...•••••••••.4...•...63 9. -.....•••.... 77 9.....•••..• (B el ... ..31 9...•••••••• BK (edit command) •.....49 9...••• E (edit cor.....•..•.42 9..88-89 9.••.••••••• EDITL[L........•..80-82 9...•.......••..•...48 9.42 9.9.••••.91 9....83 9....... current expression (in editor) ••••••.....••••• edit commands that test .COMS...87-88 9.91 9....13.••••... ...52 9 .. ...62 9.37....•.••.•. 9. continuing an edit session •••....••.•••••••...1.. (BK n) (n a number.•...13..ATM.2.10.••••• DELETE (edit command) ..70 9 ..80.11-13..•.ATM] •••••••••••••••••••••••••••• EDITF[ EOITFX] NL* ••••••••••••••••••••••••••••••• EDITFIIJOP[X.••••• BEFORE (in MOVE command) (in editor) •...31 9..••••••••••• BLOCKED (typed by editor) .••••••......•••••.....23-36 9....1 9....90 9...18-19 9.......•..•......MESS] •••••••••••••••••••••••••• INDEX...••••••••••• CAP (edit command) ....••• edit r......•• OW (edit com..•.............•••••. ..• DWIMFLG (system variable/parameter) •....•....8.80...unand) .....•....unand) ...••• EDITDEFAULT (in editor) ...14..•..• (E x T) (edit conunand) .19 9.••..•••••.. .•..90 9... CHANGEIJAME[FN.48 9...... ...84.N] ••••••••••••••••••••••••••••• AFTER (in INSERT command) (in editor) ......r..Index for Section 9 Page Numbers (A el . (DELETE • @) (edit command) ....... .8. 23-36 9.... (BELOW com) (edit command) . ) (edit command) ••••.•••.... BF (edit command) ..71 .28 9....8..•••••.10.51-54 9.••......•••..•••••••••• 9.••..•••....•••••...... .SPLST .•.••............••.52 9.77 9....AT TOP (typed by editor) ••••...•......1...••...21-33 9..•..•••. (BELOW com x) (edit command) ...FLG] •••••••••••••••••••••••••••• EDITFNS[X] NL"' •••••••••••••••••••••••••••••••••• EDITFPAT[PAT.••• ( COMSO • corns) (edit command) .••••••••• (BI n m) (edit command) ..••••..39-40 9 .......••••••••• (Brno . ....•......FROM.•.. 79 .... edit cor.•.40.. corns) (edit cor...unands that search •...lacros ..83...62 9..82 9..

.••.•.••• (F pattern T) (edit command) ....... (EMBED@ IN .•.64 9 ..•...75 9... ....••• LASTVALUE (property name) ....... ..67 9....•••• HERE (in edit command) ......... ........................•.. LOWER (edit command) ...............COMS..26 9.... @) (edit command) ...53 9.8..lmand) ...87-88 9.89 9...28-29.37·39 9.. (IF x corns 1 coms2) (edit command) ..... (IF x comsl) (edit command) ..•••.•••....••••..74 9.••••.... x) (edit command) .1....•••...92 9. EXPR (property name) ...73...........8..@) (edit command) •.. ) (edit command) ..•••••........................•.....••••••.............41 9..42 9.••.65 9..46 9..•... ...•..... ..74 9..•••• LASTAIL (editor variable/parameter) •••••••••..••••••.Page Numbers EDITLOADFNSFLG (editor variable/parameter) .......•... corns) (edit command) INDEX. ...•.•.....•......•• (LI n) (edit command) .. (IF x) (edit command) .84 9......•••. ( LPO • corns) (edit command) ...•..30 9...27 9.••..••••• (F pattern N) (edit command) .. ... EDITUSERFll .•.41 9... AFTER..... ....32... ......•••••••••••••... .•.•••.......30 9........•........FLG] .• ) (edit command) (LO n) (edit command) .. ....•. .•..............68 .... ...•••••..•.. (I c xl .... ...87-88 9....••......... L-CASE[X... ) (edit command) ..••• EDITLO[L..65 9.......••..... .... edit command) ..•...• ESUBST[X.... ...•••.....••••• JOir~c (edit command) .•••••••• LASTWORD (system variable/parameter) ...25-26 9..41 9.•••...•....84 9.1.........80 9 .EDITLFLG] ....•••••...... @) (edit command) .••. EDITV[EDITVX] NL)!( ••••••••••••••••••••••••••••••• EDIT-SAVE (property name) •...... .....••...MESS.....••..91 9. xn) (edit command) ..... errors (in ecli tor) .....78 9.. EDITOUIETFLG (editor variable/parameter) ••..•••...... F (edit cor.87 9.•.......89 9...73 9...•...41 9....•••.Y.•• (M (c) (argl •. .• argn).. L ISPX ........ corns) .......• (INSERT ....•••••••• (LOWER x) (edit command) .....••••• (FS ..•.••••••• ( LCL .......•...... ..ERRORFLG.•.....53 9.CHARFLG] ..... (F= .76 9...••........ cons) (edit command) (M (c) arg . ..6.... ....•..••••••••• LOCATION UNCERTAIN (typed by editor) •••...66 9.••••..... ...62.... (EXTRACT @1 from ..••••..••..........68 9.. .....•••.X.... @) (edit command) •...••••••••• ( HJSERT ............•.85-86.•.•.••............••••• generalized NTH command (in editor) ••...•...... corns) (edit command) ....• EDIT4E[PAT.•• location specification (in editor) ••••. ......72 9..25 9... iQplementation of structure modification commands (in editor) ........•..• (M c . .......25........•..... ....... .48 9...60 9.••.. ....•....••...... (LP .......17 9...CHANGEFLG] ... (EXAM ..••••••••• rn (in EMBED command) (in editor) •...••••• EDITRACEFU ...... EDITP[ EDITPX] NL"' ....2 9.•••••. @) (edit command) ••••.. @2) (edit command) .••••••• (LC ..••••...64 9.......3 9... history list .•.......•....•.27 9.. .••••... ..••••.•.48 9. ..27 9...66 9... . BEFORE ..........•••• (F pattern) (edit command) .•......26 9..26 9..65-66 9......•...9..16-17.. FOR . .....Z........... ..72 9....62 9..46 9...... (F pattern n) (n a number..•..••••••••••••• (rnSERT ...•••. ........22 9...••• FOR (in rnsERT command) (in editor) ••••••••••••• FROM (in EXTRACT command) (in editor) •••••........86 9..•. F pattern (edit command) ......52..

OK (edit col'7lr... ......23-25 .••••• (RCl x y) (edit command) .8.unand) PPV (edit cor.•••••••••.••.....lr......... • ..••. ....unand) ••......•••••.••••••••••••••••••••••••••• MOT BLOCKED..••••••••••••••• (ORF ••• ) (edit command) ... (n el ••..• . .18-19 9.. edit command) •••••••• n (n a number........61 9..85 9....33 9.28 9....... @2).......36 9.••••• •..74 9.....•.. 77 9...20 9..2......land) PPj!c (edit cor:'l.........66 9..•••...... em) (edit cornmand) •••••••••••••••••• (MOVE @1 TO com .. (typed by editor) ...59 9...66 9..•.......32 9. RESETVAR[RESETX..•••..67-70 9......hland) prompt character . .land) .... edit command) .........••..••••..85 9...36 9.61 9..••••••••••••• (Rl x y) (edit command) ...••••...36 9...land) PPT (edit cor.•••••••.• @)(edit command) ••••••••••••••••••• ·PP (edit cofi1r...••..LifJE.•..••••••••••...61 9.....83..81 9.•••.....71.RESETZ] NL ••••••••••••••• (RESETVAR var form • corns) (edit corrunand) ••••••• (RI nm) (edit command) ••••••••••••••••••••••••• (RO n) (edit corrunand) ...•.64.2 9.53 9.•. em) (edit command) .. . em) (n a number...79 9.70 9.....•••••••••• MARK (edit cornnand) ..~ •... .. ..................•••••....•••••••••••...•.....60 9.. (S var • @) (edit command) ••..5. .84 9........60 9.....•••••••••••••••••••••••• (MARK atom) (edit command) ••••••.53 9.48-51 9. (RAISE X) (edit command) ..... flOT CHAIJGEO. •••••••••••••••••••••••••• (fJEX x) (edit command) fJEX (edit command) •••••••••........8...59 9....•..32 9...............65 9..87 9...••••••••••••••••••••....•••••..••.34 9.19 9.....•.3.••••••••••••••.. .•....34..... by editor) ....•.••.....34 9.. (edit command) •••••••••••• (rJ el .....27 9..75 9..unand) 9. PROP (typed by editor) •••••••••••••••••••••••••• ( R x y) (edit cornnand) .• (Pm) (edit cor. SO NOT UNSAVED (typed by editor) NOT·EDITABLE (error message) •••• ~ ••••••••••••••• fJOTHrnG SAVED (typed by editor) ••••••••••••••••• (NTH n) ( n a number..•••••••.......••... .57 9. RAISE (edit command) · •••••••••••••••••••••••••••• (RC x y) (edit command) ••••••••••••••••••••.......••••••••••••••• search algorithm (in editor) •••••••••••••••••••• INDEX.89•90 9..•.Page Numbers macros (in editor) ••••.. . MARKLST (editor variable/parameter) ······~······ MAXLEVEL (editor variable/parameter) •••••••••••• MAXLOOP EXCEEDED (typed by editor) •••••••••••••• MAXLOOP (editor variable/parameter) ••••••••••••• (MBO el ...•........... READLiflE[RDTBL..9. ..83 9..60 9...60 9..3 9 ......17 9.. .......•• pattern match (in editor) ••••••••••••••••••••••• (pattern .•••.••.• ·• ••. (n) (n a nunber..••••••••••••••••••••• rill (edit command) •••••••••••••••••••••••••••••• rlOBifJO •..59 9.. (REPLACE @ WITH . (ORR ••• ) (edit command) .•••••••••••••••••••• SAVE (edit command) ••••••••••• ·• .... ) (edit command) ....•...••• P (edit cor...••••• (REPACK @) (edit command) ..LISPXFLG] ••••••••••••••••••• REPACK (edit command) •.72...77 9....32-33 fJX (edit cor.•.78 9... edit command) 9...lr.••••.. .76 9.....83-84 9..RESETY.•.. .........74...75 9... .76.•.. edit command) •••••••••••••• (NTH x) (edit command) .8...36 9..66 9....24..........5......7...47 9.. ••••••••••••••• ( NX n) ( n a number.. .••••. ( P m n) (edit command) .. edit command) .......land) .2.86 9....•• •••••••••••••••••••••••••••••• ......•.......•••• OCCURREflCES (typed....21-23....42 .

.... .61 9.... -n (n a number... TEST (edit cotil.....unand) .land) ...70 9.....•. .....••••• "'"'COMMENT*"'FLG (prettydef variable/parameter) (-n el .....•.....••.......•••.....2 9.22 9....... .11.41-42..........48 9.12.78 9.••...• UNFIND (editor variable/parameter) ·······~······ .••.......•..........•••. ......•..76..• $ (alt-mode....43 9.......•.•...••••• "' (typed by editor) ....71·72.•.47 9....Page Numbers (SHOW .•...•..28..10.78 9 ..80 9.. in R command) (in editor) .•.••..•.••..•...76........••.. edit command) ...••...••...54-57 9.21 9....80...•..82.•.58 9.•••••••.•..... u-CASE[XJ .......•••••••••• TTY: (edit cor....•....•••••....unand) ....42 9........29....••••.•• .....17 9.•...71 9...•...74 9.11.............21 9..70.83·85 9..••••••••••......•...•• THRU (edit cor. WITH (in SURROUND command) (in editor) .tructure modification commands (in editor) (SURRourm @ rn ..•••.........•......••.36-60 ' 9.19-20 9............. x) (edit command) ..78·79 9.....•••••••••••••••••••• INDEX.22.•..•. UNBLOCK (edit cornnand) .66.... ! ur~oo (edit command) ............••... .•..•.... .. .••. ...•..•••........ SBUFS (alt-modeBUFS) (prog.....••..•..•••.......... (typed by editor) ..13........•••..10..25..3. ...•• (in edit pattern) •.•.•• UPFINDFLG (editor variable/parameter) ....lr.••..•...••...•.35.. 0 (edit command) ..........•• WITH (in REPLACE command) (in editor) ..•.. (XTR .... ) (edit command) ...•••..86 9.....4 9.5..80.• USERMACROS ( prettydef command) •.. ! 0 (edit cor.•..36 9.....61 9...21 9.....unand) .•.•.30 9.• °COMMEIH*"' (typed by editor) .7 9..••... .60 9..•.......... em) (n a number.....••..•.• USERMACROS (editor variable/parameter) •....•.... ...•.....•.•• USERWORDS (system variable/parameter) ...........••••......•..•............triland) ..........46...58 9......•...•• (SW nm) (edit command) terminal .mand) ••••.........•.70-72 9..........44 9. 77 9.•• •ANY* (in edit pattern) .......18 9.............•......... UP (edit conraand) .48 9.•..43 9..45 9. and CHANGE commands) $ (alt-mode) (in edit pattern) ........•.25....••...79 9...86-88 9. : ...... ...•.30 .... ( 2ND .••.•.15-16.......••••••......•.63 9.•.... (edit cor..... .48·51.25..... ........ 72-73......•.••••..72....••..•.• UNDOLST (editor variable/parameter) •.........• UNDONE (typed by editor) . command) ..•... !t-JX (edit command) ..........••••.78-79.........•.....••..•..•............ ( in e di t pat t e r. spelling lists .••.•..n ) ........22 9.. •••••••••••••• •#(in INSERT...•.••. & (typed by editor) .....84 9..86-87 9...••.... .84 9... @) (edit corrunand) .23 9....•...••...•.... asst...••..78 9....••... edit command) . ( 3RO ...82.....••••••• & (in edit pattern) .•..•.4-5.54-57 9.••.. "' (in MBD command) (in editor) ... REPLACE..•..•••...15 9.••.....66 9..••....12.... ..•...........•...•••...• s.. spelling correction ......... (SPLITC x) (edit command) .•.••.•.. ..•••.17 9.33 9.2 9...• $$(two alt-modes) (in edit pattern) ....•.59-60 9.• undoing (in editor) .. UfJSAVED (typed by editor) .•.••. UUDO (edit command-) . .........•...•.•..•...•. TTY: (typed by editor) .. .......•• TO (edit cor..•••...••.•..•.••. .•...•.9.......... ........36.85 9...•• -> (typed by editor) .......... @) (edit command) •••..•..•••....••...•..........79 9...••••••••••••... STOP (edit cor:unand) •.•....•..... @) (edit command) . *#[ COMS) NL"' ••••••••••••••••••••• ..

.11...•. (@1 TO @2) (edit command) ..•..34 ........... = (typed by editor) ..••.. (edit cor:ir:iand) .•••••••• (@1 THRU) (edit command) .....•••........•••.. x) (edit comrnand) ....61 9..•••••••• ? (edit cor:unand) .•....•....•••••••••••••....••• (o..••..60 9........•.......34-35... ...•...........•.•••..•• =E (typed by editor) .•.•••••••............•••• (: el .••... =EDITP (typed by editor) •.. \(edit conrnand) .5 9...•••••••••••..pattern) (edit command) ... =EDITF (typed by editor) ..••••...•.•..87 9...........•.•...........'land) ••....•••••••• \P (edit cor:lf... (@1 TO) (edit command) .. ..82 9.... (\ atom) (edit command) .....Page Numbers 8 (instead of left parenthesis) ... ........ ..... =EDITV (typed by editor) •..4.11..............••....30 9...2....•...•......••..•..••.••. ..•..86 9...•••••••• .••........••...22 9.34 9...41 9....56 9............................56 9...••..•..•........•..82 9...•. .....•..........•••.....3 9. ..••.... .••••..••...•.••. ...35.•..54 9.....34 9...76 9 .....•...••.. INDEX.. == (in edit pattern) ..••• r (edit command) ... en) (edit command) ..18 9...••..14.••• @ (location specification) (in editor) .40 9.. (...••..86 9. ..29 9.....54 9.•••.........••.....•...••••••••... (@l THRU @2) (edit command) ......•••.... (edit command) ... ? (typed by editor) ..9.......12 9. ...........•..•...

.

STRING.g. although only literal atoms and strings have their pname explicitly stored.---------------------------~-------------------------------------------except that for the purposes or the funtions described in this chapter.fil!!2£=10. the pname of the atom ABCX(0 2 consists of the five characters ABC(D. all pointers have pnames. 10.. See Sections 2 and 14. ARRAY. the PNAME.5 referred to the characters that were output whenever the atom was printed. 2 % is the escape character. pname was used In INTERLISP.SECTION 10 ATOM. Sometimes we will have occasion to refer to the prin2~pname.1 Pnames and Atom Manipulation The term 'print name' (of an atom) in LISP 1. Tho pname of the list (A B C) consists of the seven characters (A B C) (two of the characters are spaces). The pname of a point1r are those characters that are output printed using prtn1.1 . tho prin1-pname of an integer is defined as though !. 1------. The prin2-pname are those characters output when the corresponding pointer is printed using prtn2. Since these characters were stored on property the atom's property list under interchangeably with 'print name'. wh~n the pointer ts e. AND STORAGE HANIPULATION 10.

4 Except for integers when radix is other than 11. + + + + + i--------------------------~--------~---------------------~-------------------Note that the prin2•pname also depends on what readtable is being used (see section 14). a.g. 4 always produce + In fact.01. ma pc[ ( X 9). Ir the pnama of the value of pack[x] is the same as that or a number. pack(((A B)"CO")] = %(A% B%)CD. pack[(1 E Although ~ u2)]=.. is usually a list of atoms. 3 pack[xJ If ~ is a.g.. pack[(A BC DEF G)]=ABCDEFG.. Ust of atoms o the valua of pnc~~ is a single atom whou pname is the concatenation of ~· the pnames of the atoms in e. mapc(x.n1J and prini[pack[x]] the same output. pack[(l 3. pack[x] will be that number. but pack[ ( X 1 lQ) JaX9.g.4. Note also that the prin2•pname of an integer depends on the setting of radix.'I 0 e.pr:l. The value of pack is still a single atom whose pname is tho same as the concatenation of the pnames of all the pointers in~· e.2 .g. In other words. it can be a list of arbitrary INTERLISP pointers. PRIN 1] produces X11 when ~ is 8.) 10.Thus the erin2-pname of the atom ABCl(D is the six characters ABCl(D. actually operates by calling ~rin1 pointers characters to printing} and a stream then of m&kes an 2nck to convert the atom out (without of the result. since this determines where %'s will be inserted.4)]~13. (See footnote :i.

rdtblJ 6 number of characters in pname of ~.rdtblJ The value of unpack is the pname of ~ as a list of • characters (atoms). scratchlist is not a list.s the number of characters tn t11e pname of !· dunpack[x. atom. than they do on numbers and lists. unpack[x:flg. 6 e. ATOM TOO LONG. to c X( (and 0 %").flg. is t~o If the p·name long to fit in scratchlist.O.3 * . where !! respect (X" AB ~ . is used.g. i. e. literal atoms and strings. the prin2·pname of computed with unpack["ABC(D".scratchlist.s are re. the Both nthchar and nchars work much faster on objects that ~ctually have an internal representation of their pname.T]= 1Vote: unpack[x} performs !! conses.e. dunpack calls unpack and returns unpack[x:flg).rdtbl) a destructive version of uripack that does not perform any conses but instead uses scratchlist to make a list equal to unpack[x.g.Note: In INTERllSP-J.flg]. as they do not have to simulate printing. 10. unpack[ABCJ = (A B C) unpack["ABC(D"] = (A B C %( D) In other words prinl[x] and mapc[unpack[x):prinl] produce the same output.s. If !!s=T.flg. Attempting to create a larger atom either uta pack or by tvptng one tn (or reading from a file) wtll cause an error. 6 If flg=T. t. Gives an error if. nchars[x.strtcted to < 99 character.

!Jl=T. 7 e.rdtblJ similar to dunpack n is a character code. e. Thus chcon(x] could a~mapcar[unpack[x].fl~.flg.4 . dchcon[x. 8 + 8' See footnote 2.g.chcont].rdtblJ NIL~ packc[(70 79 79)J=FOO.g. character[nJ Value is the atom having the corresponding single character as its pname. chcon[x. the value of nthchar is packc(x] like pack' except ~ is a list of character codes. the prin·2-pname is used. ·1 refers to the last character. except returns the pname. of list of character codes. gr~ater than the number of characters If ll is in the phame. chconl[x] returns character code of first character of pnamo of ~· e. can be negative.n JJ but faster and does rr no conses. like unpack.scratchlist. or O. in which case counts from end of pname. etc. 10.o car[nth[unpack[x: flgJ . nchar~["ABC". e. used. or less than minus that number. chcon[FOOJ ~ as a = (70 79 79). is nchars[ 11 ABC 11 ]=3.prin2-pname E.TJ=5~ nthchar[x~n.rdtblJ Value is rrth character of pname of ~· Equivalent t.flg.g.g. ·If f.g. be written chcont[FOO] = 70. ·2 next to last.

g. fcharacter[n] fast version of character that compiles open. various uses The value of gennum. initially 10000.e. e.YID will be the A0012 already in existence. 10.s: they have property lists.s u. e. mapatoms[fn) Applies fn to every 11tera1 a tom in the sys tern. character[70] m F. nlistp[x] is T. if the user has previously created A0012. The term gensym i. etc. unpack(x] could bo written as mapcar[chcon(x]. the first one generated is AOOOl.character]. 1ltoms generated by gensvm are the same a. NIL otherwise. i f gennum is set to 10023. For example. mapatoms((LAMBDA(X)(AND(SUBRP X)(PRINT X)))J will print every!!:!!?. Note: if a string. determines the next gensym.!:. either by typing it in. gensym[char) Generates a new atom of the form xnnnn. Thus.sed to indicate an atom that wa. String Functions stringp[x] Is ~ if ~ a string.· 10~2 Value of mapatoms is NIL. or via pack or gensym itself. Thus.s produced by the function gensym. the second A0002. gensym provides a way for of generating new atoms within the system. Note that the atoms are not guaranteed to be new.5 ~ is . gensym[]•A0024. but atom[x] is NIL. when gennum gets to 10011.g. and can be given function definitions. the next value returned by gens. ~=char whore (or A if char is NIL) in which each of tho n's is a digit.g.s any other literal utom.

as with Returns NIL if the substring is not well e.4.see. Equal uses Note that strings may be egual without being !£!· mkstring[x] Value is string corresponding to print of rstring( l Reads a string . except substring does not have to actually make the string i f ~ is a literal atom.6]="B C".Section 14.if ~ If! isn't a string.e. i. ~ are both strings same. string~ and removes Returns . a~d NIL.y] Is if ! and ~ prin. substring[(A B C).strequal(x. 10.6 . !l and nthchar.g. a string 9-----------------------------------------------------------------------------See string storage section that follows.n. otherwise equal. NIL . m· can ~ is ~· NIL. the thru the end be negative numbers. defined.m) Va1ue is the substring of . the character from the is the null string. gnc[x] ~et rrext £haracter of string ~· Returns the next character of the string.:s consisting of the nth thru· ~th cftaracters of If ~· ~ :substring is the nth character of of !· . substring(x. equivalent to substring[mkstring[x).n:m].t the stregual. 9 For example. (as an atom). ·Or !l m> nchars[x] or · < minus(nchars[x)l or· . n corresponds to a character ' - in ! to the right of the character indicated by ffi· If is not a string.

io----------------------------------------------------------------------------see string storage section that follows. just the pointer and the byte count. (copies The arguments are transformed to strings if they aren't strings. rplstring[x. was not a string.e.to glc[ x] gets !ast £haracter of string x.DEF. of) any number of strings. ~ ~· 1111 . Note that if ~ is a substring of y_.g.is made.£. are converted to strings if they aren't already.:$ beginning at !l may be positive or and Y. concat[ 11 ABC 11 . 11 Note that if ~ is a substring of !• ! will also be modified by the action of rplstring. i. Concatenates lambda nospread function. 11 GHI 11 ) "' "ABCOEFGHI 11 • of concat[] is the null string. will 'fit' without actually attempting the transfer. Value is the new string. Above remarks about rul£ also supply to a1.7 . i. the new string would be longer than the originai. gnc doesn't physically change the string of characters.n. (converted) The value Characters are smashed into Returns new not enough room in ~ ~· Error if there is for y_. ! will already have been partially modified since rplstring does not know whether Y. 11 If Y. e.e.y) BeJLl:ace characters of string character !l with string l· negative. 10. Used for sequential access to characters of a string. gnc[x] doos not remove the character from y_.

g._ else they are Searches l beginning at (or else ·.."XYZABCOEFABC".5]=10 skip can be used to specify a character in ! that matches Ci")' charac'ier in.! and x are. 1 if.&]=4 10. atom %(A% 8% would have C%)~ mkatom[(A B C)) is the In INTERLISP-10.."XYZABCDEF". start~ ."XYZABCOEF".an instead . the same as that of mkstring[x).. i f the atom > 99 characters..~XYZABCOEF"]=4 s~rpos["ABC". . ATOM TOO LONG. strpos[x.s ·.S]=NIL strpos[~ABC". .to !· I.:· . both string& (or converted automatically).s. ·~.of a tail. Searching. Roughly it corresponds. otherwise NIL.. the corresponding character position ·is returned. e.8 . a character positi. strpos["A&C&". character number..- NIL) and look. to member •.start:skip. given to substring or utilized in other calls to strpos.Strings strpos is a function for searching one string looking for another... except that it returns .f a .NIL. e.g. nutnb~r This number can then be. causes an error. e.•· strpos["ABC". for a sequence of characters equal .match is found.tail) ..Creates an atom whose pname is the same as that of mkatom[x) the string ! or if ! isn't a string. start i.anchor.g.y.

T]=4 Finally.NIL.NIL. strpos["ABC":"XYZABCOEF":NIL:NIL.g.If anchor is T.T]=Nll strpos["ABC". strpos compares x with tho characters beginning at position start.NIL.9 e. strpos returns NIL without searching any further down l· Thus it can be usod to compare one string with some portion of another string.NIL:TJ=7.g. Note that strpos["A". and that ~· write a function foo that will make a string portion of between and foo["NOW IS THE TIME FOR ALL GOOD MEN"."XYZABCDEF":4. i.T]=2.NIL. e. ."A".g. strpos["ABC":"XYZABCDEFABC":NIL. · even though "A" has only one character. or 1. the value returned by strpos if successful is not the starting position of the sequence of characters corresponding to but the position of the first that.e. If that comparison fails. Example Problem Given the strings corresponding to ~."IS"."FOR"] is" THE TIME" Solution: (FOO [LAMBDA (X Y Z) (AND (SETO Y (STRPOS Y X NIL NIL NIL T)) (SETO Z (STRPOS Z X Y)) (SUBSTRING X Y (SUB1 Z]) 10.NIL. tail if is T. ~. starting point plus ~· character after nchars[x] e.

If neg=T.g.would be equivalent to a list (40Q 410 420 43Q) or (%_ ! %"· #). strposl[(A B C).neg) str is a string automatically characters to (or a else string).neg:a] makes a bit table suitable for use by strposl. strposl first converts it to a bit table using makebittable described below. 10. Thus an array whose first element was 17Q . and then passing the bit table to strposl as its first argument. character or it a is is convertod list a codes . !. If strposl is to be called frequently same list of characters.10 . for strposl. 1 and !l!. it is assumed to be a character coclo. E.. Therefore' it is more efficient to call strposl with a a list of character codes.str.. If ! is not a bit table (array). The bits ·of . 12 of strposl searches ill beginning at character number stllrt (or else. strposl searches for a character not on e. strposl returns as its corresponding position. strposl[(A BC). "ABCDEF":NIL:T]=4. 43Q~ correspond to character of (ELT A 2) to codes 44Q to 107Q.start. g. 1. it is treated as a bit table. (El T A 1) .strposl[a. if start=Nll) for one of the characters in !· If' value the one is found. Otherwise' it is converted to a character code via Cheon 1.• I f ! is an array. makebittable[l. character otherwise·Nll."XYZBCD"]=4.9 are a as suitable array. a considerable savings can be achie~ed wi~h tho by converting the list to a bit table once.codes O to etc.. makebittabl• will If ! is cr~ate not an array 12----------------------------------------------------------------------------If any element of a is a number.

the The pointer.and return that as its value. and the should bo r~sulting table (array) should be given to strposl with neg=NIL. the characters of the string. strpos. no additional storage is required for using literal atoms instead of strings. although one cell is required internally. conversion atoms and strings does not require any additional storage characters of the pname.g. to construct the "inverted" table. or strposl. e. Since the internal pname of literal atoms also consists of a pointer to the beginning literal of a string of characters ·and a byte count. strposl must call makebittable whether ! To obtain bit table efficiency with neg:T.11 . storage. as in for the between for the string pointer. 10 . the characters· of characters to a word in a portion of the the It occupies one word· of string are stored five address'space devoted exclusively to storing characters. In INTERLISP-10. indicates the bute at which string begins and the length of the string. and a pointer to the characters. Otherwise it uses (and changes) !· Note: if array. neg=T./hen the conversion is done substring. 13 \. String Storage A string is stored in 2 parts. is a list or an makebittable called with neg=T. or 'string pointer'.

n . .(x.'· 10.me space mkstring[atom]) (as in which result case quietly copied to string space x other new pointer and characters y any ·type type of y doesn't matter _.m] gnc[x] and glc[x] x string no space x literal atom new pointer other new characters and· pointer ~ string new pointer x 11 teral atom new pointer other new characters and pointer x string no space. one new pointer rplstring.The use of storage by the basic string functions is given below: mkstring(x] substring[x. pointer is modified other like mkstring. is . but doesn't make much sense new args.any type characters for whole now string.y] x string no new space unless characters are in pna.n.12 of ~ .

n-p 2o cells initialized with y. is initiated. y.a swappable array. (So~ section 3. i f ! is not an array. - swparray(n.) arraysize[a) Returns the size of array !· + Generates an error.e. as a literal atom. where n ts the octal representation of the pointer. ARRAYS FULL. . unsuccessful in obtaining sufficient If this is space.p. numbers. available for array an pointers). ~ is NIL. an error is generated. GC: 1. Arrays of pointers and unboxed numbers may be manipulated the by following functions: array[n. containing all If and 0 each is usod INTERLISP The value of array is the array.x) like array but allocates ·.13 + . will The information. also called an array pointer.. . If sufficient space is not available for the array. 10 . (Le.v] This function allocates a block of n+2 words.p. of which the first two are header information. last n are cells which will contain unboxod and are initialized to unboxed 0. storing initially contain.. and not an arrav pointer.10.3 Array Functions Space for arrays and compiled code are both allocated out of a corrunon array space. The next p S. 1Vote that #n will be !!2Jl. ARG NOT ARRAY. pointers contain both £!U: and ££!::: are i. a garbage collection of array space. Array-pointers print as In.

14 . sets the nth element of the array !.s inverse operations. if ! is not tho beginning of an array.ed region of !• the value of e1t is the ful 1 36 bit word. + elt[a.n] Value is !!1!l element of the array generates an error.arrayp[x] Value is! if! is an array pointer -0thorwiso NIL. i. region of !_. ARG NOT ARRAY t of an array. 10 . If !!. The value of seta is v .• the value of elt is the seta[a.!!. •vote that .• v replaces the £.v] m half of the corresponding element.6 valueof array. No check is made to ensure that x actually addresses the begtnntng of an array.n.!: half of the nth element. corresponds to the pointer region of !.e. and is unboxed and stored as a full 36 bit word into the nth element of a. 15 arrayp is true for pointers into the middle of arrays.seta and el t are alwav. swparrayp[x] Value is ! if ! is a swappable array. 1] is the first element of the array (actually corresponds to the 3rd cell because of the 2 word header). Generates an H ! is not the beginning If !l corresponds to the u n box. j4----~------------------------------~------------------~---------------------el t[ a. NIL a 14 el t otherwise. but elt and scta must be given a pointer to the beginning of an array. as a boxed integer. ed v must be a number. If n corresponds to the pointer region of!.. ARG NOT ARRAY. 16 If n corresponds to tho unbox.· error.

ntyp[ (A type number for lists.eltd[a. i f n corresponds to the pointer regio"ilOf !· - setd[a. but automatically collect some or all of the other types (sec Section 3). the Thus GC: 8 indicates n garbage collection of list words.v) same as seta for unboxed region of a. Value of reclaim is number of words available (for thnt type) after the collection.n] same as alt for unboxed region of a. 10. • type of B)) is 8. eltd and setd are always inverse operations. 10 . Garbage collections. ntyp[x) Value is type number for the INTERLISP pointer 2S• e. but sets cdr half of ""lith element.n. if n corre-sponds to the pointer region of !· The value of ~ is ~· In other words.15 data .g. but returns cdr halfOf nth element. whether invoked directly by the user or indirectly bv need for storage.4 Storage Functions reclaim[n] Initiates a garbage collection of type n. do not confine their activity solely to the dat~ type for which they were called.

garbage its standard collection is setting.. two numbers are printed the number of words collected for that type. RECLAIM(18) GC: 18 511.type arrays. begun. i. GC: whenever is If a printed. compiled code stack positions swapped array handles list words atoms floating point numbers large integers · small integers string pointers pname storage string storage + 'II( number 1 2 4 8 12 16 18 20 24 28 30 16 typep[x..'hen the garbago collection is complete. followed by the type number.n] g~gag[message] affects messages printed by garbage collector. allocated but not necessarily currently in use (see~ below). and the total number of words available for that type. 3071 FREE WORDS 3071 --RECLAIM( 12) GC: 12 1020.e.n] eq[ntyp[x]. 1020 FREE WORDS 1020 + + 1a·-----------------------------------------------------------~---------------New user data types (see section 23) are assigned type numbers beginning with 31.16 . Example: . message=T. \. 10 .

!: of message is printed + (using is + begun. either on entering or leaving the garbage collector. If message is a list. sufficient storage will be added (in 512 word chunks) to raise the level to If ~=NIL. If n=NIL. and cdr is printed when the collection is + finished.typ) when the message ~ garbage is an collection atom or is its previous setting Sets the minimum amount of free storage which will be maintained by the garbage collector for data types of type number m. If. and nothing is printed when the collection + finishes. i.17 even during a garbage . n· 8 is used. no garbage collection message is printed. fewer than n free words are present.e.If message=NIL. string. after any garbage collection for that type. minfs returns the current minfs setting for the corresponding type. A minfs setting can also be changed dynamically. £!. 10. the minfs refers to list words. + message is printed when the garbage collection is + begun. + print) If The value of minfs(n.

Value is NIL. the number is the now minfs setting for the type beinq collected. continues.lhen the control·S is typed. i. . e.. by typing control-S followed by a number. See discussion of garbage collector algorithm.18 . and waits for input. INTERLISP immediately clears and saves the input buffer. followed by a period.g . i t is ignored.e. Section 3. 17 If the control·S was typed during a garbage collection. 10 . STORAGE() TYPE USED ASSIGNED 1 12288 ft120 512 2 4 8927 5120 23 8 6037 15360 12 16 18 2169 0 3584 24 110 802 312 23673 28 30 SUM 512 2048 173 2048 2048 512 44032 If fl!l. when a n. Causes gctrp[nJ a (simulated) control·H interrupt when the number of free list words (type 8) remaining equals !!• i. which is terminated by The input buffer is then restored. Note: A garbage collection of a 'related' . list words.type mav also cause more storage to be assigned to that type. includes storage used by and assigned to the system. storage[ flg J Prints amount of storage (by type number) used by and assigned to the user. rings the bell.e. more con sos. otherwise for type 8. and the program any non-number.collection.=T. garbage collection would occur in i7----------------------------------------------------------------------------\. If the input was terminated by other than a period.

The message interrupt GCTRP (Section Note occurs. is 16) that printed.! instead or going into a break. function and advising a break (Section 19) interrupt the user can program the handling of a ill. as in this case· the function that was about to be called when the interrupt occurred would not be called. cooscount[n] conscount[] returns INTERLISP started up. This will cause interrupt to 11 quietly 11 go away by calling the function that was interrupted. boxed. 18 Value of~ is its last setting.£1!:. 10. Both ~ and a must be numbers.19 . number of conses until next type 8 i. gctrp[] returns number of list words left. is by the called. If the user does not want to go into a break. garbage collection. openr[a] Value is the number in memory location ! .x] Stores 2S into memory location a. see Section 21. the advice should still allow in. 1.!J. resets conscount to !1· closer(a.e.9. gctrp[-1] will 'disable' a previous there are never -1 free ~ since . but first set intype to -1. number If n of conses since is not NIL.terrupt to be entered.2 1 s list words. The advice should not exit interrupt via return. initialized this way.1? interrupts. ]i----------------------------------------------------------------------------For ··alli. interrupt is called with in type (its third argument) equal to 3. e.

..6..• ' • •1 . .....P...A] MAPATOMS[FN] SUBR •· MINFS[N...NEG... • • INOEX...........5 10....... ·.1 '• ' ·....... ........ .........5 10.....FLG:RDTBL] SUBR NTHCHAR[X.19 10.. INTERRUPT[INTFN:INTARGS:INTYPE] literal atoms ....... ..10 ...6·7 10... .. pnames print name ·.13-15 10 ........•' •..............U] SUBR FCHARACTER[N] SUBR garbage collection GCGAG[MESSAGE] SUBR GCTRP[N] SUBR GCTRP (typed by system) GC: (typed by system) GC: 1 (typed by system) GC: 8 (typed by system) GENNUM (system variable/parameter) GENSYM[CHAR] GLC[ X]................ ·• character codes CHCON[X...12 10 .. .X2...7... ...........16 10....... .......19 10.. .. .18 10.............• .....N:FLG..1 10.13 10..13 10..Xn) SUBR* CONSCOUNT[N] SUBR control-H . ... ~ ...... ' ...... 11 10...12 10 ........16 10..5 10 .. .....................Index for Section 10 Page Numbers ARG NOT ARRAY (error message) ARRAY[N.....8 10............ •... • • . • ..4 10.....19 10...".....4 10............ .. ... •' ·~...............18 10 ..18 10.....10 10....... ... ·• control-S DCHCON[X......TYP] SUBR MKATOM[X] SUBR MKSTRING[X] SUBR NCHARS[X...3 10 .5 10....13 10 ..................... ~ -~ ' ..... ..15 10.FLG:RDTBL] DUNPACK[X... ........12 10.. -. ...4 10..... ..... .. .. ... • • • • • • • • • • .18-19 10...3...3 10.............V] SUBR ·:• array functions array header ARRAYP(X] SUBR ARRAYS FULL (error message) ARRAYSIZE[A] ATOM TOO LONG (error message) AOOOn (gensym) bell (typed by system) CHARACTER[N] SUBR ·• character atoms .N] SUBR ·• ELTD[A........ MAKEBITTABLE[L.. • · ~- • .14 10 .13 10...1-5........ .. ..... .........19 10 . ...... ·-··· ..RDTBL] ELT[A...FLG..15 10....... is .. input buffer ·• .. ...... ....• ·• • • • • ·... ....3 10. ..... SUBR GNC[X] SUBR ..13..14 ... .13 10......... • .RDTBL] SUBR* IHYP[ X] SUBR null string OPEIJR[ A] SUBR ·'· ·• PACK[X] SUBR · PACKC[X) SUBR .... .4 10......• . ... ..13-14 10.. . . . ·....19 10 ...... . ....... .....•.... ...5 10. •...~ - 10.. • .SCRATCHLIST.. .18 10 .. . . ......RDTBL] SUBR CHCONl(X] SUBR CLOSER[A..... ........~ prin2-pnames RECLAIM[ N] SUBR ......... .-.. . · ·• · ... ...FLG..... ........11 10 ... .• • • • • • • • • • • ti • • ....... • • • • • • • • • • ..... .4 10 ........... ..................15-19 10. .• ..4 10 .. .12 10.13 10 ..SCRATCHLIST..17 10...... .....X] SUBR compiled code CONCAT[Xl.....6. 10 ..15 10..2 10..4 10.7. ·1-4 10 .......... .. .....• ....... .... ...8 10...

... ..... RSTRING[FILE...... ....5-11 10..........8-11 10...... STRitJGP[X] SUBR ..START. • ......7...... type numbers ... searching strings .3 10.. SUBSTRING[X.•..•.11 10..••..........6 10...SKIP.START....P... string string string string characters .......• ....•......................• storage ..11-12 10...•...•..TAILJ ......•........•..•••....... .••......•.. .........••.......•....• pointers .. .. ...••.. STORAGE[FLG] ......12 10..13 ....... STREQUAL[X...........5 10....... STRPOS[X. 13 10....... .. INDEX..2 10.•..•..11 10.. " ............. ..................... .16 10..... ......10.......V] SUBR .. .... .Y] SUBR ..•.. SETD[A.... STRPOSL[A...........Y....18 10.•.. ... SWPARRAY[N......15 10 ...... • • .... ..•.......... SET A[ A. .....10 10.•...........•.••...14 10 ..•. ....... V] .M] SUBR ..... ...... .... l·I .6 10 .••..•.........•..RDTBL] SUBR user data types # ..RDTBL] SUBR .......... ...••....14 10..••...15 10.FLG....Y] .....16 10.. ..... • ..... • • • . .ANCHOR.•......•.................. ..•...•.•.7.. r~ J .Page Numbers RPLSTRING[X:N.........V] ................ . SWPARRAYP[X] SUBR ..... ....13 10.. • ..•. T vPE P[ x............•......•.........•... ................ (followed by a number) .12 10... • .................. ....NEG] ..N..........•... .STR. • • • • . functions .......6..... .. ..IJ.... II unboxed numbers (in arrays) UNPACK[X............8-9 10.... •.•.....

.

g. (MAPC LST (FUNCTION PRINT)) will cause mapc to be called with two arguments the value of 1st and PRINT. for example. (MAPCAR LST (FUNCTION(LAMBDA(Z) (LIST (CAR Z))))) will cause mapcar to be called with the value of 1st and (LAMBDA ( Z) (LIST (CAR Z))).SECTION 11 FUNCTIONS WITH FUNCTIONAL ARGUMENTS As in all LISP 1. Note that . mapx.5 Systems. 11. all system functions standardly use variable nnmos consisting of the function name concatenated with ~ or fn. However. Similarly. thereby using the INTERLISP FUNARO feature. function will cause code to be compiled for ~: quote will not. If ~=NIL.y] is an nlambda function. ~ or npplyft must be used to call the function specified by the value of the functional argument. function[x. When compiled.by specifying the free variables used in a functional argument as tho second argument to function. For example.1 Thus . Functions which use functional arguments should use variables with obscure names to avoid possible conflict with variables that are used by the functional argument. the user can be sure of no clash. since fil!. arguments can be passed which can then be used as functions.!: of a form is never evaluated. the value of function is identical to quote. e.

the value of function is an expression of the form (FUNARG x array). e.5-7. will therefore of 1st and The functional still be tho argument interpreted. map compiles open.mapfnl. and then compiled.2 . 1 If mapfn2 is provided. The value of map is NIL. variable where bindings for array those contains variables the on X· Funarg is described on page 11. If is not NIL. it is a list of variables that are (presumably) used freely by !'S· In this caso. until mapx is exhausted. map[mapx.mapfn2J If mapfn2 is NIL. That is. e . map applies the function mapfn 1 to successive tails of' the list mapx. alternate elements of the list would be skipped. The corresponding expression using function will cause a dummy function to be created with definition (LAMBDA --).• becomes a non-list.g. first it computes mapfn1[mapx). and then mapfn1[cdr[mapx)J. mapfn2[mapx] is used instead of cdr[mapx] for the next call for mapfnt. 11.. etc. mapcar would then be called with the value of 1st and the name of the dummy function.. ~ See Section 18.(MAPCAR LST (QUOTE (LAMBDA -·))) will cause mapcar to be called with the value expression (LAMBDA ··). i-------------------------------~---~-----------------------------------------1. if mapfn2 were ~.

(LAMBOA (Y) (ANO Y (LIST Y)))) will make a list consisting of x with all NILs removed. mtlp on tails.. e.mapfn2] successively computes the same values that m.mapfn1 .mapfn2] computed at each iteration instead of mapfnl[mapx]. mapc compiles open. but nconcs the values to form a list which it returns. mapcar[x. if applied to .g.mapfn2] computes the same values that mapc would compute. e. mapcon compiles open. mapconc[X.mapfn2) mapcar compiles open.mapfn1.mapfnl .3 lists on ~· e.FNTYP] is a list of fntyps for each element mapcon[mapx. mapc works on elements.g. except that mapfnl[car[mapx]] is mapc[mapx.mapfn1.g. and returns a list consisting of those values. mapcar[mapx. mapconc compiles open. Note that rnapcar creates a new list which is a mapping of the old list in that each element of the new list is the result of applying a function to the correspondin~ element on the original list. mapconc[X. on~· Computes the same values as map and maplist but nconcs these values t~ form a list which it returns.mapfnl.e. maplist compiles open.mapfn2) Computes the same values as mapc and mapcnr. maplist[mapx.Identical to map.1p would compute: and returns a list consisting of those values. mapconc[mapx. mapconc is used when there are a variable number of elements (including none) to be inserted at each iteration. i. The value of mapc is NIL.(LAMBDA (Y) {ANO (LISTP Y) Y))] will make a linear list consisting of all the 11.

new ~· £. and mapfnl[car[mapx]. the functional argument to mapconc should r~turn instead a top level copy.. in this case. it would now be ((AB DE F G) C (DE F G) (G) H I).ill: is used if mapfn2 is not supplied.4 .rnapfn1 :mapf112) applies mapfn1 to elements of mapx and returns a list of those elements for which this application is non-NIL.car[mapy]J is used to as$emble the new list. in this example. use (AND (LISTP Y) (APPEND Y)). i. mapc. et al.g. e. mapfn2[mapx) gives the new mapx. mapcar two except mapfnt arguments·· is a and mapfnl[car[mapx]. subset[(A B 3 C 4). map2c[mapx:mapy. Terminates when either mapx or !!!. the corresponding lists together.g. e. i----------------~----------------------~-------------------------~-----~-----Note that since mapconc . i. 3 Terminates when etther mapx or map2car[mapx. and is ~pplied twice on each iteration. mapfn2[mapy) the . uses nconc to string .2 subsettmapx. Note: CLISP (Section 23) provides a more 9eneral and complete facility for expressing iterative statements.mapy. (NUMBERP (CAR (FOR X IN Y COLLECT (CADR X) WHEN X)) UNTIL (NULL X)). Identical to mapc except mapfni is a function of two arguments.e. the original list will be clobbered. mapfn2 plays the same role as with map. If this is an undesirable side effect.((AB) C (DEF) (G) HI) will yield (AB 0 E F G).NUMBERPJ • (3 4)..mapfn1 :mapfn2J ~ Identical to of function are exhausted. 3 mapfn2 is still a function of one argument. is exhausted.!I?}'.car[mapy)l is computed at each interation. 11. e. is NIL.mapfn2] subset compiles open.mapfn1.g.e.

searchpdl See Section tZ.T:NIL. Li~e LAMBDA and NLAMBDA. To print a list with commas between each element and a final '·'one could use maprint[x. For example. maprint[x.• o'r"" if sep=NIL. It cycles through 1st applying pfn (or print if pfn not given) to each element of 1st.NIL:%(. every.). variables used freely by 2S· If ~ ~· 1s not NIL.%)) is equivalent to pr in 1 for lists. = T. Between each application. a function. funarg is it has meaning and is specially recognized by INTERLISP only in the context of applying a function to arguments.pfn:lispxprintflg) is a general printing function. some. where array contains the bindings of the variables on l •t the time the call to function was evaluated.. not a function itself.maprint[lst:file:left:right:sep. maprint performs prinl of !!. Mapdl. the expression (FUNARG x array) is used exactly 11.E. and x a list of the ualue of function is an expression of the form (FUNARG x array). notevery~ notany See Section 5. mapatoms See Section 5.5 . In other words. If left 1s given. If lispxprintflg lispxprinl is used for prinl (see Section 22). it 1s printed (using print) initially: if right is given it is printed (using prinl) at the end.%. Funarg function is a function of two arguments.%.

(by !• then the next application of ~ will obtain and ! resulting from the previous application of· fie. i.. function array.le. and FUNARG ··expressions are sometimes called 1 function objects' t. of Joo.. array.ad . it would 1 However..g. suppose a program wished·. -~ .._.' 5 The implementation of funarg is desc:.}!'. foo · (~ Z)))~ would By evaluating ·called be With ( FUNARG FIE array) as its seco11d argument. e.example. is called. a funarg expressi.>n can be returned as the value of a and then used 'higher up•.. 4 When a funarg is applied.o distinguish them from functions. in tl. )) and (FOO X (FUNCTION FIE (Y Z))) is evaluated. 5 For .le. since both applications of fie come from the exact same funarg object.. the stack is. is more than funarg variables. · 4 . -----------------------------------------------~~--~~---~-~-----~------~~----~LAMBDA. For example. so that tho ~· bindings contained in the array will be in force when the function.like a function. suppose foo is defined as (LAMBDA (LST FN) (PROG (Y Z) (SETO V &) (SETO Z &) . the rnapc in foo) changes the changed values of x x and If .. · it was . hence use the exact same..one application of fie. (FOO X (FUNCTION FIE instead ·. fie would obtain the rebound values . NLAMBDA. wh·ere array contained the bindings of ~ and ! (at. If foo rebound z. a~plied ·from inside of foo. 12. - Thus when fie was applied from inside .sets any ·of the variables contain.~ and ! as free yariables . modified. nnd x and fie used .' the original.6 in Section.~ ~ see. values· of and !· just a way of circumventing the clashing of For examp.c. the time foo was called). the array itself (and only the array) will be changed.rib~d 11. literal atoms which have function definitions.. computation. i f tho in a funarg expression .when.. (MAPC LIST FN) . to compute (FOO X (FUNCTION FIE)).e. when variables contained in array were no longer on the stack. and and ! bound inside 9f foo. the bindings of tho Furthermore. The bindings of .

because the value of A at the time foo is called is 0. because the value of A seen by foo is the value A had when the funarg was created inside of fie. In other words. (SETO FUM (FIE)). Example If foo is defined as (LAMBDA (X) (COND ((ZEROP A) X) (T (MINUS X))) and -. 7 . i. ~ However if fie were defined instead as (LAMBDA NIL (PROG (A) (SETQ A Z) (RETURN (FUNCTION FOO (A))))). i1.and the bindings of ~ and ! above foo would not be affected. then i f we perform (SETO A 0). and run them independently.fie as (LAMBDA NIL ( PROG (A) (SETQ AZ) (RETURN (FUNCTION FOO)))). a program can create a function object which has updateable binding( s) associated with the objoc t which last between calls to it.e . Thus by creating a funarg expression with function. but are only accessible through that instance of the maintain function. the variable bindings contained in array are a part of the function object. two For example. and the value of (APPLY• FUM 3) is 3.• the funarg carries its environment with it. different using the funarg device. the value of rum is FOO.e. instances of the same a program could random number generator in different states. i. 2. the value of furn would be (FUNARG FOO array) and so the value of (APPLY• FUM 3) would be -3.

.. ......... ·.....4 11.5-7 ·.••..MAPFfH ...•..MAPFN1... 11.••.. •'• .5-7 11. ....• -.•• ........ .. INDEX.......MAPFN2) ••.. .•..MAPFN2] • ..•....... .: LSPXPRNTFLG] ... FUf.MAPFN2] ..3 11....... :~. ••••• I FUNCTION[EXP..Index for Section 11 Page Numbers APPLY[FN..•...••.•....•...MAPFN2] .•••• MAP2CAR[MAPX....MAPFN1....3 11.6 ..•..... MAPLIST[MAPX.MAPFN1...11.. MAP CAR[ MAPX . •:• .MAPFN2] · ..1-2.. ~ .. ••..•••••• SUBSET[MAPX.•..1 11.••...•. !' ••• · functional arguments ...... •.1 11.2 11..VLIST] NL function object·s •••••• •..MAPFN2] •..•..•...••. HAPFIH . • •.•..•• MA PRINT[ LS T: FILE.MAPFr~2 l .•.. LEFT.•..•. . ••.......•.......•.MAPFN1...• .......•• MAPC[ MA·PX... MAPCONC[ MAPX .....••• •... :....•...ARG ....MAPFfH .•••. .••......•.•.•••••••••.3 H.SH ..MAPY....4 CLISP .1-Z...• ..MAPFN2] ...MAPFN1 ..•••• 11........• .•..•.4 11. MAP[MAPX.....• MAP2C[MAPX...• • ••....•.......7 11..•••••....••.•••• variable bindings •.•. ..... .•.5.1 11...•.••••....••.PFN..••. .••••.4 11...3 11...MAPFN2) •......... . MAPCOfJ[ MAPX... RIGHT ..ARGn] SUBR* ..:.... APPLY*[FN:ARGl......MAPY. 3 11:5 11..1 11.•••...:.. MAPFN 1 . ._~ ••.•••.ARGS] SUBR . .... .••..•...

4.1 + + . However. These include: 1. our design philosophy of making the stack accessible to user programs will. Storing values on an association list paired with the variable names. the stack manipulating primitives will be defin~d in a less system~dependent way. if anything. putting old values on a pushdown list.SECTION 12 VARIABLE BINDINGS AND PUSH DOWN LIST FUNCTIONS 1 A number of schemes have been used in different implementations of LISP for storing the values of variables. and restoring these values when exiting from a function. so that user programs which referente the stac~ will be more readily transportable between different implementations of INTERLISP. be generalized and improved upon. In addition. 12. first three schemes all have the property that values are scattered As of the date of this revision (October 1974).Jhcn this is completed. a major effort at BBN is nearing completion to implement in INTERLISP·10 the stack implementation for multiple environments (spaghetti stacks) described in [Bob3]. 3. Storing values on the property list of the atom which is the name of the variable. \.+ • • + + + + + . much of the material in this section wilJ be obsolet~. 2. Storing value• in a special value cell associated with the atom name. The t Storing values on a pushdown list.

The pushdown list consisting of a variable name and its value. each each pair In INTERLISP-10. An additional advantage of this scheme is that it is completely compatible with compiled functions which pick up their arguments on the pushdown Ust from known positions. The interpreter gets the value of a variable by searching back up the pushdown list looking for a 'slot' containing the name of that variable. in a paging environment would require references to many pages to determine the value of a variable. and the value in the other. with the name in one half. the variable names must also be kept.throughout list structure space. This In order to avoid this scatteritlg. occupies one word or 'slot' on the pushdown list. this is an implementation detail.g. we utilize a variation on the fourth standard scheme. Free variables work automatically in a way similar to the association list scheme. instead or doing a search. and thus secondary storage references are rarely required to find the value of a variable. that is.2 . We ~re currently consi~ering a scheme in INTERLISP-10 whereby the names of variables bciund by compiled functions would not be stor•d on th~ st~ck. but would instead b~ computable from the compiled definition~ However. would be very undesirable in our system. and possibly excessive secondary storage references. on the stack. compiled func'tiOns 'Save the names of their arguments.we place these lit v~lues on the pushdown list. The essential' point is that there be a way to associate a name wi'th the value for variables bound by either interpreted or compiled functions. usually only used for transmitting values of arguments to compiled fut1ctions. thus contains pairs. + + + + + + + 3 Currently. One advantage of this scheme is that the current top of the pushdown stack is usually in core. 12. lit Since our compiled functions savo the names of their arguments. a free lit variable may be searched for only once (e. 2 But since we want a compatible interpreter and compiler. in general. in compiled functions). . and. 3 although they do not use them to reference 2-----------------------------------------------------------------------------Also called the stack. the same as do interpreted functions. except that within a function.

and the third is called the number stack and is used for storing temporary partial results of numeric operations. provides symbolic debugging information. the second is called the control pushdown list. Tho multiplicity of pushdown lists in the actual implementation is for efficiency of operation only. and contains pairs of variable names and values. it is more convenient f~r the user to consider the push-down list as a single "list" containing the names of functions that have yet exited. and contains function returns and other control information. For example. However.variables. Thus this technique. There are (currently) 4 three pushdown lists used in INTERLlSP-10: the first is called the parameter pushdown list. and temporary storage of pointers. for a small extra overhead. consider the following definition of the function fact (intentionally faulty): 4~----------------------------------------------------·-----------------------this will change in the spaghetti system. b~en entered but not and the names and values of the corresponding variables.3 . The Push-Down List and the Interpreter In addition to the names and values of arguments for functions. 12. and allows completely free mixing of compiled and interpreted routines. free variables can be used between functions with no special declarations necessary. compiled and The names interpreted are also very useful in debugging. for they make possible a complete symbolic backtrace in case of error. information regarding partially-evaluated expressions is kept on the push-down list. minimizes secondary storage references.

The output below illustrates this by showing the state of the push-down list at the point in the computation of (FACT 1) when the unbound atom L is reached. 12.QBJ!. called.(FACT [LAMBDA ( N) ccorm ((ZEROP N) L) (T (ITIMES N (FACT (SUB1 N]) In evaluating the form (FACT 1). first function entered in this process is cond. etc. Since T is true.. This requires calling the function itimes.!.Q. The cond begins to process its After calling zerop and getting a NIL value. the interpreter begins evaluating the implicit~ following the LAMBDA (see Section 4).a!l that is the consequent of the T clause is begun (see Section 4).4 . Note that at each stage of this process. cond proceeds to the next clause and evaluates T. its arguments must be evaluated. the evaluation of the implicit E. list of clauses. However before itimes can be The first argument is evaluated by searching the stack for the last binding of N: the second involves a recursive call to ~· and another implicit fil:. and another is awaiting evaluation. as soon as fact is entered. some portion of an expression has been evaluated.

do not actually appear on the backtrace..g. e. etc. *TAIL*.a...e. both indicated on the backtrace by *TAIL*.g. However. *ARGVAL*.. those arguments not yet 111 evaluated).b. i:r Other temporary information stored on the stack by the interpreter includes the tail of a * partially evaluated implicit J!!fill!l (e.. 5 The genealogy of *FORM*'s is thus a hiJtory of the computation.e. a cond clause or lambda expression) 111 and the tail of a partially evaluated form (i. spectal functions are available for accessing these internal blips. 12. FACT(l) u. i. from cond and the interpreter. evaluating *FORM• or calling stkscan to search for it will not work. the values of arguments 111 6------------------------------------------------------------------------------Note that *FORM*.5 + + + + . are marked on tho push-down list by a special mark which the backtrace prints as *FORM*. L {in FACT} in ((ZEROP N) L) (L BROKEN) :BTV! *FORM* (BREAKl L T L NIL ((CONO ((ZEROP N) l) (T (ITIMES N (FACT (SUB 1 N) )) )) )) *TAIL* (L) *ARGl* (((ZEROP N) L) (T (ITIMES N (FACT (SUBl N))))) corm *FORM* (COND ((ZEROP N) L) (T (ITIMES N (FACT (SUBl N))))) *TAIL* ((COND ((ZEROP N) L) (T (ITIMES N (FACT (SUBl N)))))) N 0 FACT *FORM* (FACT (SUBl N)) *FfJ* ITIMES *TAIL* ((FACT (SUBl N))) *ARGVAL>11 1 *FORM>11 (ITIMES N (FACT (SUB1 N))) *TAIL* ((ITIMES N (FACT (SUBl N)))) *ARGl* (((ZEROP N) L) (T (ITIMES N (FACT (SUBl N))))) corm *FORM>11 (COND ((ZEROP N) L) (T (ITIMES N (FACT (SUBl N))))) *TAIL* ((CONO ((ZEROP N) L) (T (ITIMES N (FACT (SUBl N)))))) N1 FACT Internal calls to eval.

: 7 . *ARGn* aro usod by the backtrace to indicate the (unnamed) arguments to subrs. •. only once. in the above example. be given to itimes as its first argument after its second argument had been * evaluated. compiled functions treat free variables in a special way that interpreted functions do not. if the *ARGVAL• binding were changed. and may look up the same variable many times. 6 Also note that the *ARGl*. 7 Whenever a compiled function is ent~red. Interpreted functions "look up" free variables when the variable is encountered. names and values. In other words. 1.each free vari. .: Calls to compiled functions. indicated by •ARGVAL*. 'bindings! ·comprise the actual working. The Pushdown List and Compiled Functions . *ARGl*. A list of all free :varia~les is ·genera~ed at. . etc. the pushdown list is scanned and the most recent binding for each free variable used in the function is found (or if there is no binding. 12. indicated by *FN*. the value cell is obtained) and stored on the stack (and marked in a special way to :. *TAIL*. *FORM•.* that have already been evaluated. are handled in the same way as for interpreted functions (hence the compatibility between interpreted and compiled functions). compiled . compile time.· . and the bindings of their arguments. functions look up . e. '. . See Section 18. i f a (lower) function changed the value of the *ARG 1111 binding.. • . Note that a function is not actually entered and does not appear on the stack. . until its arguments have been evalu~ted. 1 . However. the cond would continue interpreting the new binding as a list of cond Similarly.. and the names of * functions waiting to be called. storage. and itimes was actually called. and is in fact obtainable from the compiled definition... However.6 .able. the new value would clauses.

ions locally bound interpreted functions. an ILLEGAL STACK ARG error is generated.e. 8 else NIL.distinguish this 1 binding 1 from bindings of their arguments.. In addition differ to from i. i.2 (Section 10).e.n. a stack position is a pointer to the corresponding slot on tho control or parameter stack..7 . If pos is NIL. lambdas are called in ~ However. the search starts at position. free variable bindings. pointers to interpreted variables. (STKPOS pos 1) is used. e. them. stkpos returns NIL.pos] Searches back the control stack starting at for the nth occurrence of fn. If atom. following tho compiled functions store on the pushdown list pointers to the bindings for each free variable used in the function.p. 1 is used. for all pushdown list ~ functions. and its type is. if pos is not found. i. ordinary bindings).. Pushdown List Functions NOTE: Unless otherwise stated. Thus. is a is an In this case.· It prints as an unboxed number. #32002. stkpos[fn.e. wh(ln and open lambdas are merged into the functions that contain the variables bound by them are stored on the stack in tho conventional manner so that functions called from inside them can reference the variables freely. Returns position of that fn if found. a-----------------------------------------------------------·-----------------current1y. the address of that cell. ~ position on the control stack or a literal atom other than NIL. the current stkpos[] gives the current position.. the ordinary way as fun ct ions. progs open compiled. ~ stack If n is NIL. 12. way they Whereas in compiled treat func1. and the ~ functions and open in the lambdas.

.e . can . Value of stknth is NIL. * stkname[pos] Value is the name of the function at control position.e. + also be O or negative. stknth[•10000J.pos] Value is the nth argument of the function pos. stack position. the current position is. i.. pos must be a· real stack position. i.pos] Value is the stack position of the nth function call before position pos' where n is negative.FOO] the one + before that.e.this case. stknth converts numbers to stack po$itions.8 to the first !!.FOOJ is + the value of the 'binding' immediately before tho + first argument to FOO. and stkname converts positions to function names.e. etc. sta~k ln .2 to the second. Information about the variables bound at a particular function call. etc. stkpos converts function names to stack positions. not an atom.:. In summary. stkargval[O. g If * pos is NIL. stknth[·1J is the call before stknth. + + 12. n=1 corresponds at + position + argument at pos. + s tkargval[ n . assumed.stknth[n. stkargval[ • 1 ... i. if there is no such call .g. can be obtained using the following functions: stkn·args[ pos] Value is the number of arguments bound by the function at position pos. pos. n.

For all three functions. pos may be a position on the control stack. i. · 12. stkargs[pos] Returns list of values of variables bound at pos.· stknth. The next three functions. Finally. pos can be NIL. slot.9 + . stkscan. tho search will include the arguments to the function at pos but not any locally bound variables.e. in which case the search starts with the current position on the parameter stack. and stkeval all involve searching the parameter pushdown stack. a in which case the search starts with.t] as described earlier. which is equivalent to stkpos[pos. i.. to In this case.value is the name of the nth argument of stkargname[n.e. 10 . ((ZEROP N) (RETURN L))) (SETQ L (CONS (STKARGNAHE N POS) L)) (SETQ N (SUBl N)) (GO LPJ) The counterpart of variables is also available.posJ the function at position pos. --------------------------~~-----·--------------~-----------------------------or a function name. + As an example of the use of stknargs and stkargname: variables[posJ returns list of variables bound at pos. can be defined by: (VARIABLES [LAMBDA ( POS) (PROG (N L) (SETON (STKNARGS POS)) LP (COND . evalv. a value of stkpos or. pos may also be a position on the parameter stack. and includes that position.

evalv[var. form) is eqUi valent to ret from[ pos. 'see' the stack as it currently is. otherwise l l i ·itself. In its othor words" reteval[ pos.10 e. form]] .g~. eval[form] at position ~· It is equivalent to i. stacks:· ·.e. stknth. ete:'".form] is a more general evalv. reteval[pos~form] clears the stack back to the function at position pos.value] ~ . var evaluated as of position pos. Value is the slot for that i. and effects a return from that function with vdue as its value . then value to evaluates form and returns with ~th~: next higher function. a parameter stack position.. clears the stack back to the ~unction at position pos.stkscan[var. s·tkeva l[ pos.e .• all· varjuble. 11 Finally..11-13 for description or how stkeval is implemented. stkpos. 12.) 12 ~rovided footnote form a-:-- does not ihvolve ariy ~ta~k functions.pos] returris•the·value of the atom ____. stkeval[pos. will be evaluated as of pos .2 11----------------~------------------------------------------------------------ However.. we have two functions which clear the.s evaluated in form. any functions in form that specifically ref~rence the st~ck.pos] Searches backward on the parameter stack from pos for a binding of ill· binding if found. retfrom. ": retfrora[pos.1. (Seo as· explained in . page 12.

a function of two arguments. For example.We also have: mapdl[mapdlfn. a function of two arguments.10 work. to stkname[mapdlpos] until the top of stack is reached. otherwise NIL. position) if such a position and tho Value is is found. is what is used to make stkeval. applied position to the n!ffi! of itself is the not function NIL. The Pushdown List and funarg The linear scan up the parameter stack for a variable binding can bo interrupted by a special mark called a skip-blip (see figure 12-1). and * the pushdown position itself. and another skip-blip at the top of the 12 . page 12.srchpos] searches the pushdown list starting at position srchpos (current if NIL) until it finds a position for which srchfn. Value is NIL. INTERLISP puts a skip-blip on the parameter stack with a pointer to the funarg array. When a funarg is applied. and a pointer to the position on the stack where the search is to be continued.11 1111 .mapdlpos] starts at position mapdlpos (current i f NIL). (name . mapdl[(LAMBDA (X POS) (COND ((IGREATERP (STKNARGS POS) 2) (PRINT X] will print all functions of more than two arguments. This It is also used by tho funarg device (Section 11). and applies mapdlfn. searchpdl[srchfn. to the function n!ffi! at each pushdown position. mapdl[(LAMBOA (X) (ANO (EXPRP X) (PRINT X)))] will print all exprs on the push-down list.

funarg array pointing back to the stack. setting a variable whose binding is contained in the. Note however that as. . Similarly.this implementation. like it has a patch. the . '1·· 1°2.. •"·.ray will.·' ·i' : '.sed recur.12 . change only the array. ~ '·. .sively. be seen -before those The effect is to make the stack look The names and values stored in the funarg array will thus high~r .qn ·the stack.stance of a Junarg object cannot be u.a consequ·ence Qf.. ..1funarg ar.same in..

13 FUNARG ARRAY .USE OF 1 SKIPBL1PS 1 PARAMETER STACK PARAMETER STACK • 9 C!I Ill 0 111 NM VAL VAL NM NM VAL NM VAL SKIP NM VAL NM VAL (ii Ill> NM • VAL NM KIP NM NM • VAL ARGUMENTS TO STKEVAL VAL VAL BEGIN EVALUATION OF • • • • STKEVAL • • FORM FUNARG FIGURE 12-1 12 .

....5 12... ~ .•.....•••••• *FORM111: (in backtrace) ..•• ..... ..•..••••• INDEX •.......... SRCHPO..•••••••• *TAIL* (in backtrace) .......7 12.Index for Section 12 Page Numbers association list ....••••.........•....•... .... •••..•••••••••.....•••••.10 12...POS....•••••.: ••......10 12.••••.•..•••....••••...........F_CiRM] ·SUBR .siti«.>. ...••..4-5 12....MAPDLPOS] ••••••••••••••••••••••••• number stack .• . pushdown list functions ··•·i···················· RETEVAL[POS....11 12.. • •...... S TKAR.......5 12................. free variables and compiled functions FUt~ARG .•••.•••••.......8-9 12...11· 12..••••.....•••...........3..3 12. .. *FN11t (in back trace·) ... S TKNARGS[ POS:) SUBR . .JBR ..•.N...• ILLEGAL STACK ARG implicit progn locally bound (error mess~ge) •....• MAPDL[MAPDLFN.....10 12 ...•... . • •••••••• • •.•....'..3 12......•·~······..9.7-10 12.....· •. ·· ...1-7 · 12 ..... ...11 12. ••••••••••••••••••••••• .6 12...... . ..6 12..................9 12....•........••.•.•••• ...••••.•....•....... ..6 12.....10-11 12.2.••.. variable bindings ! .•• ..•.~OSJ ··~·•···········•··············· STK_~V~L[...••.. '.-... ........•• VARIABLES[POS) ..•••. pushd~~n li~t) .......•••••.............3.....POS] •••••••••••••••••••••••••••••••••• free variables .....9 ...-..7-11 12. STKNTH[ N: POS J ·suBR .. ~ •.•• ..•.11 12 ....••••.10 12....10 12 .. •••........•.......••••••..••..................• *ARG1* (in backtrace) .. POS] .•.. ..... _.. ···... . ...6 12..G$[....1 12....••...... .•... ..••.. STKPOS[FN....••...••..... ...••• .... ·· .2.•.........11-12 12.......... VALUE] SUBR ••••••••••••••••••••••••• searching the pushdown list SEARCH PDL[ SRCHFN. · .........9 12.... ....POS J ...........S J s~ip-blip slot (on ••....···· sta·ck pq.•...•.7 12 .• ....•......n S TKAR Gl~AME[ N".........•.••...•••••••••••••••••............. vari~bles •••.....••••••....•••••••••••••....... _ .. ...••.... control pushdown list debugging .1 12..8 12....1-2 12...~·······~·······-··...... STKNAME[ PCS] Sl..7-9 12 . .. ..8 12..3 12.... 11 12......•........5 ......6 12.._~........... U. backt·race ...... *ARGVAL* (i~ backtrace) ...1.................FORM] SUBR ···········•·••••••••4•••• RE TFROM[ POS..•. parameter pushdown list pushdown list ..·.•••. .....8 12.......••.9 12.•••.•.... ......• ·• •••• • • • • • • • • • • STKARGVAf[N.1-13 12..POSJ •••••••••••••••••••••••••••••••• STKSCAN(VAR.... EVALV[VAR.....••.POSJ SUBR ···················~······· value cell .....•. ....

Then INTERLISP then passes around i. i.SECTION 13 NUMBERS AND ARITHMETIC FUNCTIONS 13. · 13. Thus. it may cause a garbage collection of large i..~-: • ·o·r·-.g..h·e"n. the "boxed number".£3.1 . large integers.. \. which is sort of like a special "cons": when a large integer or floating point number is created (via an arithmetic operatio11 or by read). it performs the extra level of addressing to obtain the "value" of the number.-~. does lots of boxes.··. .~ ~~. and 1E30 are perfectly legal literal atoms. as are 1E3 and 1.u-.e. it is necessary to distinguish between those full word quantities that represent large integers or floating point numbers.~ -i appears in a number. Note that 1000D.~~--. a floating point number.. e.d·b. INTERLISP gets a new word from "number storage" and puts the large integer or floating point number into that word.. 1000.--Fi~. 1000 is ~n integer. This latter process is called 11 unboxing 11 • Note that unboxing does not use any storage.0 General Comments There are three different types of numbers in INTERLISP: small integers.b·e-r~--~. quantity itself. but that each boxing operation uses one new word of number storage. · .~.d·~~~~~~~--.h.-. 1000F. if a computation creates many large integers or floating point numbers. 1 Since a large integer or floating point number can be (in value) any full word quantity (and vice versa). and other INTERLISP pointers. and floating point numbers. the pointer to that word.Je do this by "boxing" the number. rather than the actua 1 when a numeric function needs ..-~~.e.. the actual numeric quantity..

g. because the integer functions compile open. e.. Integer Functions All of the functions described below work on. e. eq[2000. In INTERLISP·lO. Thus. they generat~ an error. they first convert the number to an integer by truncating the fractional bits. in place of the more general arithmetic functions which allow mixed floating point and integer arithmetic. 2 Integer Arithmetic 13.3..2 .. Thus boxing small numbers does not use any storage. GC: 16. and furthermore. each small number has a unique representation.add1(1999JJ is NIL! ill or equal inust be used instead. these are boxed by integers whose absolute value is less than 1536. Unless specified otherwise.INTERLISP-10 may use different boxing strategies. or of floating point number space.integer space.8J::5. this is not necessarily always the case. e.g. 13. integers. offsetting them by Small integers are a constant so that they overlay ·an area of INTERLISP's address space that does not correspond to any INTERLISP data type. It is important to use the integer arithmetic functions. igreaterp vs greaterp.g. iplus vs plus. + + + and therefore run faster than the general ~-------------------------------~---------------------------------------------Different implementations of .1 Small Integers Small integers are those integers for which smallp is true. whenever possible. should not be used for large integers or floating point numbers. iplus[2. Note that !t9. so that !!! may be used to check equality. NON-NUMERIC ARG.3. i f given a floating point number. GC: 18. while lots of arithmetic operations may lead to garbage collections. i f given a non-numeric argument.

arithmetic functions, and because the compiler is "smart" about eliminating
unnecessary boxing and unboxing.

Thus, the expression

(IPLUS (IQUOTIENT (ITIMES N 100) H) (ITIMES X Y)) will compile to perform only
one box, the outer one, and the expression
(IGREATERP (IPLUS X Y) (IDIFFERENCE A 8)) will compile to do no boxing at all.

Note that the PDP-10 is a 36 bit machine, so that in INTERLISP-to all integers
are between -2t35 and 2t35-1. 3 Adding two integers which produce a result
outside this range causes overflow, e.g., 2t34 + 2t34.

The procedure on overflow is to return the largest possible integer, i.e. , in
INTERLISP-10 2t35 - 1. 4

iminus[x]

idifference[x;y]

x-

addt[x]

x + 1

subl[x]

x - 1

4

y

If the overflow occurs by trying to create a negative number of too large a
magnitude, •2t35+1 is used instead of 2t35·1.

13.3

iquotient[x;y]

x/y truncated, e.g., iquotient[3;2}=1,
iquotient[-3,2]=-1

iremainder[x;y]

the

remainder .when

is

~

divided by

~~

e.g.,

iremainder [3;2}=1

igreaterp[x;y)

T if x

> y; NIL otherwise

ilessp[;x;y]

T is x

< y ;.

zerop[x]

defined as eq[x;O].

NIL otherwise

.vote that zerop should not be u.sed for floating point number.s because it uses

Use eqp(x:OJ instead.

minusp[x]

T if. !
convert

is negative;
~

Does

NIL otherwise.

not

to an integer, but simply c:hecks sign

bit.

eqp[n;m]

T if n and m are
otherwise.

(!,g

!_g,

or equal

,may be used i f n and

to be small integers.)

~

numbers,

NIL

m are known

does not convert n and

m to integers, e.g., eqp[2000;2000.3]=NIL, but it
can be used to compare an integer and a floating
point number, e.g;, eqp[2000;2000.0J=T.

Q.9.£

does

not generate an error if norm are not numbers.

smallp[ n]

T if

n is

a small integer, else NIL.

smallp does

not generate an error if n is not a number.

fixp[xJ

· ·~ tf

~

is an integer, else NIL.

an error if ! is not a number.

13.4

Does not generate

fix[ x]

Converts

~

to an integer by truncating fractional

bits, e.g., fix[2.3]

111

2, fix(-1.7] = -1.

If xis

already an integer, fix(x)=x and doesn't use any
storage. 5

lambda no-spread, value is logical and of all its
arguments, as an integer, e.g., logand[7;5;6]=4.

lambda no-spread, value is the logical Q!. of all
arguments,

its

integer,

an

as

e.g.•

logor[ 1 ;3 ;9]=11.

lambda no-spread, value is the logical exclusive
or

of

its

logxor[11;5]

arguments,

an

integer,

e.g.,

= 14,

logxor[11;5;9)

lsh(n;m]

as

= logxor(14;9) = 7.

(arithmetic) !eft shift, value is n•Ztm,i.e.,
shifted left
negative.

If

m
mis

plac~s~

n

neQative,

~an

n is

be

n.

positive

shifted right

is
or

-m

places.

rsh[n;m]

(arithmetic) right shift, value is n 111 2t-m, i.e.,
is shifted right
negative.

llsh[n;m]

m places.

n can be positive or

If fil is negative, ll is

logical !eft !hift.

~

Left

-m

places.

On POP•10, llsh is equivalent

to lsh.

6--------------------------------------~------------------·---~-----~-----------

Since FIX is also a lispx command (Section 22), typing FIX directly to
lispx will not cause the function fix to be called.

13.5

lrsh[n;m]

The

logical tight !hift.

difference between a logical and arithmetic

treatment of the sign bit for negative numbers.

right shift

lies

in

the

For arithmetic right shifting

of negative numbers, the sign bit is propagated, i.e., the value is a negative
number.

+

For logical right shift, zeroes are propagated.

Note that shifting

(arithmetic) a negative number 'all the way' to the right yi&lds •1, not

o.

gcd[x;y]

and

value is the greatest common divisor of

~

e.g. gcd[72;64]=8.

+

13.2

Floating Point Arithmetic

All of the functions described below work on floating point numbers.

Unless

specified otherwise, i f given an integer, they first convert the number to a
floating point number, e.g., fplus[1;2.3) • fplus[l.0;2.3) = 3.3: i f given a
non-numeric argument, they generate an error, NON-NUMERIC ARG.

The

largest

smallest

floating point number (in INTERLISP-10)

positive

(non-zero)

floating

point number

is
is

1.7014118E38,

1.4693679E·39.

procedure on overflow is the same as for integer arithmetic.

the
Tho

For underflow,

i.e .. trying to create a number of too small a magnitude, the value will be 0.

fminus[x]

• x

fquotient[x;y)

x/y

13.6

fremainder[x;y)

the

remainder when

!

is

divided

by

e.g.,

fremainder[l.0;3.-0)m 3.72529E·9.

T if! is negative; NIL otherwise.

minusp[x)

Works for both

integers and floating point numbers.

eqp[x;y]

T if

!

z:

and

are

or equal

numbers.

See

discussion page 13.4.

fgtp[x;y)

T if

floatp[ x]

is

x > y, NIL otherwise.
!

!

if

is

floating

a

point

number;

Does not give an error if !

otherwise,

NIL

is not a

number.

Note that if numberp[x) ts true. then either ftxp[x) or Jloatp[x) ts true.

float[x]

Converts !
float[OJ

13.3

The

to a

floating

point

number,

e.g.,

= o.o.

Mixed Arithmetic

functions

in

this

section are

'contagious floating

point

arithmetic'

fun ct ions, i.e., i f any of the arguments are floating point numbers, they act
exactly like floating point functions, and float all arguments, and return a
floating point number as their value.

Otherwise, they act like the integer

functions.

argument,

If

given

a

non-numeric

NON-NUMERIC ARG.

13.7

they

generate

an

error,

minus(x]

- x

difference(x;y]

x •

y

quotient[x;y]

if

!

ancl

~

are

both

integers,

. value

is

iquotient[x;yJ, otherwise fquotient[x;yJ.

remainder[x;y]

if

!

and

~

are

both

integers.

value.

is

iremainder[x;yJ, otherwise fremainder[x;y).

greaterp[x;y]

T if x > y, NIL otherwise.

lessp[x;y]

T if x < y, NIL otherwise.

~bs[x]

! if x

> O,

otherwise -x.

abs uses greaterp and

!!l!.!!.!!!• (not igreaterp and iminus).

13.4

Special Functions6

They utilize a power series expansion and their values are (supposed to be) 27
bits accurate, e.g., sin[30J•.5 exactly.

expt[m;n]

value is mtn.
positive

+

+
+

If !!! is an

intege_r,

value

is

~ntegElr

an

and !! is a

integer,

e .g,

------------------------------------------------------------------------------In INTERL ISP-10, these functions were implemented by J. W. Goodwin by

6

"borrowing" the corresponding routines from the FORTRAN library, and hand
coding them in INTERLISP· 10 via ASSEMBLE.
.
.

13.8

expt[3;4]=81, otherwise the value is a floating
point number.

If

is negative and

~

n fractional,

an error is generated.

sqrt[ n]

value is a square root of
number.

n

may

be

n

fixed

Generates an error i f

n

is

as a floating point
or

floating

negative.

point.

sqrt[ n) is

about twice as fast as expt[n;.5)

log[x)

value is natural logarithm of
point number.

antilog[ x]

be integer or floating point.

~can

value is floating point number whose logarithm is
x.

~

can be integer or floating

antilog[l]

sin[x;radiansflg)

as a floating

~

~

point,

e.g.,

= e = 2.71828 ...

in degrees unless radiansflg=T. Value is sine of

~as

a floating point number.

cos[x;radiansflg]

Similar to sin.

tan[x;radiansflg]

Similar to sin.

arcsin[x;radiansflg]

~

is a number between ·1 and 1 (or an error is

generated).
point

The value of arcs in is a floating

number,

radiansflg=T.

and
In

arcsin[x;radiansflg]=!

is

in
other

then

degrees

unless

·words,

if

sin[z:radiansflg]=!·

The range of the value of arcsin is -90 to +90 for
degrees, -n/2 to n/2 for radians.

arccos[x;radiansflg]

Similar to arcsin.

13.9

Range is 0 to 180, 0 to n.

Range is O to 180, O to n.

arctan[x;radiansflg]

Similar to arcsin.

rand[lower;upper]

Value is a pseudo-random number between lowor and
inclusive, i.e. rand can be used to generate

~

a sequence of random. numbers.

If both limits are

integers,

the

otherwise

it

value
is a

of

rand

floating

is

point

an

integer,

number.

Tho

algorithm is completely deterministic, i.e. givon
the same initial state,
sequence of values.

rand produces

the same

The internal state of rand is

initialized using the function randset described
below,

and

is

stored

on

the

free

variablo

randstate.

randset[x]

Value is inte.rnal state of rand after randset has
finished

operating,

integers.
~=T,

lf

a

dotted

pair

of

pNIL, value is current· state.•·

two
If

.randstate is. initialized using the clocks.

Otherwise,
state,

~

is interpreted as a previous internal

i.e. a value. of randset,

reset randstate.

13.5

as

and is used to

For example,

1.

(SETO OLOSTATE (RANOSET))

2.

Use rand to generate some random numbers.

3.

(RANDSET OLOSTATE)

4.

rand will generate same sequence as in 2.

Reusing Boxed Numbers in INTERLISP·10 • SETN

rplaca and rplacd provide a way of cannibalizing list structure for reuse in

13.10

order to avoid making new structure and causing garbage collections. 7 This
section describes an analogous function in INTERLISP-10 for large integors and
floating point numbers, setn.

setn is used like setg, i.e., its first argument

is considered as quoted, its second is evaluated.

If the current value of the

variable being set is a large integer or floating point number, the now value
is deposited into that word in number storage, i.e., no new storage is used. 8
If the current value is not a large integer or floating point number, e.g., it
can

be

NIL,

floating

setn

operates exactly like setq,

point number is boxed,

i.e.,

the

large

and the variable is set.

integer

or

This . eliminates

initialization of the variable.

setn will work interpretively, i.e., reuse a word in number storage, but will
not yield any savings of storage because the boxing of the second argument will
still take place, when it is evaluated.

The elimination of a box is achieved

only when the call to setn is compiled, since

~

compiles open, and does not

perform the box if the old value of the variable can be reused.

Caveats concerning use Of SETN

There are three situations to watch out for when using setn.
when

The first occurs

the same variable is being used for floating point numbers and largo

integers.

If the current value of the variable is a floating point number, and

it is reset to a large integer, via !!.!!l• the large integer is simply deposited
into a word in floating point number storage, and hence will be interpreted as
a floating point number.

Thus,

7-----------------------------------------------------------------------------This technique is frowned upon except in well•defined, localized situations
where efficiency is paramount.
8

The second argument to
error is generated~

~

must always be a number or a NON-NUMERIC ARG

13 .11

.. (SETO FOO 2.3)
2.3
.. (SETN FOO 10000)
2 .189529E·43
Similarly, i f the current value is a large integer, and the new value is a
floating point number, equally strange results occur.

The second situation occurs when a ill!l variable is reset from a large integer
to a small integer.
large

integer

In this case, the small integer is simply deposited into
It

storage.

will

then

print

correctly,

and

function

arithmetically correctly, but it is not a small integer, and hence will not be
~

to another integer of the same value, e.g.,
.. (SETQ FOO 10000)
10000
.. (SETN FOO 1)
1

.. (!PLUS FOO 5)
6

FOO 1)
NIL
.. (SMALLP FOO)
NIL
.. (EQ

In particular, note that zerop will return NIL even if the variable is equal to
0.

Thus a program which begins with FOO set to a large integer and counts it

down by (SETN FOO (SUB1 FOO)) must terminate with (EQP FOO 0), not (ZEROP FOO).

Finally, the third situation to watch out for occurs when you want to save

~he

current value of a ill!l variable for later use.

For example, if FOO is being

used

its

by

setn,

and

the

user

wants

to

save

current

value

on

FIE,

(SETO FOO FIE) is not sufficent, since the next setn on FOO will also change
FIE, because its changes the word in number storage pointed to by FOO, and
hence

pointed

to

by

FIE.

The

number

must

be

copied,

e.g. •

(SETO FIE (IPLUS FOO)), which sets fIE to a new word in number storage.

setn[var;x)

n lambda · function like setq.

13.12

Y!! is quoted,

~

is

evaluated, and its value must be a number.

will ba set to this number.
of

~

is

large

a

that

number,

cannibalized.

If the curront valuo

integer

word

or

floating

The value ·or

setn

point

storage

number

in

vnr

is

the

is
(now)

value of Y!!:·

13.6

Box and Unbox in INTERLISP-10

Some applications may require that a user program explicitly perform the boxing
and

unboxing operations that are usually implicit (and invisible)

programs.

The

respectively.

functions

be

perform

these

operations

are

loc

vnu

and

For example, if a user program executes a TENEX JSYS using the

ASSEMBLE directive,

to

that

to most

the value of the ASSEMBLE expression will have to be boxed

used arithmetically,

e.gop

(lPLUS )( (LOC (ASSEMBLE •

0

))).

It must

be

emphasized that

Arbitrary unboxed numbers .should not be passed around
because they can cause trouble for the garbage collector.

as

ordinary

values

For example, suppose the value of! were 150000, and you created (VAG X), and
this just happened to be an address on the free storage list.
collection could be disastrous.

The next garbage

For this reason, the function vag must be used

with extreme caution when its argument's range is not known.

loc is the inverse of vag.
treats

It takes an address, i.e., a 36 bit quantity, and

it as a number and boxes it.

For example,

loc of an atom,

e.g.,

(LOC (QUOTE FOO)), treats the atom as a 36 bit quantity, and makes a number out
of it.

If the address of the atom FOO were 125000, (LOC (QUOTE FOO)) would be

125000, i.e. the location of FOO. It is for this reason that the box operation

13.13

is called loc, which is short for location. 9

Note

that FOO does not print as !11364110 ( 125000 in octal) because the print

routine recognizes. that it is an atom, and therefore prints it in a special
way,

i.e.

by

printing the individual characters that comprise

(VAG 125000) would print as FOO, and would in fact be

loc(xJ

Makes

a number

location or

out

~

of vag is the unbox of'
The

compiler

eliminates

extra

Thus

returns

the

FOO.

i.ei,

The inverse of !Qs.

vag(xJ

of

it.

vag's

must be a number; the value

and

for

example

(IPLUS X (LOC (ASStHBLE ··))) will not box the value of the ASSEMBLE, and then
unbox it for the addition.

--------------------------------·---------···········-·····-·····-------------vag is an abbreviation of ~lue .set.

9

13 .14

Index for Section 13

Page
Numbers
ABS[X]

............••....••...••.••.••••••••••.••

ADDl[X]

......................................... .

ANTILOG[ X] .......................•.•..........•.
ARCCOS[X;RADIANSFLG] .......•..........•..•.•..••
ARCCOS: ARG NOT IN RANGE (error message) ...•..••
ARCSIN[X;RADIANSFLG] .....................•...•..
ARCSIN: ARG NOT IN RANGE (error message) .....•..
ARCTAN[X;RADIANSFLG] ....•.•......•..........•...
arithmetic functions .......•.........•.........•
ASSEMBLE
.•.•...••....•...•.•....•••••.••••.•••••
box
............................................ .
boxed numbers
.......•.......•.........••........

boxing

......................................... .

COS[X;RADIANSFLG] ........•......••..•...•..•....
DIFFERENCE[ X; Y) ........•..•...•..•.•....••......
EQP[

x: Y]

SUBR

EQUAL[ X; Y]

•.••.•..••

I

••••••••••••••••••••••••

..•..••...•..••••.•.••••.••••••.••..••

EXPT[M;N]
....................................... .
FGTP[X;Y] SUBR
.•.••.••••••.•••..••••••••••••••••••

FIX[X]
......................•......•.............
FIXP[ X]
......................................•..
FLOAT[X]
....•...........•••..••••••..••.•.••.•••

floating point arithmetic .•..••...••..•...•...••
floating point numbers ..••.••.••.•...•••••.....•
FLOATP[X] SUBR ........•••..•....•.•.......•••.••.
FMit~US[

X]

.••••••••••••••••••••••••••••••••••••••

FPLUS[Xl;X2; ... ;Xn] SUBR* •.......•..•••••.....•.
FQUOTIEIH[X;Y] SUBR ...•.•. ; ...•....••..•...•.•••
FREMAINDER[X;Y] SUBR ..•..•...•.•••••.••...••••..
FTIMES[Xl;X2; ... ;Xn) SUBR• ...••.••..•.••..•••.••
GCD[X;Y]

....•.•...•..•••••••••••••.••••.••••••••

GC: 16 (typed by system) •.•..••..•.•••••..•••..•
GC: 18 (typed by system) .•.•.••.••.•••.•...•.•••
GREATERP[X;Y] SUBR .......•.....•••..............
IDIFFERENCE[X;Y] ························~·······
IGREATERP[X;Y) SUBR .....•...•.•...•...•.•.•....•
ILESSP[X;V]

........•.•.................••..•••..

ILLEGAL EXPONENTIATION: jerror message)
IMif4US[X]

....••..•

.............••..••.••••.....••.•••••••

integer arithmetic ...•.•••••.••.••••••.••..•••.•
IPLUS[Xl;X2; ... ;Xn] SUBR• •••••••••••••••••••••••
IQUOTIENT[X;YJ SUBR .•....•..••••••••.•••••••••••
IREMAINDER[X;YJ SUBR .•..••..•••.••••••••..••.•••
ITIMES[Xl;X2; ... ;Xn) SUBR* ..•••••..•......••....
large integers
LESSP[X;Y]

................................. .

..........•••.•...••.••••.•.••••..••••

LLSH[N;M] SUBR

......•...••.•...•...•.•...•.•••.•

LOC[ X] SUBR
.............•..••..••..••.••.•.•..••
LOG[X]
..................••.•..•....•••••••..••••

LOGAND[Xl;X2; ... ;Xn) SUBR* •....•....•••....••.••
LOGOR[ Xl; X2; ... ; Xn) SUBR* ••...•.......••••••••.•
LOG XOR[ Xl; X2; .•. ; Xn) SUBR* •.•.•.•••••.••.•.••.••
LRSH[N;M]

........•.••..•••.••.•••..•.••.•••.••••

LSH[N;M] SUBR

...••.•.•••••.••.•••••.•••.••••••••

Mlt~US[X] SUBR

..•..•.•..•••••..••••••.•••••••••.•.
••..•••••.•.•••.••..••••.•••..••.•

MINUSP[X] SUBR

INDEX .13 .1

13.8
13.3
13.9
13.9
13.9
13.9
13.9
13.10
13.2·10
13 .13
13 .13
13.1
13.1,3,10-11,13
13.9
13.8
13.2.4,7
13.2
13.8
13.7
13.5
13.4
13.7
13.6-7
13.1-2.4, 11
13.7
13.6
13.6
13.6
13.7
13.6
13.6
13.2
13.2
13.8
13.3
13.4
13.4
13.9
13.3
13.2•6

13.3
13.4
13.4
13.3
13.1-2,11
13.8
13.5
13.13-14
13.9
13.5
13.5
13.5
13.6
13.5
13.8
13.4,7

Page
Numbers
mixed arithmetic
NON-NUMERIC ARG (error message)
numbers
overflow
PLUS[X1;X2; .;Xn] SUBR*
OUOTIENT[X;Y] SUBR
RAND[LOWER;UPPER]
random numbers
RANDSET[X)
RANOS TATE

REMAINDER[X;YJ SUBR
RSH[N;M]
SETN[VAR;X] NL
SIN[X;RADIANSFLG]
small integers
SMALLP[NJ
SQRT[ NJ
SORT OF NEGATIVE VALUE (error message)
SUBl[X]
TAN[X;RADIANSFLG]
TENEX
TIMES[Xl;X2; ... ;Xn] SUBR*
unboxed numbers
unboxing
VAG[X] SUBR
• • • • • '!
ZEROP[X]

.....

....

JNDEX.13.2

.....
.. ..

......

13.1·8
13.2,6-7
13.1-14

13.3,6
'13. 7

.....

..... ...

..........
...........

13.8
13.10
13.10
13.10
13.10
13.8
13.5

13.10-13
13.9
13.1-2
13.2,4
13.9
13.9
13.3
13.9
13 .13
13.8

13 .13
13.1,3,13
13 .13-14

13.4

SECTION 14
INPUT/OUTPUT FUNCTIONS

14. 1

All

Files

input/output functions in INTERLISP can specify their source/destination

file with an optional extra argument which is the name or the file.

must be opened as specified below.
value NIL).

This file

If' the extra argument is not given (has

the file specified as "primary• for input

Normally these are both T, for terminal input and output.

(output)

is

used.

However, the primary

input/output file may be changed by
input[ file J1

Sets !.!.!! as the primary input file.

lts value is

the name of the old primary input file.
input[] returns current primary input file, which
is not changed.
output[ file J

Same as input except operates .on primary output
file.

Any file wh.tch is made primary must ha11e been previously
input/output. except Jor the Jile T, which ts always open.

opened

for

i-----------------------------------·-----------------------------------------The argument name file is used for tutorial purposes only. Subrs do not
have argument

•name~per

se. as described in section 8.

14 .1


file without changing the primary input file. as input[file]. TENEX~ when· a file is the highest version number is used. Similarly. if!!!! iS already open for input. file is already open for output. e. for all input/output functions.. Consistent with opened for input and no version number is giv~n. same Generates a FILE WON'T OPEN error if f. 2 The value of infile is the previous primary input file. 3 The value of outfile is the previous primary output file..e.!!! is already open. If f.Opens f.. can contain al t·modes or control· F's. If !!!! is already open. and can include sUffixes arid/or version riumbers. Opens file for output. same as output[file]. changing the 14.2 primary output file. and sets it as the primary in file[ file J input file. i. regardless of the file name given to the INTERLISP function j---------~---------------------~------····-----------------------------------To open .!!! won't open. file follows the TENEX conventions for file names.. a new file is cr~ated with a version number one higher than the highest one currently in use with that file name.. perform input[ infile[ file]]. and sets it as the primary outfile[ file] output file.g. when a file is opened for output and no version number is gi~en.g. e. perform . fi!! can be prefixed by a directory name enclosed in angle brackets.!!! for input. · Generates a FILE WON'T OPEN ·error if f.!!! won't open. In Il\fTERLISP-10. 3 To open file without output[outfile[file]]. In INTERLISP-10.

g. 1. entire Also. via infilep or outfilep. it is possibh for a file name that was previously recognized to become ambiguous. for example. indicated operation.from.does recognize the file.that opened the file. Whenever a file argument is given to an i/o function...return NIL. "recognize" the file. it is considerably more efficient to obtain the full file name once. FOUND error is generated. INTERLISP opens the file and stores its (full) name in the file table. a it Then. Then the user types control-C. by TENEX is performed on the user's even if only one file is open. 1. and then executes the corresponding operation. say FOO. INTERLISP·lO must c•ll TENEX to recognize the name. F$ (F altmode) will not be recognized if the user's directory also contains the file FIE.prsssions from FOO. Now a call to read giving it FOO as its file argument will generate a FILE NOT OPEN error. :1.. outfilep and ~· 14 . Thus if repeated operations are to be performed. or written to or read . e. . INTERLXSP maintains only full TENEX file names 4 in its internal table of open files and any function whose value is a file name always returns a full file name. Thus. opening FOO.g. creates a FOO.Z and reenters his program. 5 If TENEX . FILE NOT INTERLISP executes the appropriate TENEX JSYS to If TENEX does not successfully recognize the file.3. returns to INTERLISP the full rile name. note that recognition directory. JNTERLISP can continue with the If the file is being opened. . INTERLISP first checks to see if the file is in its internal table. Note that each time a full file name is not used.3 which in this case . and reads S1Bveral e:<. If it is being closed.2. a program performs infile[FOO]. because TENEX will recognize FOO as F00. INTERLISP checks its interMl table to rraake. Similarly. e.. If not. sure the file is open. openp[FOO]=F00. 5 except for infilep.

or change the primary Jiles1 they are pure predicates. i.I.e. closef(file] Closo file.e.4 Value is a list . in input context. version number i. the highest if no version number is returned. is Recognition is in INTERLISP-10. 1t returns the name of that f :. 14. outfilep( rue J to Similar except infilee. if other than Failing that. in version number is given. close the terminal. given. FILE NOT OPEN.le. close~ If i t either of the primary files. of the files closed. If it closes any file. Generates an error. infilep and out!ilep do noi open ang Jiles. output context. it resets that primary file to terminal. is in if no a version number one version number is returned.!! if is recognized as specifying the name of a file that can * be opened for input.!. closealH] Closes all open files (except T). if !!!! not open. the full file name will contain a directory field only if the directory differs from the currently attached directory. it attempts to close the output file if other than terminal. In INTERL1SP·11).inf ilep[ file l Returns full file name of f1!! !. higher than highest the recognition INTERLISP-10. primary If primary !!!! input is NIL. Failing both. it returns NIL. NIL otherwise. it attempts to file.

6) otherwise NIL.oth ~ input is and output. since in order to get to the nth element you have to sequence through the first n-1 elements. but a list is not. value is file (full name) if open either ror reading or for writing. thereby allowing a piogram to treat a file as a large block of auxiliary storage which can be access randomly. i. This section describes a function which can be used to reposttton the file pointer. value is file if open for corresponding type. an array is randomly accessible. Addressable riles For most applications.openp[ file. 6 For 6---------------------•••-•••-••••a••••••••••••••••••••--•••••-••-••••••••••••• Random access means that any location is as quickly accessible as any other. files are read starting at proceeding sequentially. value is file i f open for b. For example. Note: the value of recognized.e. ~ ~ h . files are written sequentially. ex~luding T. their beginning and the one immediately Similarly. op0np[J returns a list or ell files open for input or output. If ~ is INPUT or OUTPUT. (See iofile. type) If ~=NIL. - 14.NXL H file is not does not generate an error. page 14. Le. the next character read h following the last character read.5 . and that this file pointer is automatically advanced after each input or output operation. A program need not be aware of the fact that there is a file pointer associated with each file that points to the location where the next character is to be read from or written to. ~ is Otherwise value is Nil. If BOTH. otherwise NIL.

f. i.. 8 ln this case. which can later be written into. 14. part of' B will be clobbered. an END OF FILE error occurs. highest version number. and the program attempts to overwrite A with expression C. the file "grows.. which is 200 characters long. files can be enlarged. ln other words.6 . This can be achieved via the function iofile described below... if the file pointer is positioned at the end of a file and anything is written.-·th-. random file input or output can be performed on files that have been opened in the usual way by in file or out file. the file is enlarged. and then reading an expression from a specified point in its mtddle.~~d output. Note that this enlargement only takes place at the end of a file.e." It is also possible to position the file pointer beyond the end of file and then to write. unlike arrays. However..~~. and expression B at 1100... it is not possible to make more room in the middle of a file. Does not change either primary input or primary output..lli.example. is given.--o·p·e~·-f~~ --.. one application might involve writing an expression at the beotnntno of the file.. and a "hole" is created. default Value is is same If no version number as for infile.. However. 7 A file used in this fashion is much like an array in that it has a certain number of addressable locations that characters can be put into or taken from. 8 If the program attempts to read beyond the end of file.-ft i~--b..-. iofile[ file) Opens file for both input and output. if expression A begins at positon 1000. 7· -.~~ ~.-i~~~-t.-~~~~~'i~--..u·i. for example.i-..

the value is the address of the first character after the sequence of characters corresponding to ~· stariing address of the sequence. but nchars only counts it as one.skip.e. since end-of-line in INTERLISP-10 is represented as two characters in a file.-1] will set the file pointer to O.20000qJ. instead of the ln either case. Thus. and goes to end (or if end=Nil. either by outfile.start.to If address=NIL. address=·i corresponds to the end of file . Thus. If a file is opened for both reading and writing.100000q] (see page 14.7 . Goodwin. even if a version number was specified and the corresponding file already exists..-1) will set it to the end of the file. Note that one can also open a file for appending by openf[file. to the end of file). W. 11 filepos was written by J.address) §ets file £Oin!e! for file to address.file. TENEX assumes that there might be material on the file that the user intends to read. a write will automatically add material at the end of' the file. end the search is successful. and an sfptr is unnecessary. i f a file is opened for output only. address Value is of start of match. ln this case. 10 Note: in INTERLISP-10. skip can be used to specify a character which matches any character in the file. i. TENEX assumes that one intends to write a new or different file. but sfptr[file. filepos[x. either by iofile or openf(file. However. Thus. the initial file pointer is the beginning of the file. Searches file for ~ a la strpos (Section Search begins at start (or i f start=NIL.tai1J 11 10). .end.300000q].8). sfEtr returns the current value or file pointer without changing it. 9 Value is old setting. the current position of file pointer). 0 is the address of the beginning of the file. the file pointer right after opening is set to the end of the existing file. g--=------------•-•••--•-•---••a••••••••-m•••-•~••••~o•G•••--••-••••-•••o-•-••a The address of a character (byte) is the number of characters (bytes) that precede i t in the file. or NIL H not found.sfptr[file. the user should be careful about computing the space needed for an expression. or openf[file. sfptr[file. H tail is T. 14.

This results in a more efficient call to openf. openf permits opening a file for read. switching byte sizes. ~ is a number whose bits specify the access and mode for file. which is then interpreted as JFN. 14. The first argument to openf can also be a number. 12 openp will work for files opened with openf. i. e.e. and does not check whether the file is already open • i. ~ corresponds to the second argument to the TENE'X JS\'S OPENf' (see JS\'S Manual).x) opens file. write.8 . Openf ~ The following function INTERLISP•lO for specialized file is available in applications: openf( file . and allows specification of byte size. Value is full name of file. execute. openf does not affect the primary input ~r output file settings. the same file can be opened more than once.e.g. and can be signficant if the user is making frequent calls to openf. a byte size of 36 enables reading and writing of full words.e. i.the file is left so that the next i/o operation begins at the address returned as the value of filepos. etc. or append. possibly for different purposes .

00) (MOVE 1 . 2)] or to read a byte from a file [ DEFINEQ (BIN (LAMBDA (FILE) (LOC (ASSEMBLE NIL (CQ (VAG (OPNJFN FILE))) ( JSYS 5. 1) (CQ (VAG (OPNJFN FILE))) (POP NP . and in somewhat more detail in the TENEX JSYS manual. Xt is an integral part of U10 TENEX file system and is described in [Muri].1 ':.> JFN functions in lNTERL!SP·iO-v JFN stands for job f:!. tha following functions &ra available for direct manipulation of JFNs: returns the JFN for opnjfn[file] ~· H file not open. Example: to write a byte on a file [ DEFINEQ (BOUT (LAMBDA (FILE BYTE) (LOC (ASSEMBLE NIL (CO (VAG BYTE)) (PUSH NP . 14. 2) Naking BIN and BOUT substitution macros compiled code.umber. generates a fllE NOT OPEN error.9 can uve boxing and unboxing in a .la n. In INTERLISP·lO. 2) (JSVS 510) (MOVE 1 .

gtjfn(file. ac3 is either NIL. converts.E!. flags is as described on page 11. le name as would .. rljfn[jfn] releases jfn. file and ill may be strings or atoms. meaning format the f':I. Jfns(jfn. the value is returned as a string.flagsJ sets up a 'long' call to &TJFN (see JSYS manual). or other INTERLISP-10 file functions.v. 10 ac3 In to this . m is the default extension. or else is a number.ac3] Value of rljfn is T. enough The value of jfns is atomic except options are exceed atom size (2. Value is JFN. ~ the default version (overriden i f file specifies extension/version. section 2 of JS\'S manual.ext.2). 14. y and flags must be numb-ers. case. 100 specified by characters).Q. meaning format according to JSYS where manual. file is a file name possibly containing controlmF and/or alt-mode. FOO. rljfn[ • 1] releases all JFN 1 s which do not specify open files.g. e.:!!!! (a small number) to a file name. or NIL on errors.COM.!lE.

Control-A will not backup beyond the last carriage return. %control-A) is the atom terminal. the primary input file will be used. IJ !JJ. on input from Jiles. On input from terminal.11 . and an (optional) argument rdtbl. JNTERllSI' will ech'o a line-feed whenever a carriage-return ts input. the atom AB(C. readtables are described on page 14. are delimited by the break and separator characters as defined in rdtbl.24. For all input functions except readc and peekc. i.2 Input Functions Nost of the Ju'nctions described below have an (optional) argument . e.· all input junctton. e. input will be taken from that .st carriage-return~. + + + + . erase the entire line back to the la. %tA (i.!:. To ioput an atom which contains a break or separator .rdtbl:flg] Reads one s-expression from Atoms file. tVC ror character the + by + control·C~ 14----------------------------------------------------------------------------Note that the CHAROELETE and LINE DELETE characters can be . is i\lll. ~haracter.g.A.redef illed or disabled via setsyntax.fJJ.. If rdtbl ts Nil. control-A erases the la. END Of Fll£. When reading from a file.s a string. read(file..21. the primary readtable will be used.s close the file and generate an error. when reading from the terminal. For input from the containing an interrupt character can be input by typing instead corresponding alphabetic preceded control-V. an atom . AB%(C. see page 14. and an end of file is encountered. which specifies the readtable to be used for input. which specifies the name of· the Ji le on which the operation is to take place.!!. Accordingly. end•oJ-line is indicated by the characters carriage-return and line-feed in that order.string (and the string pointer re.st character typed in.g.e. 14 .set accordingly>. %% is the atom %.e. Typing control-Cl causes l1VTERlISP to print #JI! and clear JJe input buffer. IJ the file argument i. echoing a \ and the erased character. l1VTERLISP-10 will skip all line-feeds which immediately follow carriage-returns. character by the h esc~pe charact~r precede the %.14. 1Vote: in all liVTERllSF'-10 symbolic Jiles.

'When reading f[l'm the terminaC all input i. i. rdtbl] Reads in one atom from file. . i. However.erminal.!!. 1E3 reads as a floating 103 as a literal atom. INTERLISP al. printed~ page 14.12 Separation of atoms .e . e.e. Thu.g. If an atom is interpretable as a number..s the . the effect i.seen by the pro{jram until a carriage-return i. the user does not have to type the carriage return himself. 36. !!S=T suppresses the typed by following read parenthesis.ame The· integer.s is encountered. number. e.!:!. To input a string containing a double quote or a %. e. 1.· when a matching right parenthe.!!.si.e.!Q will create a number.g.0 as a literal atom. 1.) * ratom[ file.0 as a Note that an integer can be inp1.s typed. the characters are still giVen to .1t in octal by terminating it with a Q.so print. Jot reading by!. 170 and 15 read in as the s. carriage-return a normally matching right (However.s are actually .till • i. %A"B%C is read as ABC. with or without Q's. •ABX"C" is the string AB"C. e.same a.Strings are delimited by double quotes.s a carriage-return Hne-Jeed on the t. 14 . setting of ·determines how integers are radix.s though a carriage return wete typed. To indicate thi.g.g. the characters are transmitted.s line-buffered to enable the action of control-Q . etc.s.s no character.. point number. Note that % can always be typed even if next character is not 'special'.!!. precede it by %.

lf the characters normally be comprising inter~reted the atom as a number by read. rstring[file.rdtblJ Reads in one string from file. Q. control-Q. 1\lote seen ratoms[a.is defined by rdtbl. setbrk[lst.!!Q!!! never makes a string.rdtbl] . !. % is also an escape character for ratom. but remains tn the buJJer to become the first character by the next reading Junction that is called. control-V.13 is read. 11 however whether i. Ill .!!£m repeatedly until the atom ! Returns a list of ~toms read.e. Value is NIL.!separator characters for rdtbl. not including !· setsepr[lst:flg. that number is also returned by ~· Note that rill!!! takes no special action for or not would it is a break character.flg. and line-buffering also "' apply. Control-A.rdtbl] Set brea~ characters for rdtbl.file.§!.rdtblJ Calls !:. Value is NIL. and the remarks concerning control-A. terminated by next break or separator character.om or rstrino is not read by that call. 14 . and % have the same effect as with 0 lli2!!!· that the break or separator character that terminates a· cal L to rat. control- control V.

setbrk[ ( .. this provides an Characters specified by setbrk wili delimit atoms. The elements of !il may also be characters. 14.• . • )] has the same effect in INTERLISP-10 as setbrk[(46 44)). For .!:. and be returned as separate atoms themselves by * delimit Characters specified by setsepr will ~· atoms.e. •. and are otherwise ignored. i. s. the break/separ~tor characters are reset to be. then the characters are reset to those in the original system table. S. For more details.· those in the . + Note: L ).2. DEF. see discussion in section on 14~25-26.For both setsepr and setbrk.9 will be interpreted as character codes because they are numbers. making these characters be break characters when they already are will have no effect. 17 + readtables. and " are normally break characters. system's readtable for terminals. N~t• however that the 'characters' 1. regardless of value of flg. If rdtbl t. (. + + + If any of these break 17 However. the input stream if serve only to $ was a break ABC*~DEFSGH*SS read by 6 calls to ··. character and * a separator character. + its special action for read will not be restored by simply making it be a break + character again with setbrk. would be GH. ·will be returned as· + sepal"'ate atoms when read by ratom.s T.!l2!!! returning respectively ABC. setbrk[TJ is equivalent to setbrk[getbrk[T]]. :It reset break/separator characters to i.9 determinos the action of setsepr/setbrk as follows:· :It NIL clear out indic•ted readtable and be those in lst.e. ].g. O clear out only those characters in !!! · unsetsepr and unsetbrk. + disabled by an appropriate setbrk (or by making it be a separator character). e. page + ---------------------·----·-··----------------------------------~------·---~--16 If lst=T. S. ~is a list of character codes. 16 I!. Le. example. + + characters are .14 . 1 add characters in lst.

getsepr[rdtbl) Value is a list of separator character codes.g. NIL otherwise. readc --------------------·-----·--·-··--·-----------·--····-·····-·-·····-·-···----escape does not currently take a readtable argument. ratest returns T if a separator was encountered immediately prior to the last atom read by !.e. including %. readc( file) Reads the next character.15 + + . of ~ " ' etc. or • Action * is subject to line-buffering. 14 . escape[ flg J If f. e. separator. If ~ = 1. If ~ !!12fil = NIL.!!S! or .!a=NIL.!12!!!• NIL otherwise. i. but will probably do 18 so in the near future. The value of escape is the previous setting. ratest returns T if last atom read (by !. as described below. 18 Normal setting is escape(T]. getbrk(rdtbl) Value is a list of break character codes. i.12!!!) contained a % (as an escape character. makes % act like every other character for input. is not affected by break. To defeat the action of% use escape(]. ratest[x) If is = T. Value is the character. ratest returns T if last atom read by or ~ was a break character.!:!. %( or %A%8%C). NIL ottierwise..e. escape character.Note that the action of % is not affected by setsepr or setbrk.

if control-A. and so readp returns NIL. ~eekc waits until the line has been terminated before ·returning its value. flg] Value is the next character. control-Q. However'.will not return a value until the line has been terminated even U' a character has been Thus.a=T.e.£ will return them as * values. perform their and usual editing functions. ratom. be able to controlo..fl. For most applications. the input buffer will contain a single EOL chara.cter left over from a previdus input. ratoms.s input i. 19 Note that because 19----------------------~-----------------·-----------------------------------Frequently. control·Q. readc all wait for input if there is none. but does not actually read it. i. The only way to test whether or not there i. lastc[file] Value is lastfharacter read from!.34). and typed. if .!. it returns a value as soon as a character has been typed. 14 . i. peekc is riot subject· to line-buffering. In addition. i.Q. peekc.M!=NIL. This means control·V will that control-A. readp will also return T in this case. control-A. control-V will l r control[ T] has been executed (page 14.!!· Note: read. defeating line-buffering. have their usual effect. readc will return a value as soon as a character is typed. or control•V are typed.e. If f. flg l * Value is T if there is anything in the input buffer of file. peekc[ file. this situation wants to be treated as though the buffer were empty. readp[ file. NIL otherwise. will return T i f there is any character in the input buffer.9.e. !:!!. remove it from the buffer. If f!2=T.16 .s to use readp.

readline[rdtbl)2 0 reads a line from the terminal. e. whatever that may be. 14. readline performs (APPLY• LISPXREAOFN T). read --· using until it encounters either: (1) 21 a carriage•return (typed by the user) that is not preceded by any spaces.24. lispxreadfn is initially READ. e.17 . A B CJ and readline returns (A B C)22 ( 2) a list terminating in a • ) '.g. readline actually checks for the EOL character. (3) an unmatched right square bracket. but the user should consider it as a function of one argument. as described in Section 22. If readp[TJ is NIL. e. but ~ may still have to wait.of line~buffering. in which case the list is included in the· value of readline. reade may return T.g. 21 Actually. can be redefined with setsyntax. A B CJ 20---------------------------------------------~---DD•G~~---------------------- Readline actually has two extra arguments for use by the system. Otherwise it reads readline returns NIL. 22 Note that carriage-return. the EOL character. A B (C OJ and readline returns (AB (CD)). page 14 . indicating there is input in the buffer. which parentheses 1~ or right not included in the value of readline. The same is true for right parenthesis and right bracket. Le.g. returning it as a list. expressions.

In this case.!:. 14 .rereadstringJ2 4 is a skip ~ function. It moves the file pointer for file ahead as if one call to read had been performed. paren-count.g. rereadstring should be the material already read (as a string). and skread operates as though i t had seen that material first. ABC J ••• ( D-E F) ••• (X Y ZJ and readline returns (A B C (DE F) (X Y Z)).18 lt always uses filerdtbl for 1 ts . etc. readtable.is for the case where the user has already performed some ~·s and . or a list is terminated with a ')'. A B C_J and readline returns (A B C) "' Ill 24 skread was written by J.. .!lQ. set up properly. 23 e.and readline returns (ABC). w. Goodwin. . skread[file.m's before deciding to skip this expression. the line will terminate e.. compute cost without paying the to really read in storage the and structure. In the case that one or more spaces precede a carriage-return. 23----------------------------------------------------------------------------l f the user then types another carriage return. rereadstring . readline will type ' ' and continue reading on the next line. double-quote thus getting its count.g.

using ~· Both prinl and pr1n2 print lists as well as atoms and strings.-Tiii primary readtabl e will be used.st of the Junctions described below have an (optional) argument . which specifies the readtoble to be used for output. %] H terminated on an unbalanced %].s otherwise .file. carriage-return appearing in the description oJ rm output. prin2 is used for printing S-exprassions which can then INTERLISP be read back into with read i. If ~=8. prinl[x. llnles.!f!.19 ~ tt i:> .3 have closed Gny :!. extant thing the read one which open left otherwise the value of skread !$ NIL. If ~ is A1Il. 1 () 1 and separator is printed as prin2 prints a g after integers but print does not (but both print the integer in octal). which specifies the name oj the file on which the operation is to tak.e.. e. Output Functions No. also would par~ns. Some of the functions have an (optional) argument rdtbl.g.rdtbl) prints 15 on file with %1 s and 111 s inserted where required for i t to read back in properly by read.. the atom %(%) by prin2. Junction means carriage-return and li.e place.ne-Jeed. 1Vote: in all H'TERllSf'-10 symbolic Jiles.e.stated. (PRINI (QUOTE%[)) might be used to print a left square bracket (the % would not be printed by print).The value of skread is %) H the first encountered was a closing paren.ti1.sed.file) prin2[x. e. 14.g. the primary output file will be u. print is usually used only for explicitly printing formatting characters. end·oJ-line is indicated by the characters carriage-return and line-feed in that order. 14. If rdtbl is iiJll-. break characters in atoms will be preceded by %'s.

pointer.sentation of the addre. it will read in a. rr spaces.s.s #N. print[x] would print 3. ~ = (A (B C (D (E F) G) H) K). If printlevel is negative. or numbers.s.20 . its value is NIL. all lists will be printed as&.s of radix). print. value is old setting. Note that thi.s other than li.st. (A (B C & H) K). even while INTERLISP is 14. in correctly.file] Prints terpri[ file] Prints a carriagemreturn. Print level The print functions print.which will be Below that level.s.rdtbl] Prints the S·expression ~using a carriage-return line-feed.s. printlevel[J gives current setting.s will not read back.s the octal repre. where N i. (A (B C (0 & G) H) K).. and if E ~ Then if Uc Z.s of the pointer (regardle. ar~ printed a. The variable printed. pr1n2.string.file. just &. atom. the action is similar except that a carriage·return is inserted between all occurrences of right parenthesis inunediately followed by a left parenthesis. The printlevel setting can be changed dynamically.print[x. and if rr 5 0. and prin2 are all affected by a level parameter set by: printlevel[ n] Sets print level to U• Initial value is 1000. t.e. its value is NIL.s the atom 'IN'. .. followed by Its value is ~· For all printing Junctions.s. spaces[n. Suppose n controls the number of unpaired left parentheses.

• typing will cause the list to be terminated. 26 If the print routine is currently deeper than the new level. except that characters cleared from the output buffer will have been lost. 27 Readtables and terminal tables were designed and implemented by D. control-PO. If a period is used to terminate the printlevel setting.e. the change is permanent and the printlevel is not restored (until it is changed again). clears the output buffer. 28 In INTERLISP-10. A readtable 25----------------------------------------------------------------------------As soon as control-P is typed. as though level is infinite. . readtables are represented (currently) by 128 word arrays. Lewis. the printlevel will be returned to its previous setting aftar this printout. 26 The printlevel will inunediately be set to this number . INTERLISP clears and saves the input buffer.. it is ignored and printing will continue.21 C.4 Output to all other Jiles acts Readtables and Terminal Tables 27 The INTERLISP input and (to a certain extent) output routines are table driven • is a datum28 that contains '°' by readtables and terminal tables. Thus. by typing control-? followed by a number. followed by a period or exclamation point. which simply clears the output buffer. thereby effectively skipping the next (up to) 64 characters. and then waits for input which is terminated by any non-number. Note: printleuel only affects terminal output. rings the bell indicating it has seen the control-P. If the input was terminated by other than a period or an exclamation point.) 11 a circular or long list of atoms. 26 Another way of "turning off 11 output is to type control-0. all if unfinished lists above that level will be terminated by ". The input buffer is then restored and the program continues. If an exclamation point is used. i. a string of digits. 14. is being printed out. 14.printing.

value is + ~· is system's table. \. + Readtable Functions + readtablep[rdtbl) input from reset~ terminals while !_g.+ information about the syntax class of each character. some will also accept ORIG Value is ~. If rdtbl is a real readtable. ·etc. or T as indicating the + system 1 s read table for terminals.&lli•T. He can also create his own readtables. via setreadtable. and then not specify a + rdtbl argument. otherwise NIL./here indicated. list or string delimiter. + (not the value of ORIG) as indicating the original system readtab)e. if rdtbl is a real read table.e. + for + initially equal but not + change. + separator character. + system packages use three readtables: + value of) filerdtbl for input/output from files. most functions that accept readtable arguments will + also accept NIL as indicating the primary readtable. and (the value of) editrdtbl. The T for input/output from terminals.22 . + + escape character. 14. i. These three tables ~re Using the functlons described below. value value is primary read readtable If + . + terminals.r. + install them as the primary readtable. generates an ILLEGAL READTABLE error. use + In the discussion below. or NIL. e. the user may or copy these tables. (tho in the editor.g. getreadtable[rdtbl) If rdtbl•NIL. break character. + and either explicitly pass them to input/output functions as arguments. for Otherwise.

" to STRINGDELIH.setreadtable[rdtbl..Jl=T. NIL. fr.g. setreadtable resets the system readtable for terminals. [ belongs to the class + LEFTBRACKET. RIGHTPAREN. 30 There discussed on page 14. ·or + a real readtable.2!!! can be ORIG. from] copies (smashes) f!. RIGHTBRACKET. .Q!!! into rdtbl. + can be NIL.2!)! and rdtb 1 + In addition. + system readtable. Syntax Classes A syntax class is a group of characters which behave the same with respect to a + particular input/output operation. and OTHER. + value is a copy of !!!fil. + + + 14. etc. i.23 . generates an ILLEGAL READTABLE error.$O + i~----------------------------------------------------------------------------1 f fl. SEPRCHAR. STRINGDELIH. separators belong to the class SEPR. setreadtable is suitable + for use with reset form (section 5). meaning use system's original + readtable. 29 Generates + ILLEGAL READTABLE error if rdtbl is not NIL. or a real readtable.e.29. l. BREAK.flg) copyreadtable[rdtblJ resets primary readtable to be ~. ESCAPE. rdtbl can be a real + readtable. + Characters that are not otherwise special belong to the class OTHER. T. Note e.Syntax classes for term1n·a1 tables are + that the user can reset the other system readtables with (SETQ FILEROTBL (GETREAOTABLE)). Value is previous setting of + primary readtable. SEPR 0 BREAKCHAR.s a + readtable. + + + are currently 11 syntax classes f'or read tables: LEFTBRACKE T. setg. l. in which case value is + a copy of original otherwise + Note that + copyreadtable is the only function that create. For example. or ORIG. break characters belong to tho + syntax class BREAK. + fr. LEFTPAREN. resetreadtable[ rdtbl.

+ character.ill.table] ch is either a character code.+ The functions below are used to obtain and (re )set the syntax class of a + character. or in the case of read-macro characters + (page + (type fn). a in that class. ORIG.26).g. table can be either NIL. + number.e.class. e. an expression or character ch form The value of setsyntax is the previous table. means give + ch the syntax class it has in the table indicated + by + be + equivalent to getsyntax[class:table'). . class of" being which the is character ]. or a real readtable or + terminal table. and 49 indicates the character 1. setsyntax[ { . means + give + indicated by £!. + class of ch. if £!! is a Value is syntax class of £h with respect to table. a the the 14. sets syntax class of' £. i.table] ch can either be a character code.class J. in INTERLISP•10.g. T.24 code syntax or as class can also character. i. e. In the last case. or a real readtable or terminal table. + table can be NIL. or a syntax class.e. ORIG. T. i. it is interpreted as a character code. + the value of getsyntax is a list of the character + codes + getsyntax[BREAK]•getbrk[]. or a character. a character code.%[ 14. + + setsyntax[ch. T. class is a syntax + class.h. 1 + indicates control-A. or + a real readtable or terminal + equivalent to getsyntax[ ch . + getsyntax[ch. e.g. or a character.e. setsyntax[%(. For example. + setsyntax will also accept class=NIL.0RIGJ. class.

tableJ table is NIL.25 a value. -'> (Note that the class ESCAPE refers to the + input escape character. and + ESCAPE are all break characters. not BREAK. .) Making a character be a format character does not . STRINGOELIM. Format Characters ~ A format character is a character which is recognized as special by road..e. setsyntax[%u . Breaks. The + lEFTPAREN.rdtbl) and setsyntax[ch. e. getsyntax will never return BREAK 14. -e- accept a character as an argument. LEFTBRACKET. syntaxp(41. getsyntax[ BREAK . + However.rdtbl). Separators. and Readtables The syntax class BREAK (or SEPR) corresponds to those characters treated as break (or equivalent separator) is + to + Note that the characters corresponding to the syntax + charactei'"s by to getbrk[rdtbl).¢.(.g. setbrk[list[ch]. + characters which are break or separator characters but have no other special + Junction belong to the syntax class BREAKCHAR or SEPRCHAR (as well as being + In fact. getsyntax applied to these characters will return the syntax class corresponding to their format character function. •} s.syntaxp[code. lHTBRACKET. 11 . To disable a format -> character. . and ESCAPE. e. STRINGDELIH. assign i t syntax class 01'1-IER.:- six corresponding syntax classes are: R!GHTPAREN.g. equivalent RIGHTPAREN. i t is perfectly . i. table. disable the character currently filling that f1. T. and therefore members of the class BREAK.BREAK.].. and%. RXGHTBRACKEl..rncUon. or SEPR as + Instead.).OTHER).¢.yntaxp compiles open.LEFTPAREN]=T. • There are six format characters in INTERLISP namely[. Note that syntaxp will not {- class class.class. or a real readtable or terminal ~ Value is T U' coda is a member or syntax.rdtblJ is RIGHTBRACKET. acceptable to have both { and [ function as left brackets.. + classes LEFTPAREN.l. . ~· + Thus.

but that + means make %( b& Ju&t a break character. e.BREAK}. + e. e. if I is defined + by + value of foo is (A B C).· For instead exa~ple.g. %(. where lle! + INFIX. when + (X I V).'ed into the inpu.g. gi.2D£. If the user does disable one of the fo·rmat characters.expression of the form (type fn). being used for that call to + interpretation of the value 'returned depends on the type of read•macro: + (1) MACRO of the class BREAK or SEPR). + 1. be used However. by performing setsyntax[%(. and therefore disables the LEFTPAREN + function + setsyntax[%( . + defined by: + + BREAK can had been read. SPLICE.OTHER]· followed ~s by MACRO. or a lambda expression.BREAKCHA~) setsyntax["( .+ members of + interchangeably with BREAKCHAR.0THERJ. + Read Macro Characters + The user can define various characters as read macro characters by specifying + as a class an .26 and the user c V). + nop (since%( is already a break character). of the could be [HACRO(LAHBDA(FL ROTBL)(KWOTE(REAO FL RDTBLJ. and fn is the name of a function. or Whenever llfil! ~· The The result is inserted into the input as if that + expression + read-macro character. it is not sufficient for restorinp the· + formatting function simply to make the character again into a break character.ving i t + as arguments the input file and readtable. the result Will be (X AB (SPLICE (LAMBDA NIL ( APP~NO FOO))).· it calls the usociated function. the inputs . note that setsyntax["( :BREAK] is a equivalent to setsyntax[X(. (2) SPLICE The result (which should be a list or NIL) is + !15. 14. setsyntax[ %(:BREAK J would not restore "( as LEFTPAREN. + encounters a read-macro character.t list. It is In most cases.

rdtbl. previous setting. turns them readmacros in Value is on. the pa.. + could be defined by: ~ (INFIX (LAMBDA (Fl RDTBL Z) + ( RPLACA ( CDR Z) Note that read-macro characters can be 1 + (LIST (QUOTE !PLUS) (CADR Z) (READ FL ROTBL))) Z)) by nested. Thus. i. the bracket is also put back into the buffer to be read (again) at the higher level.!1£ as format. + Note that i f a read-macro 1 s function calls read. NIL (or actually appeared. ai·------------------------------D·---~-------------D·------------------------- If a call to read from within a readmacro encounters an unmatched RIGHTBRACKET within a list. + ~ is defined and the will by value be + of foo returnad.g.fOO V) is 1 for example. inputting an expression such as (AB 1 (C DJ will work correctly. (SPLICE (LAMBDA (Fl RDTBl) (READ f'l RDTBL))). function 1 s value is taken as a new tconc 1 is t -> which replaces the old one.The associated function is called with the list of (3) INFIX what has been read (current level list only). 31 readmacros[flg. and (X . RIGHTPAREN Thus the first case is disallowed. ~ v + + (MACRO (LAMBDA (FL RDTBl) (EVAl (READ Fl RDTBl)))) (AB C).e. + For example. if then if (X (ABC) V) input. If turns off action of flg=T.rdtbl] If f. its third in The argument. and the read returns NIL. 14. -o- reading a single RIGHTPAREN or RIGHTBRACKET via a read inside of a read-macro y function. e.nm/bracket will be put back into the input ~ buffer. is + If + (X !=FOO Y) is input.!!I=Nil. and a READ-MACRO CONTEXT ERROR will be generated. + 1 () 1 ) If this occurs.:- cannot distinguish the case where a followed the read-macro character.. the y function or RIGHTBRACKET y from the case where the a tom . (A B ' ) . lli. (X ABC Y) will be returned.21 + + + + + .

+ contains + input/output + (control-Q). + example. However. + + termtnal In addition. how control characters DELETELINE are to be value is ll. gettermtable[ttbl) If ttbl=NIL.+ Terminal Tables + A readtable contains input/output information that is media-independent.28 . the action of parentheses is the same regardless of the device from + which the input is being performed. terminal tables + cannot be passed as arguments to input/output functions. Otherwise. + value + ILLEGAL TERMINAL TABLE error. + He can also create his own terminal tables and install them as the primary + terminal table via settermtable. + + classes For settermtable[ttbl) If~ ll1tl· (i. whether lower case input is to be converted to upper case. etc. value is primary terminal table.g. the user may change. 14. unlike readtables. or copy terminal tables. terminal tables are represented (currently) by 16 word arrays. current) is a real terminal table. + Using the functions below. + line-buffering + echoed/printed. characters e. etc. table is a datum32 that A terminal that DELETECHAR pertain (control-A).e. generates resets primary terminal table to be ll!ll· an Value ij·-------------------------------·--·-··---·--···-·····-··-···-·····~---·-···· In INTERLISP-10. terminal tables contain such information as how + + to NIL otherwise.!tl• U' !ill is a real terminal table. + Terminal Table Functions + termtablep[ttbl) those syntax operations is of only. reset. to be performed.

g. + smashes from into ttbl. getsyntax. where ttbl is a terminal to ~ primary readtable. -e-. generates an ILLEGAL READTABLE error. setsyntax[ ch . in which case value ~ is a copy of the original system terminal tabla. + If given incompatible class and table arguments. indicated refer + In the absence of such information.BREAK. --0- the table. setsyntax[ chi . value :l. + LINEOELETE (or DELETELINE). rdtbl] an ILLEGAL + setsyntax[ch. table. y is copytermtable[ttblJ previous ttbl.!).g. NIL. getsyntax and syntaxp use the. ~ Note that copytarmtable is the only function that + creates a terminal table.s a copy of resettermtable[ttbl. and syntaxp all work on terminal tables as well as When given NIL as a table argument. + Terminal Syntax classes There are currently six terminal syntax classes: CHARDELETE (or DELETECHAR).from) Generates ll!ll· ttbl can be a real terminal table. or ORIG. e.ch2 J re hrs to the primary read table. In addition. from and ttbl can be NXL or a real terminal table. meaning use system's original terminal table.g. and EOL These classes + !4. all three functions default to the + e. + ~ primary readtable or primary terminal table depending on which table contains the + TERMINAL TABLE error. from can bs ORIG.BREAKJ will ~ 4 primary readtable. setsyntax[ch.an '°' ILLEGAL TERMINAL TABLE error if ttbl is not a real + terminal tabla. CTRLV (or CNTRLV). all three functions generate . getsyntax[ CHARDELETE. readtables.CHARDELHE] will refer to the primary terminal e. errors. class argument.ttbll.29 . RETYPE. setsyntax.

CTRLV. + control-V. If mode=UPARROW. + + + that t or control (However. control·R.e. if any. otherwise NIL.17. is an alphabetic character (or it refers to the corresponding control character.UPARROW) makes control-A echo as tA. All other values of char + generate ILLEGAL ARG errors. + to + code). the previous character is disabled. 14. characters belong to The classes CHARDELETE. char char mode=SIMULATE.g. and + terminal syntax class NONE. When a new character is assigned Used to indicate how control characters are to be + echoed + character code.+ correspond (initially) to the characters control-A. + echoing printed. the EOL character signals to the line buffering routine to pass the input back to the calling function. 33 All other control·Q. + value is the current output mode without changing + it. 33 ---------------------·-----------------------~--------------------------------- On input from a terminal. + charcontrol[A. It also is used to terminate inputs to readline. + previous output mode for char. + Terminal Control Functions + echocontrol[char. i f char.:haracter. the function echomode described below can be used disable all echoing. The is value char itself output corresponding of is never will be will be alphabetic echocontrol is If mode=NIL.30 .mode:ttblJ carriagereturn/linefeed. e. RETYPE. + i. LINEDELETE. reassigned the syntax class NONE. followed by the information can be a ·Character If mode= IGNORE. page 14. and the value of setsyntax will be the + code for the previous character of that class. + printed. If + printed. If + simulated. + one of these syntax classes by setsyntax.) Therefore. + and EOL can contain at most one character. mode=REAL. independently specified or for the the Note + characters only. char will be printed + as + c.

NTHCHDEL. by for LINEDELETE. the message to be printed must be less + than 5 characters. ECHO the characters deleted CHARDELETE are.g=NIL.message.ttbl) ~: LINEDELETE message is the message printed when LINEDELETE character is typed.echomode[flg.s • setting. and + EMPTYCHDEL.31 + • + . If i~-----------------------------------------------------------~----------------This setting of lSTCHDEL. If previous f. and POSTCHDEL makes it easy to determine exactly what has been deleted. Initially "f-<cr>". by NOE CHO the characters deleted CHARDELETE are not echoed. 1STCHDEL. The value of deletecontrol will + be the previous message as a string. ' EHPTYCHDEl message is the message printed when a CHARDELETE is typed and there are no characters in the buffer. + used for specifying the output protocol + when a CHARDELETE or LINEDELETE is typed according + to the following interpretations of + deletecontrol[type. Xnitially "\". turns echoing for terminal table ttbl on. POSTCHDEL. NTHCHDEL. echoed. Initially "ll<cr>". Value :l. 1STCHDEL message is the message printed the first time CHARDELETE is typed. turns echoing off. Initially "\". 14. Initially""· POSTCHDEL message is the message printed when input is resumed following a sequence of one or ~~re CHARDELETE 's.ttblJ If flg=T. namely all of the characters between the \'s. NTHCHDEL message is the message printed on subsequent CHARDELETE's (without intervening characters).!.

e. + is backspace) deletecontrol[NOECHO]. ~8 deletecontrol is code for control·H. The conversion is then performed at the TENEX level.e. the value will be the previous + message without changing it.32 .. ttbl J If the user's terminal is a scope terminal. + raise[ flg. which ~haracters) If f. (eliminates echoing of del•ted + deletecontrol[1STCHOELi"tH tH"). fl~p=NIL. + the vc\lUe of deletecontrol is the previous echo + mode. input is echoed as typed.!fl=T. i.REAL].. For ECHO and NOECHO. echoing is also available via raise[ O]. 14.!:!12!!!• rstring. and deletecontrol(NTHCHDEL. If + all characters are passed as + previous setting. before INTERLISP-10 even sees the characters. which executes the JSYS calls corresponding to the TENEX command RAISE. Value is CONTROL In INTERLISP's normal state. message is ignored."tH TH"]. i. 36 Line-buffering and and typed. Following a sysin. + Note: + echocontrol can be used to make it really delete the last character by + performing the following1 echocontrol[8. . characters typed on the terminal (this section does not apply in any way to input from a file) are transferred to a line buffer. The initial setting or raise in INTERLISP-10 is det'ermined by the terminal mode at the time the user first starts up the system. Characters are transmitted from the line buffer to whatever input function initiated the request (i. or ~) 36 only + + + + + + + + + ia---------------------------~------------------------------------------------In INTERLISP-10. 36 peekc is an exception. both raise[] and raise[T] execute TENEX JSVS calls corresponding to the TENEX command NORAISE. the raise mode is restored to whatever it was prior to the corresponding sysctut. Conversion of lowercase characters to uppercase before .e.+ message=NIL. ECHO or NOECHO. but lowercase + letters are converted to upper case. it returns the character invnediateiy. read.

Rubout can thus be used to clear type-ahead. but by INTERLISP. references to control-A.33 . In this case. on•~ characters are echoed preceded by a \. The Or. carriage-return following the right parenthesis before any if he whereas types (PROGN (READ) (READ)) ha would not. for they w:l.ng is not performed by read or ratom. 38 Typing rubout clears the entire input buffer at the time i t is t11ped. 39 As described earlier.e. control-Q. i. only that they sire siiU in tho Note also that it is . once a carriage return has been typed. the CHARDELETE. Therefore. and EOL characters can all be redefined. if tho third argument to read is NXl. 38 (If no characters are in the buffer and either control-A or control-Q is typed.e. INTERLISP ochoes ##. INTERLISP also outputs a carriage-return line-feed. requesting input that determines whether parentheses counting is observed. it does not matter (nor is it necessarily known) which function ultimately proc0ss will the characters. for calls from read. 37 Until is thls time. or EOl characters. immediately if on any characters next the (PROGN (RATOM) (READC)) followed are 'left request by AB over'.the function that is currently INTERLISP input buffer. the characters are also transmitted whenever the parentheses count reaches 0.g.) 39 Note that this line radH:l. . U:NEOELETE. 37--------------------G----Q 0 --------Q·------~QOD•~·o·---~--~-m-•-UGO~--~Gm•g-~ As mentioned earlier. the user can delete at a time from the input buffer by typing control-A. perform both operations. whereas the action of control-A and control-Q occurs at the time they are read. the entire line is 'available' 0 even if not all of it is processed by the function initiating the request for input. or carriage return in the discussion actually refer to the current CHARDELETE.when a carriage-return characters typed. However. LINEDELETE. i. ' if the user executes (PROGN (RATOM) (READ)) and types in A (B C D) he will have to type action in is the tal~en. the user can delete the entire line buffer back to the last carriage-return by typing control·Q. 14.11 which case INTERLISP echoes ##.:l.11 input. e. carriage•return will be 'for returned example. whatever they may be.

line-buffering until carriage-return or matching If the expression being typed is not a list. since returning at this point would leave the line buffer in a "funny" state. control is available to defeat this line-buffering. In this case the user could control·Q the entire litie. 2.g. Control-A and control·Q editing are available on those characters still in the buffer. (RATOM) followed by ABCcontrol•Aspace will return AB. NIL. he will delete only TIME since the rest of the line has already been transmitted to !:. Thus if control is T and (READ) is followed by 'ABC('• the ABC will not be read until a carriage-return or matching parentheses is encountered.!!!! and processed. and the user types NOW IS THE TIME followed by control·Q. input determines how the line is treated: 1. II (RATOH) followed by indicating that control-A was attempted since the ( is a break character and would therefore already have been read. The function that initiates the request for.g. the effect is the same as though control were parentheses. ratom characters encountered. are returned as soon as a break or separator character is Before then. control-A and control•Q may be used as with read. "• or[. e. it is returned as soon as a break or separator character is encount~red. 14.Turning-off Line-buffering The function control[ TJ. 40 e. (READ) followed by ABC space will immediately return ABC. (control-A will return ( and type with nothing in the buffer. if a program is performing several reads under control[TJ.34 .e. read if the expression being typed is a list. since all of the characters are still in the buffer. i. Thus. 40 --------~--------------------·------~-----------------------~-----------------An exception to the above occurs when the break or separator character is a (. After characters are returned to the calling function without line· buffering as described below.

is ( REAOC) returned no immediately. is typed. sysbuf[ flg] same as linbuf for system buffer.ng ttbl.T).flg) Clears the input buffer for file.35 . !n (RE ADC) followed by % will read the %. 0 or control·S control·E. the internal buffers associated with linbuf and sysbuf are not changed by a clearbuf[T.!. ll :l. 14. When control·D.5 XNTERLlSP's normal for the terminal table con~rol ls its previous setting. I f !Jjz=NlL.s possible. eliminates control[u.ttbl) line buffer:l. 0 INTERLISP automatically does a clearbuf[T:T). y_=Nll The value of 14. INTERLISP restores the buffer after the interaction. 0 restores line-buffering (normal).JCIS saved at last clearbuf[ T: T].3. If both the system buffer and lNTERLISP's line buffer are empty. contents of INTERLISP's line buffer and the system buffer are saved (and can be obtained via linbuf and sysbuf described below)..g is T. either control i'. value is INTERLISP'S line buffer (as a string) that \'. readc/peekc the character particular. (for control-P and control·S. Miscellaneous Input/Output Control Functions clearbuf[file. control H. clears this internal buffer. read the control-A. line editing followed by controluA w:l. If file is T and f. ) if !ll:l=T. linbuf[flg) Sae Appendix 3 .

Thus if the user wants to "peek" at various charactars in the buffer. radix[n J Resets output radix41 to In I with sign indicator the sign of n. and sysbuf prpvide a way of 'undoing' a clearbuf.e. there is no input radix. linbuf. setting without changing Initial setting is 10. first 160 taken. in INTERLISP-to. -9 will print as shown with the following radices: radix printing 10 -9 ·10 68719476727 i. For example.T). examine the buffers via linbuf and sysbuf.36 .bklinbuf[x] !$ is a string. bksysbuf. he could perform clearbuf[T. sets floating format control to n ---------•-••~e-o~oeoa•••••••••-••••-••••~••••••••••·~~-·-••••••••••••••••••••• 41 Currently. radix[] gives current it. 14. (2t36-9) •11Q 8 -8 777777777767Q Value of radix is its last setting. buffer to ::S· bk. fl tfmt[ n] In JNTERLISP-10. bk$ysbuf[x] bksysbuf sets system buffer to ~· The effect is the same as though the user typed ~· ~ is a string.linbuf sets INTERLISP' s lino Ir greater than 160 characters. and then put them back. bklinbuf.

Gives the column number the next character will be read from or carriage return.n J a beyond the carriageQreturn is first. 1after position=O. linelength[] Initial setting is 72. e. inserted returns current setting. Value is the former setting of the line length. linelength[n] Sets the length of the print line for all files. the subsequent sysin will continue from that point. Also saves the stacks. Value of fltfmt is last setting. current setting without fltfmt[ J returns changing Initial it.h) which gives the position in the file.37 .6 Sysin and Sysout sysout[ file) Saves the user's private memory on file.g.'n). sysout is file 14. so that if a program performs a sysout.g. (PROGN (SYSOUT (QUOTE FOO)) (PRINT (QUOTE HELLO))) will cause HELLO will be printed after (SYSIN (QUOTE FOO)) The value of . 0 printed to. (See TENEX JSYS manual for interpretation of fltfmt[TJ speciiiias free format (see Section 3). position[ file . set ting is T. 14. resets position to Il· Note that position[fUe) is not the same as sfptr[f:l. Whenever printing an atom would go length of the automatically line. not on the !tne. e.

the only way Jor a program to determine whether it i. sysout is also . Whenever the INTERLISP . generates a FILE NOT If FOUND error.e. from a . ~.s Ju. 42 A value of NIL indicates the sysout + was unsuccessful. 43 Value is Ust[fileJ.stem. and the effect will be exactly the sa~e ~shaving perform~d a sysin. file is a runnable file.e. but not when the sysout was performed. there was a problem in reading the file. f. Sy.s11. the time and date that the sysout was performed. + ~i----------------------------------------------------------------------------sysout is advised t6 set the variable sysoutdate to (DATE).sout Jiles are ~ compatible with the new .sembled and/or reloaded.2.s to te.sv.s rea.saue the . . i.e.sin or from a .sy.s11. or user's direptory was full. 14 .s. i. For example.(full name). or simply type the file name to TENEX.sin continues immediately where . (COND ((LISTP (SYSOUT (QUOTE FOO))) (PRINT (QUOTE HELLO)))) will cause HELLO to be printed following the sysin. + + + + + + + + 43 In INTERLISP-10. sysin[fileJ restores the state ot INTERLISP from a sy•out f:Ue.e.sout doe. when the value being returned by sysout is a list. either disk or computer error.su. i.38. Instead.sout left oJJ. use the TENEX RUN conunand.state of an11 open Jile. the user can treat the sysout file the same as a SAV file.sv.!!! is not found. Since .st coming ba. old . it is not necessary to start up an INTERLISP aiidCaU sysin in order to restore the state of the user's program.! .sout.stem i.sout i. i.. advised to evaluate the expressions on aftersysoutforms when coming back from a sysin.sv.s !!.sv.st the value oJ . If sysin returns NIL.cll.e.s.

. If printflg=T. See section is.printflg] Reads successive S-expressions filerdtbl as readtable) and evaluates each as 1 t is read.9. on EXPR. otherwise it does not.39 ~ . 14. a message is printed and the old definition saved. the If definitions but and !:2!. ldflg affects the operation of define. are stored on property l:l.14. and is a function is redefined. H ~· (Section 8) ldflg:::NIL.!:. dfnflg cannot simply be rebound because it is a global variable. or the single atom STOP. definition is simply overwritten. load prints the value of each S· expression. load[file.ill• and \. in which case it is set to the indicated value regardless of dfnflg. from an end tho of file list of these from file (with IS-expressions. not only function also variables set by If ldflg::PROP. .sts. encountered./hile load is operating. until it reads either NIL. reset to ldflg. 44 dfnflg Thus. defineg. 45 except when the variable has value NOBINO. Value is file (full name). the function property definitions lists under the are ~ stored property ldflg=ALLPROP. 45 44----------•••-••a•••••-••••••••••••••••••••••••••••••••G•••••••••••••••o-•••• Using resetvar (Section 5).ldflg.7 Symbolic File Input readfile[ file] Reads read successive (with S-expressions filerdtbl as or a Value file using until readtable) single atom STOP is read.

. 14. any file that can be loadod The interpretation of ldflg is the samo by load. VARS is same as ( RPAQQ RPAQ). and subsequently modified 46 47 by w. For· + more complicated specification.varsJ46 permits d_efinitions.!• e. w. a function name.f1le. NIL ··means none. + (FOOCOMS DECLARE: (OEFLIST & ~· or (QUOTE MACRO))) would ------------------------------------------------------------------------------loadfns was originally written by J.illis a list. either RPAQQ or FOOCOMS can be ~reated used to as an edit pattern and matched with the entire non•DEFINEQ expression~ In 9ther words. single selective loading function of !!!. 47 --. · Teitelman~ If a compiled definition subfunctions.g.* ioadfns(fns. to some member of + it matches (using edit4e) some list on Y!. i. or T.ldflg.e. meaning all functions. a + non•DEFINEQ expression will be loaded if either + its i l l or cadr is !9. is loaded. + When Y.ill is compared + with .both i l l and + eig. + 1ndicate (RPAQQ FOOCOHS ··) should be loaded. Goodwin. each list on vars + is ~ of non-DEFINEQ expressions. FNS/VARS + same as ( fi1eCOMS file BLOCKS). and any other + is + atom is the same as list[atom].!:.! is a list of function names. each atom on Y. - as for load.file can be either a compiled or symbolic file.40 so ~re all compiler · generated . + !!!!::! specifies which non-DEFINEQ expreuion are to + be loaded: (i. evaluated): T means all.e.

41 .file.. once the file package knows about the contents of a + the user can edit functions contained in the file without explicitly + file.file. those members of Y!ll for which no corresponding -> expressions were found (if any). + file must previously have been function .ldflg] same as loadfns[NIL.o- the functions that were found.73) to determine where the first (page in + fns resides. plus a list of . ~ The value of loadfns is a list of (the names of) .6().:- (For more discussion. the preferred way to notice it 14. loadvars[vars.63). when either the symbolic or compiled versions of the file are + loaded. If ~ is non-NIL. those functions which have not been modified do not have to be loaded in order to write out an updated version of the file. Le.fns. plus a list of -i- any) headed by the -> atom NOT-FOUND: e.file.cause (RPAOQ FOOCOMS DEFUST 1 s which set 0 m)..ldflg. loading them.ldflg. and load from that file. If the file is not going to be loaded. all DECLARE:'s. -¢- those functions not found ( H include -> those expressions that were loaded.. + are normally noticed. (FOO FIE (NOT-FOUND: FUM)). see page 14. + Files + their contents become known to the f'i le package + (page 14.ldflg] same as loadfns[fns.o4' evaluated.. . the 'noticed'.. the value will also loadfns will use whereis 14. up MACRO 1 s to be and all read and . Similarly.g.T] + As mentioned in section 9. !f file=Nll. again headed by -> the atom NOT-FOUND:.. Note that .varsJ loadfrom[file.

+ but its raison d'etre is to inform the file package about the existence and + contents of a particular. + edit[F001J. + + File Maps + A file map is a data structure which contains a symbolic 'map' of the contents + of a file.b~-1.~· Currently. he need ·only perform loadfrom[FOOJ. e. + 60 The internal representation of the file map is not documented since it m!ElY · change when the map is exten~ed to include information ·about other than just ftinction definitions. loadfns. and makefile(FOO].g. unless it is also one of the block functions.-i~~~~i~~~ -~~-d~-s-i0g~~d-·. 50 + makefile. For example.i. + map enables loadfns to load selected function definitions simply by setting the + f:i le pointer to the corresponding address using sfptr... + + 14. the file the exprs for a given block. + + + + 49 byte address.-~.42 . and numerous other system functions For example. if the user wants to update the file FOO by + editing the function F001 contained in it. and it will not load the block name..~. It will not load a function which already has an in-core expr definition. defineg expression in the file..file.-/1"{e·~-. + lbadblock[fn.--1· :. and then performing a + 48.. + definition within the defineq.file. see sfptr. this consists of the begin and end address 49 for each the begin and end address for each function prettydef. and ·the begin and end address for each compiled + function... +.i~. : • ~~.~h-~.r0i.7.+ is with loadfrom. page 14..·. + at the same time by giving loadfrom a second argument.. + depend heavily on the file map for efficient operation.F001J.ldflgJ Note that the user can also load some functions calls loadfns on those functions contained in the - block declaration ~ontaining fn. 48 . loadfrom[FOO. recompile. -~. ..

+ 62 the file name with directory and version number stripped off. since a file map will usually appear + in the corresponding file.. a file map for the + new file is also built and stored on the FILEMAP property. or outside of INTERLISP altogether. 63 In addition. buildmapflg is initially T. tho <} file map is written on the file itself .43 + + + + • .50. For this reason. the rest are simply copied from the old + file to the new one. 14. However. Whenever a file is written by prettydef. 64 Thus. !. in most cases. + Whenever a file is read by load or loadfns.single read. unless the file was written with buildmapflg=NIL..68) those function definitions that have been changed since + the previous version are prettyprinted.Q. 64 For cosmetic reasons. However. + 63 Building the map in this case essentially comes for free. the address of the file map in the file is (over)written into the FILECREATED expression that appears at the beginning of the file so that the file map can be rapidly accessed without having to scan the entire file. 65 + The procedure followed whenever a system package that uses file maps accesses a • file getfilemap first checks the + FILEMAP property to see if a file map for this file was previously obtained or + 5i·-----------------------------------------------····-·--·-~------····-··----unless buildmapf'lg=NIL. Similarly. the file map is written as the last expression in tho file.ru! and loadf'ns + do not have to build the file map at all. under the + property FILEMAP. . but should instead always use the FNS command.. . since ·it requires only reading the current file pointer before and after each definition is written or copied. a file map is automatically built 61 + and stored on the property list of the root name 62 of the file. page 14. resulting in a considerable speedup. 55 is embodied in the function getfilemap. the file map is heavily used by the 'remake' option of + prettydef (page 14. building the map does require that prettyprint know that it is printing a DEFINEQ expression. the user should never print a DEFINEQ expression onto a file himself. or was created in a prefile map INTERLISP..

For example. it is opened.o1hen it is loaded. and store it on the property FILEMAP. + + + + + + + + + + + + + + + + + + + 14.8 Symbolic file Output writefile[x. file maps for compiled files are not written onto the files themselves. the loadfrom will be (slightly) slower than if FOO did contain a file map. since 1 t will be stored on FOO 1 s FILEMAP proRerty. successive s-expressions from as a readtable. 59 While building the map will not help thts operation. initially T.· If file is not open. opened. The functions which use file maps contain various integrity checks to enablo them to detect that something is wrong. when ! is finished. usemapflg is available primarily to enable the user to recover in those cases where tho file and its map for some reason do not agree. However. i f usemapflg=NIL. 66 If there is none. list. and to generate the error FILEMAP DOES NOT AGREE WITH CONTENTS OF file-name. + + + + 67 currently. and a file + map will be built. A new map will then be built (unless buildmapflg is also NIL). For example. getfilemap next checks the first expression on the + file to see if it is a FILECREATED expression that also contains the address of + a FILEMAP. 68 . the user can set usemapflg to NIL. when available. inserting or deleting just one character will throw that map off. 66•••--------•••••-••• 0 •-•oO~•~••••••••o•o•o••••••oooa~-u-••••••••••••••••••••- The full name of the file is also stored on the FILEMAP property along with its map. and then reexecute the operation. i f the user edits a symbolic file that contains a map using a text editor such as TECO. a STOP is printed on file and 1 t h closed. but subsequent calls to loadfns for this version of FOO will be able to use the map that was built as tho result of the loadfrom.file] Writes a date expression onto file. it will help in future references to this file. Value is file. followed by car[fileJ is used and the If file is a file is left Otherwise. load and loadfns will build maps for a compiled file 1.44 . its value is used. In such cases. 67 If neither &re successful getfilemap returns NIL. 69 14. .+ built. causing the map contained in the file to be ignored. If ~ ~· using fi lerdtbl is atomic. Similary. loadfns will obtain and use the file map for a compiled file. 68 getfilemap also returns NIL. if the user performs· loadfrom[FOO] where FOO does not contain a file map.

load and loadfns * do not have to build the file map at all. + + unless the file was written with buildmapflg=NIL. since a file map will usually appear + in the corresponding file. the user should never print a OEFINEQ expression onto a file himself. resul. However.43 + + + .single read. For this reason.68) those function definitions that have been changed since + the previous version are prettyprinted. in most cases. the rest are simply copied from the old + file to the new one. under tho + property FILEMAP.50. 6i••-••••••••••••••••••••••••••••••••••••••••••••••••••••••••a••••••o•••••••••• unless buildmapflg=NIL. the file map is heavily used by the 'remake' option of + prettydef (page 14. the address of' the file map in the file is (over)written into the FILECREATED expression that appears at the beginning of the file so that the file map can be rapidly accessed without having to scan the entire file. + + 14. + Whenever a file is read by load or loadfns. + + + + + For cosmetic reasons. since it requires only reading the current file pointer before and after each definition is written or copied. page 14. 53 Building the map in this case esseniially comes for free. 54 Thus. Similarly. 66 + The procedure followed whenever a system package that uses file maps accesses a + file getfilemap first checks the + FILEMAP property to see if a file map for this file was previously obtained or + is embodied in the function getfilemap.. However. 65 + . tho + file map is written on the file itself . buildmapflg is initially T.ting in a considerable speedup. a file map is automatically built 51 + and stored on the property list of the root name 62 of the file. building the map does require that prettyprint know that i t is printing a DEFINEQ expression. a file map for the + new file is also built and stored on the FILEMAP property. the file map is written as the last expression in tho file. 52 the file name with directory and version number stripped off. or was created in a pre· file map INTERLISP. but should instead always use the FNS command. 53 In addition. Whenever a file is written by prettydef. or outside of INTERLISP altogether.

67 If neither are successful getfilemap returns NIL. 58 9etfilernap also returns NIL. since it will be stored on F00 1 s FILEMAP property.+ built. it will help in future references to this file. successive s-expressions from as a readtable. and a file + map will be built. For example. However. Similary. if usemapflg=NIL. usemapflg is available primarily to enable the user to recover in those cases where the file and its map for some reason do not agree. followed by car[file] is used and the lf file is a file is left Otherwise. The functions which use file maps contain various integrity checks to enable them to detect that something is wrong. Value is file. 69 14./rites a date expression onto file. file maps for compiled files are not written onto the files themselves. In such cases. when ! is finished. the loadfrom will be (slightly) slower than if FOO did contain a file map. but subsequent calls to loadfns for this version of FOO will be able to use the map that was built as· tho result of the loadfrom. causing the map contained in the file to be ignored. A new map will then be built (unless buildrnapflg is also NIL). 59 While building the map will not help thi~ operation. If file is not open. i f the user performs loadfrom[FOO) where FOO does not contain a file map. it is opened. 9etfilemaQ next checks the first expression on the + file to see if it is a FILECREATEO expression that also contains the address of + a FILEMAP. if the user edits a symbolic file that contains a map using a text editor such as TECO. for example. and store it on the property FILEMAP. and to generate the error FILEMAP DOES NOT AGREE WITH (ONTENTS OF file-name. opened. the user can set usemapflg to NIL. + + + + 67 currently. its value is used. load and loadfns will butld maps for a compiled file when i t is loaded.44 .file] \. 66 If there is none. If ~ ~· using filerdtbl is atomic.8 Symbolic File Output writefile[x. initially T. a STOP is printed on file and it is closed. loadfns will obtain and use the file map for a compiled file. 66•-------------••-••••••••$•••••••••••o•••••••••••••••••o•••••e••••••••••••••• The full name of the file is also stored on the FILEMAP property along with its map. + + + + + + + + + + + + + + + + + + + 14.. list. when available. 68 . inserting or deleting just one character will throw that map off. and then reexecute the operation.

61 prettyprint has a second argument that is T when called from prettydef. function setreadtable[T] prettyprint: PP FOO is performs that calls then and equivalent to PRETTYPRINT((FOO)). it prints (on the terminal) the name of that function if more than 30 seconds (real time) have elapsed since the last time it printed the name of a function. tabs are used instead of spaces for the inital spaces on each line. it will prettyprint the 60-----------·------------------•G•--------q•DGDOGg••eouD•M•oo•ODO••••O•m•--·-The prettyprint package was written by~. Tabs will not be used if prettytabflg is set to NIL (initially T). pristine definition. This results in a reduction of file size by about 30%. or have been compiled with their definitions saved on their property lists . The definitions of the functions are printed in a pretty format on the primary output file using the primary readtable. Primary output file and primary readtable are restored after printing.pp[x] nlambda. For example.it prints the original. 62 In order to save space on f:l. (FACTORIAL (LAMBDA (N) (COUD ((ZEROP N) 1) (T (!TIMES N (FACTORIAL (SUB! NJ) Note: prettyprint will operate correctly on functions broken~in. prettyprint[lstJ60 61 1st is a list of functions (H atomic. 62 that are brokon. In this case. assuming that each tab corresponds to 8 spaces. its value is used). PP(FOO FIE) or (PP FOO FIE) is equivalent to PRETTYPRINT((FOO FIE)). but has a value. Teitelman. advised.les. 14. but does not change the current state or' the function. If prettyprint is given an atom which is not the name of a function. nospread output[T].45 . whenever prettyprint starts a new function.

If all A facility for annotating INTERLISP functions is provided in prettyprint. printed in the right margin. prettyprint returns (atom NOT PRINTABLE).value. For example. • h same as any other ·INTERLISP function. \. and RECURSIVE. For compilation purposes.lhen running an interpreted function. is equivalent to guote. i. (T (ITIMES N (FACTORIAL (SU~1 N]) These corrunents actually form a part of the function definition. i. Accordingly. the extra atom and list structures storage required by the comments will be eliminated.e.. N•l. Example: (FACTORIAL [LAMBDA (N) (•COMPUTES NI) ccorm (• O!=t) ((ZEROP N) 1) (• RECURSIVE DEFINITION: N!=N•N·l!) . prettyprint will perform spelling correction.1. • is defined as a macro which compiles into no Thus. writing (ITIMES N (FACTORIAL (SUB1 N)) (• RECURSIVE DEFINITION)) in the above function would cause an errQr when !TIMES attempted to multiply N.46 This is the way the . comments should only be placed where they will not harm the computation. 63 Otherwise. instructions.e. i f you compile a function with comments. where a quoted expression could be placed. it entered the Therefore. • is defined as an NLAMBDA NOSPREAD function that returns its argument. Comment Feature s-expression beginning with • is interpreted as a comment and. and load the compiled definition into another system. 14. Any fails.

for more options.prttyfile. all files that prettydef has opened will + be closed. 14. See discussion of remaking a file. or a control-D + is typed. Thus whon comments are suppressed and printed as the string ~~cOMHENT~~. page 14. and the (partially complete) file being ~ written will be deleted. readtable. et al. see end of this section.21? except it first sets •*yomment•*flg to 65 NIL. documenting for li. in a filerdtbl prettyprint as its format.s. The function ~ is provided to prettyprint functions. the value of 0 comment 0 flg is printed. Corrunents are designed mainly prettyprinting to the terminal. The arguments to prettydef are interpreted as follows: prttyfns is a list of function names.s t t ng. the comment is printed. including their comments. *stcomr. The functions on the 64----------------------------------------------------------------------------The value of ucommentoflg determines the action. variable settings.69. to the terminal. If ucommentu flg_ is NIL. ~operates exactly like . Otherwise. property lists.ient 0 flg is initially set to 11 ~*COMMENTO ". prettydef The value uses of that '°' Xf an error occurs.47 by the file . ~ prettydef is the name of the symbolic file was created.prttycomsJ 65 Used to make symbolic files are suitable for loading which contain that function definitions. 6 4 Prettydef prettydef[prttyfns. prettydef actually has three additional arguments for use package.comment feature is intended to be used.

functions. 14. surrounded prettyprinted are th&t they can be prttyfns is atomic by a loaded with (the proferrod usage). prettydef will print a DECLARE: expression suitable for informing the compiler about these functions. 67 prttyfile is the name of the file on which the output is to be written. ~ and setg. and an ~ 66 will also be written which will set that atom to the list of functions when the is file loaded.list (DEFINEQ . is closed at end of prettydef file and primary output file is restored. its top level value .is used as the list of function names. prttyfile a list 60----------••••-•••••••••a-•••••••••••••••••••••a•••••••••••••••••••••••••••o• ~ value.• ) so If load. + + + + + 67 and ~ are like See section 5. see section 18. The following options exist: prttyfile=NIL The primary output file is used. except they set the top level In addition. expression will also be written which informs the user of the named atom or list of functions when the file is subsequently loaded.. if any of the functions in the fiie (including those printed by ms command) are nlambdas. and becomes primary output file. in case the user recompiles the file without having first loaded the nlambda. For more discussion.48 . prttYfi le atomic The file is opened if not already open.

evaluation of forms if atomic. its top level value is used and an rpngg is written which will set that atom to the list of commands when the file is subsequently loaded. the values of all user properties 68----------------------------------------------------------------------------If atom 1 does not have the property propname (as opposed to having tho property with NIL value). 68 If propname property on that list. The interpretation of 1. miscellaneous INTERLISP evaluated upon loading. 2. forms e~ch ~ command in the command list is as follows: is written which will restore the top level value of this atom when the file is loaded.Car of the list is assumed to be the file name. The command If PROP should be used H it is not known whetner or not an atom will have the corresponding property. a warning message 11 NO propname PROPERTY FOR atomi" is printed.49 . property lists of atoms. If prttycoms atomic is preferred (the usage). ls a list of commands interpreted as described prttycoms below. These commands are used to save on the output file top level bindings of variables. arrays. exactly as with prttyfns. an to be It also provides for •t output time. is a list. (PROP propname atom 1 ••• atomn) an appropriate deflist will be written which will restore the value of propname for each atom 1 when the file is loaded. and advised functions. The fUia is left open at end of prettydef. deflist's will be written for each If propname=ALL. 14 . and is opened if not already open.

e . type. is e. this case the expression (RPAQ var form) is written. i. 1. arrays. . each atom following ARRAY should have an array as its value. .g.f~rst argument to prettyder.r data types.e. ( P •••.(on the property list of each atomi) are saved.43. each S·expression following P will be printed on the output file. 71 HORRIBLEVARS (section 21} pro~ide~ a way of saving and r~loading variables whose values contain re•entrant or circular.•• fnm> were the .Y!!t. 70 7. will be set to the top-level value it had at the time the file was prettydefed... each form following E will be evaluated at output time. . see page 14.50 . . a defineq is written with the definitions ~r rn 1 ~·· fnm exactly. An appropriate expression will be written which will set the atom to an array of exactly the same size. + + + + + + 70 The user should never print a DEFINEQ expression directly onto a file himself. ) . -------------------------------~---··-------·----------------~----------------sxsprops is ~ list of properties used by system functions. .7 1 If it (FOO (APPEND FIE FUM)) interpreted . and contents upon loading. (FNS fn 1 ·~·fn~). (ARRAY atom 1 •. which will set its top level value when the file is loaded. or hash arrays. 69 3. form). non-atomic. (RPAQQ vari top•level·value) is written. as though (fn 1 . ) . 6. ~i If m 1 is atomic. and consequenUy evaluated when the file is loaded. .• atom0 ). var n). an expression wi 11 be writ ten. ~n . use. for each var i.• when prettydef reaches this command.. 4. Only properties 69 not on that list are dumped when the ALL option is . but should instead always use the FNS convnand for dumping functions.as (var· or (FOO (QUOTE (FOOl F002 F003))).. .u. 5. list structure. (VARS var 1 . for more details.sed . (E . 14.

51 . The user can then Sae Section 19. lst 1 ) . comn). F002 has PROPJ. 1 . (ADVISE fn 1 . 14. . in which case it is first set to NIL. fnm. and PROP2. except that only non-NIL property values are saved.. a declare expression will be written which the block compile functions interpret as block declarations. ( IFPROP propname atom 1 • . 9. comn wi 11 be interpreted as a prettydef command. . (ADVICE fn 1 . USERMACROS writes expressions for adding the definitions to usermacros and the names to the appropriate spelling lists. atomn) same as PROP command. tha effect is the same as (RPAQ var 1 (UNION ht 1 var 1 )).)' for each fni' will write a deflist which will put the advice back on the property list of the function.. 10. . 11 • ( COMS com 1 . (USERMACROS atom 1 .!!:i can initially be NOBINO. if F001 has property PROP1 F003 has property PROPl and PROP3. :Le..8. Y..•. See Section 18. 12. 14.. atomn>• each atom 1 is the name of a user edit macro. (USERMACROS) will save all user edit macros. each of the commands com 1 ·• • . and For example. each element of lst 1 not a member of var 1 (at load time) is added to it. (IFPROP (PROP1 PROP2 PROPJ) F001 F002 FOOJ) will save only those 5 property values.• blockn) for each block 1 .. use readvise to reactivate the advice.. 13. (varn • lstn)) For each var 1 . fnmL for each fnn• an appropriate expression will be written which will reinstate the function to its advised state when the file is loaded. (AOOVARS (var 1 . (BLOCKS block.

~-.... New prettydef commands can be defined via prettydefmacros (see page 14.. EVAL@COMPILE. e.g w.. + + + + 73 Except for the PROP and IFPROP commands. is evaluated and its value used in executing the command. and (3) not evaluated at + compile time.·.+ 15.~~.. + processes its arguments by + on + DOEVAL@LOAD. in which case the • must fol low the property name. (DECLARE: . the relevant tags are COPY.-. would + e..i~~.~i. it or not evaluating each list depending the setting of an internal state variable.e. and DONTEVAL@LOAD can be used to reset this state variable. prettydef performs spelling correcton using declaretagslst as a spelling list..~. ~valuating When declare: is produ.~. + The initial setting is to evaluate.-i~cii~. those prettycoms appearing within the DECLARE: command The is ·embedded in a DECLARE: expression. (PROP MACRO* FOOHACROS). caddr of the .conunand. alon... EVAL@LOAD.• OONTCOPY. O. 14.8 o£cL~~£ ~-. if the atom • follows the command type.. the form following the • . and DONTEVAL@COM~ILE. + (DECLARE: + defined as an nlambda nospread function. 1. In this case.ith any tags that are specified.. OOEVAL@COMPILE.~ ~i~~-. e.~.. ii. (2).. 73 Note that (COMS * form) provides a way of corrrp~itng what should be done by prettydef. The tags..g. prettycoms/flags) Normally expressions written onto a symbolic + file are ( 1) evaluated when loaded.ci. (FNS •(APPEND FNS1 FNS2)).52 . The value of declaretagslst is a list of· all the tags use~ in DECLARE: expressions~ If a tag not on this list appears in a DECLARE: prettycom. and not defined on + · :· 72.g.OCOPY..~..g.ci· i~ . 57). + the compiler. 72 EVAL@COMPILE DONTCOPV (DEFINEQ ··) (DEFLIST ··)).. + output of DECLARE: allows the user to override these defaults. + (DECLARE: EVAL@COHPILE DONTCOPY (FNS ••) (PROP··)) . lf prettydef is given a command not one of the above.ce DECLARE: is called. or In each of the commands described above. copied to the compiled file when + the symbolic file is compiled (see section 18).

( RPAQQ FOOVARS (FIE . the corrected version of prettycoms is written (again) on the output file. e.. this will result in prettycoms being reset. (RPAQQ FIE value of fie) 8. and F003 3.53 .ld then be the corrected version. the uncorrected prettycoms would already have beon printed on the output file.. When the file is loaded. STOP 75 since at this point. 14. (FOOVARS RESET). Example: ~SET(FOOFNS (FOOi ~sET(FOOCOMS(FIE (QUOTE FIE1] ~PRETTYDEF(FOOFNS F002 F003)) (PROP MACRO FOOl F002) (P (MOVD (QUOTE FOOl) FOO FOOCOMS) would create a file FOO containing: 1. (PRINT (QUOTE FOOVARS) T) 6. (DEFLIST (QUOTE ((F001 propvalue) (F002 propvalue))) (QUOTE MACRO)) 9. ) 7. prettydef generates an error. 76 If unsuccessful. (PRWT (QUOTE FOOFNS) T) 4. { RPAQQ FOOFNS ( FOOl F003 F003)) 5. spelling list.g.it attempts spelling correction 74 using prettycomsplst as prettydefmacros. The value of FOOVARS wou. A message which prints the time and date the file was made (done automatically) 2. (MOVO (QUOTE FOOl) (QUOTE FIE1)) 10. and a message printed. BAD PRETTYCOM. a If successful. DEF INEQ followed by the definitions of FOO!. F002.

defJ prints the expression expr ill a pretty format on the primary readtable. Used by prettydef.!.!! and closes it. if position + minspaces is gre.the time and date the fite was made. • The message printed when the file ~s loaded. endfile[ file J Prints STOP on printdef[expr.• •.changes) prints the FILECREATED expression at beginning of prettydefed files that upon loading types . 1 is used). 76 and stores this time and date on the property list of file under the· property FILEDATES.!!!does a terpri and then spaces[posJ. printfns prints defincg and prettyprints the functions to primary output file using primary readtable. 7e. minspaces indicates the minimum number of spaces to be printed by tab. prettyheader is initially "FILE CREATED 11 14.Q.54 .•••••• •• •• • • • •.ater than Q. printdate[file.!.file) performs appropriate number of spaces to move to position pos. i. is the value of prettyheader followed by the time and date.e.minspaces. tab[pos. use by the file package.•• • • • • • • • --• ci output !fil 1s file using the primary the left hand margin a••••• ••••oo•••G•••'•••••••••••••••••••••••••••. i. .prettydef functions ~ printfns[x) is a list or functions. command (FNS • FOO) is equivalent to conunand (E (PRINTFNS FOO)).left.e •• it is intended to be small number (if NIL. Thus.!• £.. changes is for.

setting is 48.55 + • . comments. if they are to be changed. et al. etc. they must be reset.. is essentially If def::NIL.(line length determines the right hand margin). page 14. PROG's. determines the position of the right margin for prettyprint.NIL. are global Therefore.e. resets linelength to the value of filelinelength. def=T means expr is a function definition. no lrpars is initialized to 4. COND's. not rebound. prettyprint printdef[getd[fn]. Initial Comments run between firstcol and 77••--••••••••••••••0••••••a•••a•••••••••-••••o•a••••••O••••••••••••••••••••••• Note that makefile.66. firstcol. and when printdef is called from the editor via the command PPV. variables. i. i. 2 is used if left=NIL. Special Prettyprint Controls All variables described below. filelinelength is initially 72. brackets are used. 14. def is NIL when prettydef calls prettyprint to print variables and property lists. no special action will be taken for LAMBDA's.T]. 77 f irstcol is the starting column for comments.e. #rpars controls the number of right parentheses necessary for square bracketing to occur. #rpars. before calling prettydef. see Section 18. CLISP. or a piece of one. linelength[n] lf ~rpars=NIL.

such + as produced by clispify. Setting the . in the interests the of approximates + atom. 78 prettylcom is initialized to 14 (arrived at empirically). If a word in a conunent ends with a ' • • and is not on the list abbrev ls t. However. may occasionlly encounter + some + prettyprint. line. begins on a the new next word Also. rather than calling nchars. encountered in a conunent.£2. + satisfactorily in most cases. users with + unusually long atoms in their programs.g..line length. greater than halfway.56 the characters in each This procedure works output produced by The value of #carefulcolumns tells instead + in of prettyprint + glitches number efficiency. and the position is greater than halfway between firstcol and linelength. e. + prettyprint how many columns (counting from the + right hand margin) in which to actually compute + nchars + lcarefulcolumns to 20 or 30 will eliminate + 14. instead of f!rstcol. a conunent bigger is prettylcom in size.!:!. when computing + how much will fit on a line. prettylcom If . in if and the the a comment list is position is the list begins on a new line. it (using is printed .!il) than starting at column 10. of approximating. + #carefulcolumns .

57 . + it slow widepaper[T) sets filelinelength to 120. to 80. This is a usefu 1 setting for prettyprinting files to be listed on wide paper. firstcol and prettylcom to 28. (FOO (X V) . then corns) (FOO A B) appearing in the third argument to prettydef will 14. Ir prettydefmacros. The value of widepapor is its previous setting. page 14.above widepaper[ flg) glitches. printdef uses prin2 instead of prettyprinting. #carefulcolumns is initially + o. initialized to prettyflg corrunentfl~ is Ill If prettyflg is NIL. prettydefmacros Is an assoc-type list for defining substitution macros appears for on prettydef. as if it Note that the file loads the same were prettyprinted. the expression is treated as a comment. widepaper[] restores these parameters to their initial values. This is useful for producing a fast symbolic dump (see FAST option of makefile. clispifyprettyflg used to inform prettyprint to CLISPH'Y selected function definitions before printing them.66). commentflg If ~ of an expression is ~ to c?rrunentflg. although will down -e- prettyprint slightly. See section 23. prettyflg is initially set to T.

a tod + before substituting ·in the definition + command. ·~hen (FOO A 8) will cause (AB) to be substituted for X throughout £2.58 . 79 + the command. is If the it is prettyprinted in other expression e. or + prettydef.g. + initially NIL. + If + prettyprint will ignore the expression. ill&!: of the command is . (* E x) expressions the result himself. so that the 'argument list• for the macro can also be atomic. and then £2!!!! treated as a list of commands for ~ (Le. eva lu. This gives the user the option of + computing + prettyprinted in its place. and of some if this found. time. + result is non-NIL. for example.This gives + the user the option of printing the expression · + himself in whatever format he pleases.. if (FOO X . + prettyprintmacros If the atom • follows the name for the is an assoc-list that enables the user to format + selected + expression being prettyprinted is looked up on + prettyprintmacros. (section 6).!!l!· 14. to the be prettyprintmacros is A comment of this form causes prettyprint . + corresponding entry is applied to the expression.£!! ~ to be evaluated at ( 111 E (RADIX 8)) as a comment in a function containing octal numbers can 79•---••••••-••••••••••••••••••••••••••••••••••••••••••••••••m••••••••••••••••• + + + + The substitution is carried out by subpair. . COMS) appears on prettydefmacros.cause A to be substituted for X and B for throughout V cddr of the macro).. of cdr application each of the NIL. + normal fashion.

or has a non-NIL property list. all comments consisted of upper case atoms.. 14. 82 i. Users with lower-case terminals can skip to the File Package sections (as they can type comments directly in lower case). do not change the atom (but remove the 1).. so-----------------------~-----o••··------------·---o·•··-------------------~-- User must type %% as % is the escape character. the first comment was (• %% INTERPRETS A SINGLE COMMAND). The output on the next page illustrates the result of a lower casing operation. convert the atom ·to lower case.g.be used to change readable printout. or has a top level value. 82 do not change it. is a bound or free variable for the function containing the comment. If the second atom in a comment is %%. first If the If the atom81 is an Otherwise. Before this function was prettydefed.e. Note that comments are converted only when they are actually written to a file by prettydef. first character is %. the radix to produce more The comment is also printed. the text of %% the comment is converted to lower case so that it looks like English instead of LISP (see next page). e. convert the atom to lower case.59 . The algorithm for conversion to lower case is the following: If the character in an atom is '. 80 lNTERL ISP word. 81 minus any trailing punctuation marks. Converting Comments to Lower Case Tpis section is for users operating on terminals without lower case who nevertheless would like their comments to be converted to lower case for more readable line-printer listings. or is a defined function.

comment and the first \Jhen character After converslon.ew. the comment is physically modified to be the lower case text minus the %% flag. i. atoms already converted to lower case converting. . first character in the following each period are left capitalized. so that conversion is thus only performed once (unless the user edits the conunent inserting addiiional upper ~ase text and anothe~ 14.60 %% flag). the are not changed · if the ·comment is converted again.Conversion only affects the upper case alphabet.

do NOT print value. pr1nt value.) (BREAKCOM1 BRKEXP BRKCOM NIL BRKVALUE) ( BREAKEXIT)) (OK (a Evaluate BRKEXP.(BREAKCOM [LAMBDA (BRKCOM BRKFLG) (PROG (BRKZ) TOP (SELECTQ BRKCOM [t (RETEVAL (QUOTE BREAK1) (QUOTE (ERROR)] (GO c~ Interprets a s1ngle command.) (BREAKCOM1 BRKEXP BRKCOM) (COND ( BRKFLG ( BREAK2) (PRIN1 BRKFN T) ( PRIN1 (QUOTE " EVALUATED T))) (SETQ !VALUE (CAR BRKVALUE)) (a For user's benefit.) (BREAKCOM1 BRKEXP BRKCOM BRKVALUE BRKVALUE) ( BREAKEXIT T)) (tWGO (A Same as GO except never saves evaluation on history. and ex1t.) (• Evaluate BRKEXP unless already evaluated. unless already evaluated.) (BREAKCOMl BRKEXP BRKCOM T BRKVALUE) (BREAKEXIT)) (RETURN (~ User will type in expression to be evaluated and returned as value of BREAK. and ex1t.61 .) II) (BREAKCOM1 (SETO BRKZ (COND (BRKCOMS (CAR BRKCOMS)) ( T ( LISPXREAO T] (QUOTE RETURN) NIL NIL (LIST (QUOTE RETURN) BRKZ)) ( BREAKElCIT)) (EVAL (* Evaluate BRKEXP but do not exit from BREA't<.) ) 14. Otherwise same as GO.

etc. LAST. ucaselst words on ucaselst (that do not appear on lcaselst) will be left in upper case.g. as English words. words that end in periods and occur more than halfway to the right margin cause carriage returns. to except for those on abbrevlst. and E. abbrevlst abbrevlst · used is abbreviations and to words distinguish that end in between periods. LENGTH.E. I. EVERY.flg] value is lower case version of ~· lf fl. l•case[rifJLE NOT FOUNOn. e. 1-case[FOO. 1-case[FOO] "' foo.g. in the example on the previous page. during conversion lowercase. ucase ls t is initialized to NIL. words ending in periods. . e.g is T. AND. the first letter is capitalized. GET. e.62 ~ "File not found". not was written as tNOT. Thus. GO. 1-case[x. abbrevlst is initialized to the upper and lower case forms of ETC. Normally.G.T] = Foo. the value of 1-case is also a string. lcaselst is initialized to contain words are which INTERLISP functions but also appear frequently in comments.T) u-case[x) Similar to 1-case 14. If ~ is a string. cause the first character in the next word to be capitalized. LIST. furthermore. and GO as tGO in order that they might be left in upper case.lcaselst Words on lcaselst will always be converted to lower case.g.

The essential point is that the COMS be computable from the name of the file. editv. PRETTYDEF(NIL FOO.File Package 8 3 14. The functions described below comprise a coherent package for eliminating this burden from They require that for each file.g. 84 85 file can contain a suffix and/or version number. DWIM corrections to user + reassignment of top-level variables. the deliberately vague statement that it does the or where 'right' sa--------------------------------·-----·-·-----------------------·-----------The file package was written by \. but instead + make thing with + respect to keeping track. 14.FOO. etc. of what has been changed.63 • • + + . as opposed to 'local' file operations such as those performed by print. 85 e. sfptr. * e.I. Therefore.g. The file package keeps track of which files have been in some way modified and need to be dumped. recompile. prettydef. prettydef[NIL. read.g. the + symbolic or compiled files reside in other directories. et al. etc. load. which files have been dumped. but still need to ba listed and/or recompiled. such as those cases + functions. tcompl. Teitelman. + loadfns. All the system functions that perform global file operations.84 • the user.. interact with the file + Some of these interactions are quite complex. It can be disabled by setting filepkgflg to NIL.3 FOOVARS) is acceptable. same function appears editf.TEM. the first argument to prettydef be * NIL and the third argument be fileCOMS. or were originally made + under a different name. as well as those functions that + change data stored in files. e.FOOCOMS]. in several different files. package. where file is the name of the file. this section will not attempt to + document how the file package works in each and every situation.9 This section describes a set of functions and conventions for facilitating the bookkeeping involved with working in a large system consisting of many symbolic files and their compiled counterparts. where the e.g. and what file operations + need to be performed in accordance with those changes. + etc.

14.Z]. to the list filelst. by the appearance of more than one FILECREATEO expressions. the the file package can be broken down roughly three noticing files. loadvars. and (3) updating files. For exam~le.COM. but <NEWLISP>EDITA.LSP is added to fileht.g.l.3 is added to loadedfilelst. (2) marking changes. + The property FILE is used to determine whether or no. both roo and FIE will be noticed. filelst.+ Noticing files + Operations in + categories: (1) + Files are 'noticed' by load and loadfns (or loadfrom.. value (( fileCOMS • type)). if the user performs LOAD[ <NEWLISP>EOITA . into For example. the property FILECHANGES contains the union of all changes since the file was loaded (1. loaded.SP. to the property list of + its + completely loaded. loaded as a compiled + file. loadedfilelst is not used by the file package.).t the corresponding file + has been modified since the last time it was loaded or dumped as described + below. each or the files mentioned in the FILECREATED expr&ssions are noticed. it is mantained for the user's benefit. user performs load[<TEITELMAN>FOO. if the user performs BCOMPL((FOO FIE)). e. the file package can detect that the file being noticed is a compiled file (regardless of its name). etc. filename ·with version number and/or directory field root name. For example. and e. EDITA will be added . since this name corresponds to the name the file was originally made under. 86 87 where ~ in~icates how the file was etc. + + + + + + + + + + + + 87 The variable loadedfilelst contains a list of the actual names of the files as loaded by load or loadfns.3]. Us~ of In addition.LSP. + adding the property FILE. and subsequently loadi FOO. if' ths All removed. to . and ((FOOCOMS • T)) is put on the property + FOO. + Noticing a · file consists of adding its root name . only partially loaded as with loadfns.64 . Similarly.e. and the property FILEDATES a list of version ao-----------------------------------------·------------------------·---------The computation of the root name is actually based on the name of the file as indicated in the FILECREATED expression appearing at ·the front of the file. + FOO. In this case.COM.COM . there may have been several sequences of + + + editing and rewriting the file). + i. + file operations in the file package are based on the root name of the file.

+ + + + + .. page 14. T) F002). makefiles. The use and maintenance of these + properties is explained below. after updatefiles has completed operating. FILE property is non-NIL. similar procedure is followed for changedvarslst. any procedure that requires the FILE property to be up to date. . • the user defines a new function but forgets to add it to the prettycoms for the corresponding file. adding it to the list changedfnslst. via a DYlM correction. the function is marked as being changed + by a function is changed.g. + Marking changes + Uhenever or + implicitly. the file package only knows about two "types": functions and variables. 90 ss--------------------------------------------------------~-------------------1ni tia11y.. file has been found. For..) This procedure is followed rather than update the FILE property after each change because scanning filelst and interrogating each prettycom can be a time-consuming process.g. FOOZ. both files? and cleanup print warning messages when changedfnslst is not NIL following an updatefiles.. this reason.. variables and A as with editing.numbers and the corresponding file dates. the . function or variable is added the function updatefiles + interrogating corresponding file. i. and is not so noticeable when performed in conjunction with a large operation like loading or writing a file.. 89 updatefiles operates by scanning filelst and the + When (if) such files are found.75 describes how to add additional types. 'getp[FOO. 88 Periodically. For example. + + .e. and addfile. 89 90 updatefiles is called by files?. and then calls + if ·• updatefiles. e.65 + .. 14. and the function or variable removed from changedfnslst or + Thus. is + called to find which file(s) contain the functions and variables that have been • changed. e. and F003...F!LE) will be ((FOOCOMS. either explicitly.. edits F002.name of the + to the value of the property FILE for the + prettycoms for each file. (The user can also invoke updatefiles directly. . the user loads the file FOO + containing definitions for F001.. the files + that need to be dumped are simply those files on filelst for which cdr of their + changedvarslst. cleanup.. . Functions or variables that remain on their corresponding changedlst are those for which no .

are + moved to the property FILECHANGES. + (rplacd) to NIL.! NIL. 91 In addition. the file is removed from notcornpi ledfi lcs. the user defined some functions and initialized the corresponding prettydoms without loading • file.options. dump all files that have been modified.66 . the and cdr of the FILE property is reset Whenever the user lists a file using listfiles.ll. i.g. or not prettydcf reprintfns. i. Makefile makefile[file. it is removed from notlistedfiles. is available to the user via the function files?. is written using makefile (described below). the state of all files can be determined. cdr of the FILE property.sourcefile] notices previously it sourcefile. or brecornpile. whenever a file iS compiled by tcomp\. list all files that have been dumped but not listed. the list and Performs calls fileCOMS.e. added to fITelst. or any combination of any or all of the above by using one of the function described bG'low.+ Updating Files + Whenever + functions/variables that have been changed. recompile. and file. the file is added to the list notlistedfiles a file and notcompiledfiles. This information Similarly. giving !. the user can see whether and how each particular file has been modified (by examining the appropriate property values). bcompl. changes as its ~1-------------~-------------------~------------------------------------------If the file was not cin filelst. then tho file will be •noticed' by virtue of its being written. Similarly. FILEDATES and FILE CHANGES properties.reprintfns.e. + + + + if noticed. e. and given appropriate FILE. linelength[filelinelength]. 14. Thus at each point. recompile all files that have been dumped but not recompiled.

e. causing CL ISP translations to be 92-----------------•••-~~•om•-•••••-••O•••e•••••mu•aoo•••m••~~au-ga~ao-o~--u••A fileCOMS are constructed from the name field only.g. CllSPIFV perform prettydef with clispifyprettyflg=T. and notlistedfiles. Note that i f file has property FILE TYPE with value CUSP. nor are they compiled even when options specifies C or RC.) 93 Files that do not contain any function definitions or those that have on their property list the property FlLETYPE with value DON'TCOMPILE. i. This list of changes is included in the FILECREATED expression printed at the beginning of the file by printdate. are not added to notcornpiledfiles. (these two version numbers and dates are also kept on the property FILEDATE for various integrity checks in connection with remaking a file as described below. which will cause clispify to be called on all functions marked as having been changed.TEM] will work. along with the date and version number of the file that was originally noticed. those items that have-been changed since the last makefile.e.67 a ~ • lll • • • • • . 95 Alternatively. prettydef merges those changes with those handled in previous calls to makefile. e. and stores the result on the property FILECHANGES.arguments. 92 then adds restores f :I. i. NOCLISP performs prettydef with prettytranflg=T. this one. The list of changes is simply cdr of the FILE property. the compiler wi 11 know to dWiinify its functions before compiling them. For more details. as described earlier. if file has the property FlLETYPE with value CLISP.· c calls tcompl after prettydef or bcompl if there are any block declarations specified in fileCOMS. and the date and version number of the current file. causing cl is pi fy (see Section 23) to be cal led on each function defin9g as an expr before it is prettyprinted. 94 Including any generated via the COMS command or via a prettymacro. notcompiledfiles. 14. 93 options is a list of options or a single option Interpreted as f~llows: FAST perform prettydef with prettyflg=NIL RC call recompile after prettydef or brecompile H there are any ~Jock declarations specified in fileCOMs. as described in section 18 and 23.le original to linelength. prettydef is called with clispifyprettyflg reset to CHANGES. see discussion of clispifyprettyflg in section 23. makefile[FOO.

14. given to the compiler as the answer to the compiler's question LISTING?. does not remake rue.!! has a FILEGROUP property.68 . ST. only some. the compiler will not be called until all files on this property have been dumped that need to be. and finally list the file. DWIM. FIX. e.default for all calls to makefile is to remake. + Remaking a symbolic file + Most of the time that a symbolic file is written using prettydef.g. the. The ~EW option i i provided in order to override this default. in place of the corresponding CL ISP expression. CLISP. 96 If F.(C F LIST)] will dump FOO.!. A considerable savings in time is afforded by + copying the prettprinted definitions of those functions that have not changed + from an earlier version of the symbolic file. then tcompl or bcompl it specifying that functions are not to be redefined. EDIT and WEDIT are one such and DWIHIFY another. or S is the next item on options following C or RC. For example. + NEW flli. + usally a few. It lt lt lt LIST calls listfiles on + REMAKE 'remakes'· file. See discussion below. STF. group. The user can indicate that f Ue must be block compiled together with other · files as a unit by putting a list of those files on the property list of each file under the property FILEGROUP. makefile[FOO. iterative statement.g. e. of the functions that it contains have· baen changed since the + last time the file was written. If !.printed. H any. + + + and prettyprinting only those ~a----------------------------------------------··----------------------------1r makefileremakefl~ is T (its initial setting).

although it is considerably faster if one does exist. 14. ~ighest prints the message "file NOT FOUND.e. and prettydef does not begin scanning from the beginning of the file each time. changes to ~ or property lists. The scan utilizes skread (page 14.69 + + + + + + + + + + + + + + •+ + . those not specified by reprintfns. e. + as it does when reprintfns and sourcefile are both NIL. + sourcefile=T means use most recent version (i. SO IT WILL BE WRITTEN ANEW". or EXPRS meaning + prettyprint all functions with EXPR definitions. up and pick up a function previously skipped.functions that have been changed. although not as great a savings as occurs when a map is available.g. Makefile and Remaking a file arguments to prettydef. prettydef is able to back. remaking is intended td be used When a makefile remake is being 97----------------------------------------------·-----------------------------Remaking a symbolic file does not depend on the earlier version having a file map.e.never has to scan very far. prettydef scans the file looking for the corresponding definition whenever it is about to copy the definition to the new file. or ALL meaning prettyprint all + functions either defined as exprs or with EXPR properties. prettydef . 98 Note that doing a remake with reprintfns=NIL makes sense i f there have been changes in the file. prettydef also builds a map of the functions it has skipped over so that if the order of functions is reversed in the new file. reprintfns and sourccfile. prettydef has two additional arguments. which performs a number of 'do-what-l•mean' type or • services in this context. and proceeds + While a file can be remade by appropriately specifying the reprintfns and + sourcefile in + conjunction with makefile. 97 To this end. but instead 'walks through' the original file as it is writing the new file. The net result ·is still a significant savings over (re)prettyprinting the entire file. but not to any of the functions. • reprintfns can be a list of functions to be prettyprinted. In the case of a remake where no file map is available. 98 sourcefile is the + name of the file from which to copy the definitions for those functions that + are not going to be prettyprinted. prettydof ~ the second argument to prettydef. Since the functions are for the most part in the same order. + If sourcefile cannot be found.18). However. as described below. number) of prttyfilo. i.

+ lOO The user can specify reprintfns as the third argument to makefile. + EITHER THE PREVIOUS VERSION OR THE ORIGINAL VERSION OF file. and specifying as reprintfns the unioh of + all + property.+ performed. SO IT WILL HAVE TO + BE WRITTEN ANEW". 99 prettydef will be called specifying as reprintfns those functions + that have been changed since the last version of the file was written. (~age then FILE CHANGES 11 CAN • T FIND 14.ains from the If both of these fail. lf loadvars If will + ~~--------------------------~-----------~---~---------------------------------The normal default for makefile is to remake. but not the compiled file. makefile also checks the state of the file (f. which 1t obt. + 'When a remake is specified.e. + the changes file obtains the full name of the most recent version of the fil~ ~tored date as that on If it does. makefile will attempt to remake using the original varsion of + the file. Note that the user can override this default for particular file~ by using the NEW option (page 14. i. as indicated by the value of makefileremakeflg. 14.70 . in + + + + + + which case the above checks are not executed.64). and has the same + the FILEDATES property. 10 + sourcefile. i.. the user·does not ~ave to explicitly include REMAKE as an option. 102 This procedure permists the user to load or loadfrom a file in a different directory.Qfil: of + the FILE property) to see how the file was originally loaded + the file was originally loaded as a compiled file. and hence have not been loaded. + 101 The user can also specify sourcefile as the fourth argument to makefile. + file as sourcefile • 102 In the case where the most recent version of the file + cannot be found. initially T.e. makefile calls prettydef specifying that that have been made. makefile + file (that it knows about) 101 from the FILEOATES property. and still be able to makefile-remake. and checks to rnllke + sure that the file still exists. makefile will automatically + call loadvars to obtain those DECLARE: expressions that· are contained on tho + symbolic file. the one first loaded. makefile prints the message was ° For loaded by loadfns (but not loadfrom). and then calls prettydef with reprlntfns and sourcefile=NIL.68).

files) For each file on files that has been changed. makefile does not call prettydef. then calls a lower EXEC via subsys (section 21).!!!• (if NIL. e. mak.efileremakef'lg is NIL. performs makefile[ file . • makefiles[options. LOADED. if any functions have been defined or changed that are not contained in one of the files on filelst. nospread function. notlistedfiles is used) followed by a QUIT command. e. or whether the REMAKE option was specified." Similarly. a message is printed alerting the user. makefiles[ LIST] will make and list all files • 104 Value is a list of all files that are made.g." In both i f only some of the symbolics were load via cases. The EXEC will then read from 103----------------------------------·--··----------····----------------------I f the file has never been loaded or dumped.e.g. the user simply set up the fileCOMS himself. 14. listfiles[ files) nlambda. setting of makefileremakeflg. then makefile will never attempt to remake the filo. but instead will call prettydef with sourcefile=reprintfns=Nll. 103 If a remake + is not being performed.options). makefile checks the state of the file to make sure that the entire + symbolic file was actually loaded. If the file was loaded as a compiled file. 1 . and returns + (file NOT DUMPED) as its value. Uses bksysbuf to load system buffer appropriately to list each file on !!. If files = NIL. 71 + + + + + . loadfns or + makefile prints "CAN'T DUMP: ONLY SOME OF ITS SYMBOLICS HAVE BEEN -c- loadfrom. regardless of the . 104 In this case.automatically be called to obtain the non-DEFINEQ expressions. + makefile prints the message "CAN'T DUMP: ONLV THE COMPILED FILE HAS BEEN + LOADED. filelst is used. or the option NEW was + specified.

compilefiles[(STF)] will compile each file on notcompi ledfiles so that the functions are redefined w:I. nospread function.g. it is interpreted as the options argmument to makefiles. 72. and the value of listfilestr. or advise or redefine listfilest for more specialized applications. dumped ~ut not compiled. + + + + brecornpiles) Dumps.>". Executes the option of makefile for each member of files. .the system buffer. e. 106 Each file listed is removed from notlistedfiles if the the user + control-C's to stop the listing and QUITS. if <fi le· name> NOT FOUND" and proceeds to the next nlambda. thout the exp rs being saved. For + each file not found. and QUIT back to the program. (or + + + + + + any and all files on files ios·----------------------------------a·--------------------------------------11str11es calls the function listfilesl on each file to be listed.g. 14. dumped but not listed. notcompiledfiles is used. listfiles prints the message + 11 + file on files. cleanup[ files] nl&mbda. RC (If files=NIL. compilefiles[files) listing is completed. initially ".) 106 files?[] Prints on terminal the names of those files that nave been modified but not dumped. The user can reset listfilestr to specify subcommands for the list command. plus the names of those functions (if any) that are not contained in any file. e. LISTS. This feature can be used to supply an answer to the compiler's LISTING? question. list the files. listfilesl computes the appropriate string to be fed to TENEX by concating the file name. and recompiles 106 If car of files is & list. nospread. lists.

107 is the name of a prettycom.requiring the corresponding files = NIL.should fir. However.73 + + + + + + .system JtleCOMS are clobbered to save . whereis[x. i f clennupoptions is (RC F). or the name of any other prettydef command. variable. If ~=NIL. no listing will be performed.e. filefnslst knows 1. newfile2 elements of type ~· returns a list of all (filefnslst and bcompl and brecompile use this option. he .st the location of a .st load the Ji le <LISP>fl. ~=T is and commands iru=NIL is equivalent to FNS. is equivalent to VARS. ~ is usually FNS or VARS but may be BLOCKS. Therefore. it will be interpreted as the list of options regardless of the value of cleanupoptions. 14.s be available. etc. newfile2[name. Similarly.coms. Alternatively. in INTERLISP-JO. in file.files) ~ operation.) io1·-------------------------------------------------------------------Q------The user can affect the operation of cleanup by resetting the variable cleanupoptions. filelst is used.s requires that the JileCONS oj the corresponding Jile. files=NIL equivalent to (the value of) filelst.type.type) £Q!!!! is a list of prettydef commands. etc. \<1hereis sweeps through all the files on files and returns a list of all files containing !· whereis knows about and expands prettydef all prettydefmacros.system junction. 1Vote fi lefnslst[ file) returns a list of the functions specified by fileCOMS. about prettydefmacros. For example.. If Value is Nlt.space. initially (LIST RC). ARRAYS. if car of files is a list. iJ the user wants to a. and no functions will be redefined as the result of compiling.JS/ViHlS. the . that wherei. and equivalent is to (APPEND FILELST SYSFILES).

The user can supply this information by putting on the property list of the prettymacro.lf !1!. under the property PRETTVTYPE.) If the user often employs prettydefmacros. £21!!• ~· ~. newfile2 returns "contained" in £2. e. Thus.!!• where . and and !l!!!!! corrrespond to the arguments to newfile2.!!!!· T if !l!!!l! is (whereis uses newfi le2 in this way. and to if FNS. this expansion would not be necessary.) Otherwise.74 ~ .g.s.JOB a function (or LAMBDA expression) of three arguments. the user may have a macro called GRAMMARS which dumps various property list but no functions.!!!!=T. a large number of If the user could inform the file package as to what his various prettydefmacros actually produce. their expan~ion by the various parts of the system that need to interrogate files can result in conses and garbage collections. The result of applying the function to these arguments should be a list of those elements of type 14. For example. the file package could ignore this command when seeking information about FNS. so. newf ile2 returns T if there are anv elements of type !ill· (makefile uses this option to determine whether the file contains any and therefore whether it whether should be contains to call compiled~ any BLOCKS. GRAMMARS. determine bcompl/b~ecompile or tcompl/recompile.f!!!! is a prettydef command. and !!!!!!.

The function newfile? should be used to mark elements of other types as being + changed. to move them to their respective changedlst. i f name is a list. As described on page 14 . However. or prettytypelst (CHANGEDVARSLST VARS)). it is added to changedfnslst o~ changedvarslst respectively by newfile? (see below). 110 If string is supplied. it is sufficient to return a list of only those elementsof type typo contained in com that are also contained in name. i t is sufficient to return T i f there are anv elements of type type in £Qfil· Similary.65.IJO is If initially the user For ((CHANGEDFNSLST FNS "functions") adds (CHANGEDGRAMLST GRAMMARS) to prettytypelst.!n. makefiles will warn the user that some elements of this type are not going to be dumped in the event that it could not find the file to which they belonged. 109 Currently. such as calls to whereis that edi tf performs when given a function without an expr (see section 9). example.ontains any of the functions on changedfnslst The user can tell the file package about other types by adding appropriate entries to prettytypelst. The user nay take advantage of . files? will inform the user if any elements remain on the changed list after updatefiles has completed. whenver a function or variable is changed. note that simply returning a list of all elements of type ~ found in £Q!!! will always work. Updatefiles operates by mapping down filelst and using newfile2 to determine if the corresponding file changedvarslst. when ~ is an atom other than T or NIL.st type string). i. the file package knows about two "types": functions and variables. when name=T. Similarly. where string is optional. Each element of prettytypelst is a list of the form (name-of-changedl:l. + 109---------------------------------------------------------------------------Actually.75 + + + + + -i- + + + + .contained in £2. then updatefiles will know to move elements on changedgramlst to the FILE property for the files that contain them.e. finally. 14.these conventions of newfi le2 to reduce the number of conses requ ired for various file package operations. c.. return T i f name is contained in com.

!!. . newfile? 14. e.changedlst) changedlst is the name of a changedlst.fil! to changedlst. is DWIM.76 CHANGEDGRA~ILST. newf ile? Value editor.newfile?[name. is used by the etc. + CHANGEDFNSLST. + .!!!!!· + define.g. + (undoably) adds !1!. etc.

..........75 14..28-29................14 .....•...67 14......... 35 14.... ......53 14..... control-S .11................... CLEARBUF[FILE...... C (makefile option) ...2 14................•...•... INDEX............••• ... ..•..............•.............36..28-29.......•.....43 14. .....•• CHANGEOFNSLST (file package variable/parameter) ....... ...13.... BCOMPL . COMS ( prettydef command) .51 .....••... ALLPROP (as argument to load) ...13-16..•.••..........•..men ts (in listings) ..FLG] SUBR ••••••••••••••••••••••••• CLISPIFY .•...•..46-47.......•......65....21 14...72 14..59-62 14.••• 9 •••••••••••••••••••• control-D control-E control-f • • • • I • • • I • • • I I • I I • • • • • I • I • I • • • a I I • • • • • I I ' • ill 9 ill I • I I I I 111 I 9 I I I 111 I t 9 I 111 I I I o I 9 I I I 111 9 9 I I I control-H control-0 • I ol I I I I I I I I I I I I I I 111 I • I 0 I I I I I I • 111 I 9 I I 111 I 9 I I • • I I I 111 I ill I I I 111 111 I I I I I <II I I I I I I I I 9 I I 111 I I I I I I I I 111 I I 111 I 111 I I I I I I I 9 I Ill I I I I I I I I I I I I I 111 I I 9 t I I I 9 I control-P control-Q I I control-R ....................16. COMMENTFLG (prettydef variable/parameter) ........•..51 14..50 14.......•......... COPY (declare: tag) ..67 14.•..•.......... .•.... CLISPIFYPRETTYFLG (prettydef variable/parameter) . ....•..... ....... CLEANUP[FILES] NLA ....30 ........... •••••••••••••••••.......... BAO PRETTYCOM (prettydef error message) ...... CLOSEF[FILE] SUBR ....... BREAK (syntax c 1 ass) ...... BREAKCHAR (syntax class) •...21........ .• .•................62 14................ control-V .........25 14........29..............33 14.67 14...23.•••• ADVICE (pr et tydef command) . .. break characters .•..............4 14............23 .75 14.••......35-36 14.... ......11-13. 14...•......•.•.... .65....... . ADVISE ( prettydef command) ..16.73 14....... ...........32-35 14 ....29 14.......... crJTRLV (syntax class) ...•. .. .67 14.56.. 14.............36 14...........•.....51 14......57 14..... ..35 14..39 14..TTBL) SUBR •••••••••••••••••••••••••••• control character echoing .............16..... com......... .49 14...51 14.....••.••...... ... 29 14.... 33-34 14....16............•....•......•.......1 14....•.. .. 35 14.....13. bell (typed by system) .....11.... ..•..17-20........................... ...29................•• addressable files ADOVARS (prettydef command) .......31 14.38 14. BKLINBUF[ X] SUBR .... .••.57...•• carriage-return .................... COMPILEFILES[FILES] NL* ..12.......51 14........ .... BKSYSBUF[X] SUBR .......•..52 14.•• BLOCKS ( prettydef command) ..........•••• CLEANUPOPTIONS (file package variable/parameter) . BUILDMAPFLG (system variable/parameter) .72 14. . CONTROL[U... AFTERSYSOUTFORMS (system variable/parameter) ALL (use in prettydef PROP command) .......• COPYREAO TAB LE[ ROT BL] SUBR .....................51 14....31..4 14.25.......21 14...........35 14......71 14. ..•..67...........•... ..67 14......5 14...........• BRECOMPILE ...........•.72 14...25-26 14...34 14... block declarations ....35 14.... 33·35 14.•.••...................•................ CHARDELETE (syntax class) .... C LOSEALL( ] SUBR ....Index for Section 14 Page Numbers ABBREVLST (prettydef variable/parameter) •....•..... CHANGEDVARSLST (file package variable/parameter) ........ ..... ..11-12.. CLISPIFY (makefile option) .31......29 14.. ARRAY ( prettydef command) ..•.••...... control-A .......

...........30 14..•••••••••••••••••••••••••••••• FILEGROUP (property name) ....•... FILEMAP (property name) •. ...42-44 14. DELETECONTROL[TYPE... o ••••••••• : •••• ESCAPE (syntax class) .......••••• EVAL@COMPILE (declare: tag) .••......70 14...••....MESSAGE..•........29 14.••....57.71..•.. .. mar... nar....50 14...... DONTCOPY (declare: tag) .........• echoing .... ..38 14.29 14...••....•........••••..•. ENDFILE[Y] ........ END OF FILE (error message) .• ...••..........Page Numbers COPYTERMTABLE[TTBL] SUBR ..........••....52 14......••••..39 14.••. .51 14....•....•...• ESCAPE[FLG...63·75 14.•..12 14......66-67.•••... s:ymbolic dump •••••••••••••••••••••••••••••• (nakefile option) .TTBL] .....•••••••••••••••••••••••••••••• FILECREATED ...........•.. .......••.••..•........3-4.54. ECHOCONTROL[CHAR..........67 14...... .•••••..........15 14 ..66 14..)<] ........•.....•••• DOEVAL@LOAD (declare: tag) ................•.63 14.• E (in a floating point number) .•.... ..........55......52 14.••....52 14.. . DELETECHAR (syntax class) .•..•• FI LE \.. oorHEVAL@COMPILE (declare: tag) ••••••••••••••••• DONTEVAL@LOAO (declare: tag) ..73.25 14.••....•••.... FILE NOT OPEN (error message) file package ...52 14..... .•......11 14.... ........••...... .9 14...........•• EXPR (property name) fast FAST FILE file file FILE .........•••••••••••.....• E (prettydef corrunand) E (use in comments) ..•.••...............30 14.•....31 14..•••...•.3......54 14. 14................52 14...........••••• NOT COMPATIBLE (error message) ..........64...••....... 2 14. FILECHANGES (property name) ····················• FILECOMS[FL...7....... ....•.....•....ION' T OPrn (error message) ....••••••••....•..68 14..............•.•.......••. ..........•.52 14.•..2°3 14......•..•... CTRLV (syntax class) .. FILEDATES (property name) ....... ..38 14......53-54 14..... DECLARETAGSLST (prettydef variable/parameter) DECLARE:[X] NL* •••••.52 14.70 14...MODE... ...• file pointer .......... DOCOPY (declare: tag) ....66 14.........•......TTBL] SUBR ••••••••••••••••••••••••• EDITRDTBL (system variable/parameter) ...••••••••••••••••••••• DEFLIST[L.19 14..••.28-29 14.••••..... CREATED (file package) ...•.29 14..67....•....s ...........••.....52 14...64...••••••••••....28·29 14....•.••..••..... FILELINELENGTH (file package variable/parameter) . FILE (property name) .............• DOEVAL@COMPILE (declare: tag) •..les ......• DELETELINE (syntax class) ......• .TTBL] •.57 14.......•....................••• EVAL@LOAD (declare: tag) .. ....•...•......••.....•.........2 14...........• DECLARE ....••..... FI LE llOT FOUND (error message) ...••...•.•...•.49 14. . ECHOMODE[FLG..••...64.....••••• FILEPKGFLG (file package variable/parameter) INDEX.....52 14....... . ".. EOL (syntax class) ...•••.....31 14.....54 14......... ......11...••..••••...........22 14.....52 14.......... end-of-line ...••.. DFNFLG (system variable/parameter) .......5-7 14..•.•...............11 14......•.••••• ...43 14.•••.RDTBL] SUBR •••••••••••••••••••••••••• escape character . FILEMAP DOES NOT AGREE WITH CONTENTS OF ftle-name (error message) .•.....PROP] ..•.....••.58 14....6....• FILEFf~SlST[FILE] •.••...•........44 14.....75 14........... ........63 ................ ...•............•....39 14.• FILELST (file package variable/parameter) ....73 14..

..57 14..... ..........• 14....• 14 ............75 14..... 14...•...... GETF ILE MAP[ FILE.... GE TSE PR[ RDTBL] SUBR .. 14..... 10 14.....PRINTFLG] ..12-13.....8-10 JFNS[JFN....... .......... IF PROP ( prettydef command) . 14.........•...29 14........39 LOADBLOCK[FN.......... ...... 14.....40 LOADFROM[FILE...... Ff.................... ..........•...........IS (prettydef command) ..... asst........66........ ............•.LDFLG] .37.......... · · · · · · · · · • · · · · · · FILETYPE (property name) .. 14....LDFLG] ...30 14...........•...2.... 14......18...V....8-10......3-4 GETBRK[ RDTBL] SUBR ..............35 LI!JEOELETE (syntax class) .......... 72 literal ator..•............... .FILE.......1-10 14............12 LOAD[FILE.. ..........36-37 14..........41 lower case ..FILE...33.... INFILEP[FILE] SUBR ....... ............. 14..................•....... 14...is ..•..7-8 14...25 LHJBUF[FLG] SUBR .•.....•••..................•.. .TABLE] .55 14.........•..... ... • .......68 LISTFILES[FILES] Nt...22-23..41 LOADVARS[VARS.........16-17.......... ......• 14...... .... .55 line-buffering ....6-7 J Fr~ ........28-29 14....6 14... FLTFMT[N] SUBR ........•.......... INFIX (type of read macro) .62 INDEX...67 14...... ..............43 14.....•...... 14... ..................... .50 14......•........ 14 ....... files ........15 14...............VARSJ ....... variable/parameter) 14.........•.......14....•.................................•••••••.••....•••............. 14 .35-36 1 ine buffer .....28 14.....•.....3 .. ..... · ... FILES?[] .. 12 14..64 LOADFNS[FNS...... 15 14.......44.72........22 14 ..... ·14..... FILERDTBL (system variable/parameter) ..... floating point numbers .....•.............. 14......FNS...... 14..... ILLEGAL READTABLE (error message) ...•..19 LISPXREADFN (prog.........32................•••..29............. ...11....... ............... GETREADTABLE[RDTBL] SUBR .................. ................LDFLG... .. 17 LIST (makefile option) .....25 LEFTPAREN (syntax class) ... Ff~S/VARS . ..•.. GTJFN[FILE.FILE.... 14.........16........•........ ILLEGAL TERMINAL TABLE (error message) ·········· INFILE[FILE) SUBR ..•..... global variables .............. 72 LISTFILESl[FILES] .................... 14........ .... 14..... 14..47 14.................................. 14..........51-52 14......•.....•.•.......39.......... ....... 14...... ILLEGAL ARG (error message) ............11-19 input/output ... 14..37 LASTC[FILE] SUBR ...............10 JS YS ......... 14....•.............31 LINELENGTH[N] SUBR ..55..... ...•.••......62 LEFTBRACKET (syntax class) .....................•...FLAGS] .....111 •••••••••••••••••••••••••••• 14.. ......24 14...LOFLGJ .27 IUPUT[FILE] SUBR ... 16 LCASELST (prettydef variable/parameter) ....25 14....68.Page Numbers FILEPOS[X:FILE............. ................. 14.......•.... 73 14......•...•.................. 14......... FL] ....•........................•...........35 input functions .. forr:iat characters .•••••....• 14..............••.32·35 line-feed ............. .LDFLG.1-75 IOFILE[ FILE] SUBR .... 1 input buffer .......42 LOADEDFILELST (file package variable/parameter) 14..... ...21.... .........• 14.AC3] ...71 LISTFILESTR (file package variable/parameter) 14......... GETTERMTABLE[TTBL] SUBR ...... .EXT. . GETSYtHAX[CH.....66...........SKIP:TAIL] ......START:END.............. FIRSTCOL (prettydef variable/parameter) ...

•..........••.... ..•..•.•..••••..• 14.. • ...•.••.••••••...•...47-55......• MAKEFILE[FILE..21 output functions ......75 14...•........•••.....••.....73......... 14 ...••••••........23 OUTFILE[FILE] SUBR .• 14...Page Numbers lower case comments .. .....•....REPRINTFNS.. .•....•.........•.............•••••• 14............54 PRETTYLCOM (prettydef variable/parameter) •......••.•••.14 .......•••••..........••.••••••..........•• 14........ 14..68 14....66..••..4 . .2.••....••.....•.12..68....•••.•.....X) SUBR .•.........•••.•.... FIOIJE (syntax class) ..... .... 14.•••..•.....•.••• NOT FOUND.••.•....47 PRETTYCOMSPLST (prettydef variable/parameter) 14.REPRINTFNS.•• 14.•.•••...••...•....•••.•.....• 14.... tlOCLISP (makefile option) .33 PEEKC[FILE] SUBR •••••••••••••••••••••••••••••••• 14... ..................OPTIONS.... ....•..•..••... ... margins (for prettyprint) .57...6-7 OUTFILEP[FILE] SUBR •. 14... .•••..•......41 numbers .....49-53 PRETTYDEFMACROS (prettydef variable/parameter) 14.... .......•• NOTCOMPILEDFILES (file package variable/parameter) NOTLISTEDFILES (file package variable/parameter) •..... ( t~OT PRIUTABLE) •...66-67....•••••••••••• .FILES] ..FLG] .......•......75 14 ...••••..67 14.SOURCEFILE) MAKEFILEREMAKEFLG (file package variable/parameter) .....32 14.. 14 ......•.UPOATEFLG) ····~········· tlEWFILE?[NAME.......••..71 14.72 14.53 PRETTYDEF[PRTTYFNS:PRTTYFILE...•••............26 14....••..... ••• 14 .• MACRO (type of read macro) ....•.• 14............19·21 P ( prettydef command) .....8 opening files .•...3-4 OUT PUT[ FI LE] SUBR ....• 14......•.......• 14...72 14....•..58 PRETTYTABFLG (prettydef variable/parameter) 14 .......45 (error message) .TYPE] SUBR .••• 14.....76 14...66-67..• 14..•...•..COMS.16... ......CHANGES] ....•...•......69 14'46 14...62 14...59-62 14.67 PRETTYHEADER ..........•. .....57......•..•..........45 PPV (edit cotnmand) ...12..•.....•. .....49 14....••••...•..•••••••• NOT FOUND (error message) ....... 14........35 POSITION[FILE] SUBR ....FLG.••• NO propname PROPERTY FOR atom (error message) r~oa1r~o ..19 OPENF[FILE....8 OPIJJFN[FILE] SUBR ••••••••••••••••••••••••••••• •• 14.5.52...• 14. lower case input ...•.. NOT DUMPED (error message) .30 14...... 14........•••••••••••.•••••••...••.... 14..... 14..........22 OTHER (syntax class) .PRTTYCOMS..•..•..••••••••••••••.... INDEX..••••••................. ....•...32 14.• MAKEFILES[OPTIONS. 72 14...•..... .• 14. NCHARS[X... L-CASE[X.••.66 prettydef commands .••...•••.TYPE...• ·......CHANGEOLST] •.......RDTBL) SUBR •.••.73-74 PRETTYFLG (prettydef variable/parameter) .••.14.7 14.... ......• NEWFILE2[NAME.......••...•......•..••••• 14.......~9 14.....••.••...37 PP[X] NLS!: ..71... .....57...... NEW (makefile option) •....•.... PRETTYOEFLG] ..1 OPENP[FILE.......9 ORIG (used as a readtable) .............•....••...........•...... 1 output buffer ...•....3.....•••••••••••••• NORA I SE (TENEX command) ..•....•....... SOURCEFILE.•..12-13 octal .71-72 r10T-FOUrJD: ...........45 PRETTYPRINTMACROS (prettydef variable/parameter) ...•••.....•••....•.63.....•••••..56·57 PRETTYPRIIH[ FNS.•... SO IT WILL BE WRITTEN ANEW 14..•••.•......••... . ..•....... ..68 14...54 14.••..•. ~ ......50 parentheses counting (by READ) ..• 14....•.55 PP>!t(X] NLt!: .....

.•...•..••••••••• RPAQ[RPAOX.••. primary terminal table .........12..64 14....••••• READMACROS[FLG..67.•.57 14....... READ[FILE..•.••.••.•••...... PRINT[X..••......•.....29 14..•...••...... 7 14....•...25 14..•...........•.•••••.• RC (makefile option) .25.FLG] SUBR .•••.••••••••••••••••••••..•..10 14.••••• PRINTDATE[PRTTYFILE....•.•...•..•••••.......•• readtables ..•.........•.••.....11.•••.•...••.••... .....•.•• QUIT ( tenex conunand) ......27 14 .....•••.Y] NL ....•.•.•.....••.•...•..•...27 14.RPAQY) NL .•....•...........•. RATOMS[A..•.....•••..28-29 14.•......FILE] SUBR .......32 14. .4.•..•.20 14 ...••..••• 0 (following a number) .....•••.... PRETTYTYPELST (file package variable/parameter) primary input file ...LINE.1-2...•..•........74 14.1....•....•••• READTABLEP[RDTBL] SUBR ••.• (REDEFINED) (typed by system) ••...••. SETREADTABLE(RDTBL....• PRINTDEF[EXPR...............••..•.••.......• RIGHTPAREN (syntax class) ······••••••••••••••••• RLJFr~[ JFf~] .•... RE ADC[ FI LE] SUBR .21-27 14.•••• SEPRCHAR (syntax class) ...••.......•••..•.•••••••••••••••• INDEX. PRHH[X..•........••••.....•••••••••••••••.•••..........25-26 14.......FLG] SUBR .......•..•.••...••••..•..FLG] SUBR •••.•• READFILE[FILE] ...........•..•.....•.•...25 14 ..•...•..33 14....52 14...•..RDTBL] .•....•.. 11.•......• RAISE[MODE...•••.71-72 14.54 14....•..13-14 14. PRETTYTYPE (property name) .4.•.... 19.••..•.....RDTBL.•••• ....19-20 14...•.•..•.....•.•••••. READVISE ...•..•.•.•..•. PRIN2[X..49.TTBL] SUBR ..•••...••...•...•..•••...•• READLINE[RDTBL.•...•...•••......•....••.•••••...23 .......•.•... 39..•..••••• SEPR (syntax class) .......... 29 14....26-27 14..•••...•.•....54 14.....68 14.CHANGES] ..•.•....••• SETBRK[LST.••••...23....15 14.•...Page Numbers PRETTYTRANFLG (clisp variable/parameter) •..36 14.•..17-18 14.... ....34 14.•......19.. primary readtable .........•..24..•.13 14.••...•••.••••••.36 14..72 14.23 14...........••• read macro characters ..20·21 14...15....••.•••.....•••..39.•••...• PROP ( prettydef command) .FILE....• rubout ..•.•.. .....••.•• READP[FILE.... ...54·55...••.39 14......• RAISE (TENEX command) ..••.•....75 14......••........••••• RPAQQ[X. 22.....•• RECOMPILE .•..RDTBL] SUBR ....•......•••....•...LEFT. .25 14.•...13-16.............•• RADIX[ NJ SUBR ..•• RIGHTBRACKET (syntax class) ..••••. RESETTERMTABLE[TTBL...35 14.....•..•••..•..39 14 ...•.RDTBL] SUBR ..67 14.. 4'8 14....19-20 14..LISPXFLG] ••.20 14.. RATEST[X] SUBR ....•. REMAKE (makefile option) ...•..•••••••• RSTRING[FILE.FROM] SUBR ...•..5 14.....••..•••...•••.••••••••.•..OEF....12....••.••..•••......FROM] SUBR .•......••••.••.19...••.•...14..•...••..FLG. separator characters .• reading from strings .•........ searching files ..••••• RETYPE (syntax class) .•.••• RESETREADTABLE(RDTBL....••••••••••••••••••••••••••••••••• PRINTLEVEL[N] SUBR printlevel ..RDTBL] SUBR •••••.19 14.•.PRETTYOEFLG] .• primary output file ....19.......32 14....•• RATOM[FILE.FILE] SUBR ......•...••...•.34 14 .......RDTBL] SUBR •....••••••••••••.•••..•••••••...•••.•....•....29 14.•••••••....11 14..•••.13 14....11 14..•••..12-14....•.. 51 14........ ..•.......•••.67 14 • 11-12.22 14..........16 14..•..FILE] SUBR ..... 34 14........•••. PR INTFr~S[ X] •••........•.••••• root name of the file •.•.• READ-MACRO CONTEXT ERROR (error message) .•......•...••....•....48-49 14 .......•..•.••...........

•....•.....•.......• spelling lists ..•••..62 14...........56 14...19..............••...••..•. .....•......•...35-36 14....... •••••••••••••••••••••••••• ..20 14.. STOP (at the end of a file) •......MINSPACES... .........52-53 14....15 14.....••.•..........CLASS..•...59 14..•......•....••..14 .......•.ADDRESS] SUBR ....54 ....SkIP.... TERMTABLEP[TTBL] SUBR ••••••••••••••••••••••••••• TERPRI[ FILE] SUBR •••••..EXPRFLG] •••••••••••••••••••••••••••••••• VARS ( prettydef command) version nurabers .....START...20 14...... USERMACROS (editor variable/parameter) .........•.•.••..65....•.•... . % (escape character) .44...........•.44 14.. square brackets (inserted by prettyprint) .• syn ta:......•....... SYSPROPS (system variable/parameter) .44 14.46........ 33-34 14...........24 14.....51 14. symbolic file output ....•••••••.. UPDATEFILES[PRLST.........•.......71 14............. SFPTR[FILE.29 14...... classes " ... WIDEPAPER[ FLG] •••••••••••.44-55 14. ..•......••••• STRINGDELIM (syntax class) strings ......54 14......37 14. . .28 14................... . ...2 14.......•....55 14....TABLE) ...................7... TCOt1PL TEf·JEX ....•••.. ••••••••••••••••••••••••••••••••• WHEREIS[X..... 14...•......FLST) .••........• •CAREFULCOLUMNS (prettydef variable/parameter) #RPARS (prettydef variable/parameter) .............. terminal syntax classes ...... .••.... SPACES[N...........• spe 11 ing correction .....•....50 14................. USERMACROS (prettydef command) ......•••......•..13-14 14..38 14............2 14. trc (use in comments) ......38 14....REREADSTRING] ..) (carriage-return) .... ••••••••••• WRITEFILE[X...11-13..•...75 14..........50 14......••.......18-19 14... % (use in comments) ••••••••••••••••••••••••••••• %% (use in comments) •••••••••••••••••••••••••••• & (typed by system) .....•... SETTERMTABLE[TTBL) SUBR .57 ......73 14...39.•......... ## (typed by system) .12·13.....CLASS..... •••••••• ..........55 14...17-18 14.57 14................. ••••••••••••••••••••••••••••••••••• .....•.•...32.••••••••••••••••••••••••• UCASELST (prettydef variable/parameter) .•....15.....• SKREAD[FILE. .. terminal tables ................Y...•..•......•...... .......• II # ..47 14 ..•• ........•..............••• .FILE] ••••••••••••••••••••••••••••••• [.. symbolic file input .7 14..•.. .....•............... (follo1·1ed by a number) ......... •••••••••••••••••••••••••••••••• •••••••••••••••••••••••••••••• .•.. .......••...12 14.51 14.20 14....28-35 14..........•.• U-CASE[X] . . .........•••••••....• SPLICE {type of read macro) ..••••••........•....2-3............25 14 ....... .....59-60 14........••..•.. ••••••••••••••••••••••••••••••••• terminal .............RDTBL] SUBR ..39-44 14...FILE) .•.•.TABLE] SYSBUF[FLG] SUBR SYSIN[FILE] SUBR SYSOUT[FILE] EXPR ....1.•••••••••• "' •••••••• SYNTAXP[CH... .....17.28 14........••.....23-30 14..)(inserted by prettyprint) .Page Numbers SETSEPR[LST.......••. $(alt-mode) .. •••• SYSOUTDATE (system variable/parameter) ....•......... 31.......26 14.20 14......6 14.55 14 . INDEX....ANCHOR.......•...........FILES] .••..TAIL) SUBSYS .••.... .....25 14..67 14..62 14.... TAB[POS.....FILE] SUBR ........ USEMAPFLG (system variable/parameter) .•••...40 14...11-12.52-53 14......7·9 14........35 14.FLG..•.. VARS[Fr~.• SETSYNTAX[CH..•....11.37-38 14. ... .....•.........•.......•..•.• STRPOS[X...4.....•..•...TYPE.......

........... ...21 14 .......47 14 ......•.........••••••••••••• ] 1 (use in comments) . ...... ......... 7 14..•.31.• \ (typed by system) •.11.14...•.....•...•••••••..•••......4 7 14....17 14.....Page Numbers "' (use in prettydef command) ..... .••.........• (typed by system) .....(typed by system) . INDEX....33 14 .•........ "'"'COMMENT** (typed by system) .....18 14........•••••....................••. "'*COMMENT*"'FLG (prettydef variable/parameter) -.. ...52 14..••••••••••.59 ....

.

and continue or return from the call. so that i f a break condition (defined by the user) is satisfied. value of fn is computed it is printed also. Teitelman. and obtain this These three facilities together are called the break All three redefine functions in terms of a system function. 15. Break modifies the definition of its argument. Trace nodifies a definition of a function fn so that whenever fn is called. i------------------------~------------------~---------------------------------The break package was written by W. debugging information.SECTION 15 DEBUGGING • THE BREAK PACKAG£ 1 15. When the (trace is a special case of break).1 Debugging Facilities Debugging a collection of LISP functions involves isolating problems within particular functions and/or determining when and where incorrect data are boing generated and transmitted. a function fn. break! described below. perform any computation. The user can then interrogate the state of the machine.1 . the process is halted temporarily on a call to fn. its arguments (or some other values specified by the user) are printed. In the INTERLISP system. package. there are three facilities which allow the user to (temporarily) modify selected function definitions so that he can follow the flow of control in his programs.

i. the user looks at the value of !!. A second break occurs after the next iteration. 15. After examining ! and m the user allows the computation to continue by typing OK. However. . When this break is released. He uses breakin to insert a call to breakt just after the PROG label LOOP. When an error occurs on the fifth recursion. the user traces the function factorial. The following two examples illustrate these facilities. the break is. the user has constructed a non-recursive definition of factorial. and a fu 11 break occur's.2 . The rest . the Oser) When the breakpoint is reached and if a break condition (defined by is satisfied. In the second example.maintained and no damage is done. the function factorial returns its value of 120.of t"'e tracing proceeds without incident. and the user can evaluate various INTERLISP forms and direct the course of the computation. tti1s time with N=O. and instructs breakt to return The user wotild then presumably edit factorial to change L to 1.. and then goes on with the computa. When the break occurs.e.Breakin allows the user to insert a breakpoint instde an expression defining a function. In this case. trace redefines factorial SQ that it calls break1 in such a way that it prints some information. break1 reverts to interactive mode.the user examines the variable n~ 1 as the value of this cell to factorial. This break is to occur only on the last two iterations. when !l is less than 2.tion. The situ a ti on is then the same as though the user had originally performed BREAK(FACTORIAL) instead of TRACE(FACTORIAL). • mistakenly typing NN. in this case the arguments and value of factorial. In the first example. a temporary halt occurs and the user can again investigate the state of the computation. .

. TRACE(FACTORIAL) (FACTORIAL) .3 . FACTORIAL(4) FACTORIAL: N =4 FACTORIAL: N =3 FACTORIAL: N = 2 FACTORIAL: N= 1 FACTORIAL: N = 0 U.. 24 15.. L (FACTORIAL BROKEN) :N 0 :RETURN 1 FACTORIAL = 1 FACTORIAL = 1 FACTORIAL = 2 FACTORIAL = 6 FACTORIAL = 24 .A.S.o-pp FACTORIAL (FACTORIAL (LAMBDA (N) (corm ( ( ZEROP N L) (T (!TIMES N (FACTORIAL (SUBl N]) FACTORIAL .

pp FACTORIAL (FACTORIAL (LAMBDA ( N) ( PROG ((M 1)) LOOP(COND (( ZEROP N) (RETURN M))) (SETO M (!TIMES H (SETQ N (SUBl N)) (GO LOOP]) N)) FACTORIAL .... It uses the prompt character ':' to indicate it is ready to accept input(s) for evaluation. •.· . in the same way as evalgt uses •.. FACTORIAL(5) .. .1·.. BREAKIN(FACTORIAL (AFTER LOOP) (ILESSP N 2) SEARCHING . ((FACTORIAL) BROKEN) ·:NN U. followed by another : . NN (FACTORIAL BROKEN AFTER LOOP) :N 1 :M 120 :OK (FACTORIAL) ((FACTORIAL) BROKEN) :N 0 :OK (FACTORIAL) 120 .' breaki allows the user to interrogate the state of the world and affect the course or the computation.. and we say he is 'in a break.A. .... FACTORIAL .2 Breakl The basic function of the break package is breakl. . and the value will be printed out. The user may type in an expression for evaluation as with evalqt. 15.. message of the form ( • BROKEN) followed by ': 1 Whenever INTERLISP types a the user is then 'talking to' breakl..B.. Or the user can type in one of the commands specifically recognized by breakl described below..

. load a file. see that the value was incorrect.. all without leaving the break. the user can prettyprint functions.5 Similarly i f the . the user is in complete control of the flow of the computation. etc.Since break1 puts all of the power of INTERLISP at the user's command. he can insert new breaks on subordinate functions simply by typing: (BREAK fn1 fn2 . It . time a computation. whose evaluation causes an error 0 If the user types in an expression the break is maintained. For example. compile functions. call the editor. In short. and even force a return back to some higher function via the function retfrom or reteval. Similarly.is important to emphasize that once a break occurs. including the one currently broken: EDITF( fn) For example. change the function. and the computation will not proceed without specific instruction from him.. via the functions described in Section 12. define new functions or redefine old ones. ) He can edit functions. In addition the user can examine the pushdown list. 15. anything that he can do at the top level can be done while inside of the break. he can do anything he can do at evalgt. and evaluate the expression again. ) or he can remove old breaks and traces if too much information is being supplied: (UNBREAK fn3 fn4 •. the user might evaluate an axpression.

h inls. breaks on the function FOO.' brkexp./_hen the user types OK or GO. and is the ·result of' evaluating ·'the break.the argument to ill.!· breakl as a fancy 2-------------------------------------------------------------·---------------By typing control-Ei see Section 16. not a special system feature like the interpreter or the garbage collector.expression is the body of the definition of FOO •. one can t.29 or any other function.returned as the value of the break.!• which permits interaction before an.had occurred . The break expression is an expression equivalent to the computation that would have taken pla·ce had no break occurred.• · In other words. to whatever function called FOO.. i. the break is Only if the user·. and returns a value. which is one of the arguments to breakl. 15.6 . 3 Except that breakl does not 'turn off' control•D.user aborts a computation2 initiated from within the break. expression. the value or a is given implicitly.!1! or cond or fil:. of ill.d after evaluation. 3 Note that breakt is just another INTERLISP function. the break . The value returned by break1 is called 'the value of the break. will the computation continue. or evaluates a form which does a retfrom or reteval back out of breakt. The break expression then corresponds to. a control·D will force an immediate return back to the top level. the body of FOO is evaluated.e. maintained. \. The effect is the same as though ·no break .e. and its value . if the user. via a GO or OK command. · It has arguments which are explained later.' The user can specify this value explicitly by using the RETURN command described below. gives one of the conunands that exits from· the break. the same as fQ. But in most cases. For example. i.

and then exited.7 is not . OK Same as GO except the value of brkexp printed.e. one might use the EVAL command and follow this with RETURN (REVERSE !VALUE). i. For breakin AROUND. EVAL Same as GO or OK except that the break is maintained after the evaluation.Zl.Break Commands GO Releases the break and allows the computation to proceed. maintain the break. See breakin. breakl evaluates brkexp. rebroken. makes it "go away' without returning a value. For breakin. brkexp is NIL. using BEFORE or AFTER. For example. t Calls error! and aborts the break. OK. The user can then interrogate the value of the break which is bound on the variable !value. 15. brkexp· is equivalent to the body of the definition of the broken function. and then the function is rebroken. Typing GO or OK following EVAL wi 11 not cause reevpluation but another EVAL will. !OK Function is first unbroken. EVAL. For break or !. page 15. then the break expression is evaluated. its first argument. and exited with value typed. evaluated. IEVAL followed by GO. EVAL is a useful command when the user is not sure whether or not the break will produce the correct value and wishes to be able to do something about it if it is wrong. All other errors.. i. including those encountered while executing the GO. brkexp is set up by the function that created the call to break1. brkexp is the indicated expression. This is a useful way to unwind to a higher level break. evaluated.e. and RETURN commands.· !OK is equivalent to !EVAL followed by OK. Very useful for dealing with recursive functions. i. !EVAL function is first unbroken. and continue with the break. !GO Function is first unbroken. RETURN form or RETURN fn[args] The value of the indicated computation is returned as the value of the break.£!. prints the value of the break·.!::!!. rebroken.e.

i.BREAKl] but leave .lastpos] °" search forward for next atom I the next atom is a number and can be used to specify more than one call e. reset lastpos to stknth[n. g. ARGS. lastpos is tho position of a function call on the push-down stack.8 it .e. If @ cannot successfully complete a search. (FOO BROKEN) :UB FOO and FOO is now unbroken @ resets the variable lastpos.g.BREAK1) teletype lino as its argument(s). which establishes a context for the commands ?=. The following atoms are treated specially: @treats the rest of the 0 @ do not reset lastpos to stknth[-1.UB unbrealts E.!:.e. It first resets lastpos to stk. BT. 15. @ FOO I 3 is equivalent to @ FOO FOO FOO Example: i f the push-down stack looks like BREAK! FOO SETQ COND PROG FIE corm FIE CONO FIE CONO PROG FUM (13) (12) (11) ( 10) (9) (8) (7) (6) (5) ( 4) (3) (2) ( 1) then @ FIE COND will set lastpos to the position corresponding to (7). BTVR. stknth[-1. @ @ COND will then set lastpos to (5). a. BTV. move lastpos back that number of calls. and continue searching from that point. @ searches bacl~ward. and EDIT.it as it was. i.BREAK1] and then for each atom on tho line.nth[ 1. @ FUM °"FIE to (4): and @FIE I 3 ·1 to (3). forward. It is initialized to the function just before the call to break!. i f positive.!iln. numbers if negative. for a call to that atom. and IN? described below.

of the second ?= can also be used on brkcoms. @ 1= This is a multi-purpose command. brkexp will be evaluated. and the top level executive appear as the single entries ••BREAK••.. In this case. as in the above case. @ FOO I 2 followed by ?= X will allow the user to examine the value of X in the previous call to FOO. If the user types ?= X (CARY). For example. This provides a way of examing variables or performing computations as of a particular point on the stack. it types the name of the function at lastpos.e. i f brkcoms is (EVAL ?= (X Y) GO). he will see the value of X. edit. 15. Its most corrunon use is to interrogate the value( s) of the arguments of the broken function. it uses stkarg in this case. where fn is the name of the function for which it was searching. ?= also. i. if FOO has three arguments (X V Z).e. The difference between using ?= and typing X and (CAR Y) directly to breakt is that ?= evaluates its i. and the value of (CAR Y). stkname[lastpos] can be used on brkcoms.types (fn NOT FOUND). and then the function exited with its value being printed. it prints an· of the arguments. When @ finishes. it uses stk.eval. the values of X and Y printed. e. the noxt command on brkcoms is treated the same as the rest of the teletype line. BT Prints a backtrace of Junction names onlv starting at lastpos. i.9 . (See discussion of @ above) The several nested calls in system packages such as break. recognizes numbers as refering to the correspondingly numbered argument.e. Thus · :@ FIE FIE : ?= 2 will print the name and value argument or FIE. If the line is empty. ••EDITOR••. and ••TOP•• respectively. i. will produce: : ?= X= V= Z= value of X value of V value of Z ?= operates on the rest of the teletype line as its arguments. in which case the next command on brkcoms is treated as the rest of the teletype line.g. then typing ?= to a break on FOO. For example.nputs as of lastpos. etc.

i. these are the arguments to the function entered at that posit ion.g.Prints a back trace of function variables beginning at lastpos. e.S. BTV names wt th Same as BTV except also prints arguments internal calls to eval. or function and arguments. i. = form. the srv-. i.10 .e. the printlevel will be restored after a printlevel during the backtrace is completed.to change backtrace. variables[lastpos) (Section 12).A. BTV. BTV! BT.g. the next brkcom must either be the functional argument. and BTV! all permit an optional functional argument which is a predicate that chooses functions to be will skip all SUBRs. (See Section 12).e. (FOO BROKEN) := (COPY FIE) sets FOO and goes on.. = fn[argsJ for the break following an unbound atom error. For BT. 15. or NIL if no functional argument is to be applied. For most cases. Sets the atom to the value of tho form. ARGS Prints the names of the variables bound at lastpos.e. (NOT BTV (LAMBDA (X) those functions on FOOFNS. exits from the break returning that value. (See Section 12) of Same as BTV except prints everything on stack. ~kipped on the backtrace. BTV•. e. only U. BT SUBRP (MEMS X FOOFNS))) will skip all but If used a$ a brkcom the functional argument is no longer optional. BTV. if control·P is used. and BTV!. The following two conunands are for use only with unbound atoms or undefined function breaks (see Section 16). and continues the computation. arglist[stkname[lastposJJ.

(FOO BROKEN) :->(QUOTE FOO) For U. e.B. facilitates editing the expression causing the break: NON-NUMERIC ARG NIL (I PLUS BROKEN) :EDIT IN FOO . In other words.g. e..F. the user can specify a function and initial arguments..g. error occurring immediately following a call to «J?ply.D. U.A. etc.A. ·> cannot operate..-> expr for use either with unbound atom error. Iilthis case. (IPLUS X Z) EDIT •(3 Y) •OK FOO and user can continue by typing OK.D.11 . EVAL. or undefined function error. breaks.F. F001 to FOO and continues tho expr need not be atomic.g. 4-------------~----------------------------------------------------------------> does not change just brkexp: it changes the function . (APPLY X V) where the value of x is FOO and FOO is undefined. so 1 is printed and no action taken.or expression containing the erroneous form. the user does not have to 15 .F.S.D. e. perform any additional editing.fces the express ion containing the error with expr (not the value of expr) e. (EVAL X).g. there is no expression containing the offending atom. where the value of x is FOO----aild FOO is unbound. or a U. (MEMBERX BROKEN) :·> MEMBER X Note that in the case of a U. e.F. U.g. ( F001 BROKEN) :-> FOO changes the computation. EDIT designed for use in conjunction with breaks caused by errors.O. error immediately following a call to eval. U. Rep1.

breaks on user Therefore. if For a compiled function FOO incorrectly . or to eval. example.mplementa t ion by all of the exceptional cases involving interactions with compiled functions. initially position of the break) looking for a form. on putd.e. i. an internal call to eval. 5 However. i f (PUTD (QUOTE (FOO)) big•computation) were handled by EDIT. and permits interactive editing to Note that the user can then type successive O's to the editor to see the chain of superforms for this computation. so that the user can continue with the computation by simply typing OK. e. EDIT could use the new corrected form to reset the break expression. EDIT will print an appropriate failure message and return to the break. the break expression cannot be reset. found. EDIT might be able to find the form headed function. but complicated in its :l.12 . 15 . big-computation would be reevaluated. in some situations. i f FOO were interpreted EDIT would find the putd form itself.e. i. he would still not have in any way informed EDIT what to do about the immediate problem. and also find that form in some higher interpretod But after the user corrected the problem in the FOO-form. et simplified explanation which account for 90% of the situations arising in actual usage. al. shall give error the breaks.g. we functions.Th is command is very simple conceptually. It then prints the form. Then EDIT continues from that point looking for a call to an interpreted function.called putd and caused the error ARG NOT ATOM followed by a break. by FOO. so that when the user correctod that form. the incorrect call to putd. However. if any. EDIT begins by searching up the stack beginning at lastpos (set by @ command. the break expression is reset. It then calls the editor on either the EXPR or the argument to eval in such a way as to look for an expression !S to the form that i t first begin. i f possible. will For those others. following breaks within breaks. If ·the user exits from the edit with an OK. Tho two cases are shown below: 5-----------------------------------------------------------------------------Evaluating the new brkexp will involve reevaluating the form that causes the break.

he can edit the calling form and reset the break expression with one operation by using EDIT. ATTEMPT TO RPLAC NIL T ( RPLACD BROKEN) :IN? FOO: (RPLACD X Z) Although EDIT and IN? were designed for error breaks. and superform.g. if upon reaching a break on his function FOO. The following two protocol's with and without the use of EDIT. the user determines that there is a problem in the caJ l to FOO. but does not call editor. illustrate this: 15.13 .ARG NOT ATOM (PUTO BROKEN) :EDIT IN FOO ••• (PUTO X) EDIT 111 ( 2 (CAR X)) ARG NOT ATOM (FUM) ( PUTD :EDIT rn BROKEN) FIE ••• (FOO X) EDIT "" ( 2 (CAR X)) •OK FOO :OK "'OK NOTE: BRKEXP NOT CHANGED PUTD FIE : ?= U = ( FUM) :(SETQ U (CAR U)) FUM :OK PUTD IN? similar to EDIT. they can also be useful for user breaks. e. but just prints parent form. For example.

e. + 8 REVERT will work correctly if the names or arguments to the function.8. See previous footnote. or even its function type.(FOO BROKEN) (FOO BROKEN) : ?= X = (A B C) y = 0 X = (A B C) y = 0 : ?= :BT :EDIT IN FIE ••• (FOO V U) FOO SETO COHO PROG EDIT •(SW Z 3) *OK FIE :OK FOO find which function FOO is called from FIE (aborted with tE) :EDITF(FIE) EDIT *F FOO P (FOO V U) *(SW 2 3) *OK edit it FIE :(SETO Y X) reset X and Y (A B C) : (SETQQ X 0) ' D : ?= X = D Y = (A B C) :OK FOO + REVERT. + + + 7 REVERT can also be given the position using the conventions described for @ on page 15. REVERT FOO ·1 is equivalent to @ FOO ·1 followed by REVERT. 7 on stack and that point With + REVERT is useful for continuing a computation in the situation where a bu~ + discovered at some point below where the problem actually occurred. REVERT + essentially says "go back there and start over.g. 6-----------------------------------------------------------------------------~ and X have not been changed." 8 ? is prints the names of the break commands. but brkexp has. have been changed.14 . + 15 . check them goes back · to position lastpos at + reenters the function called + the arguments found on the ~t~ck.

the first one prints the arguments of the function. Note: whenever an error occur. However. which causes the function to be evaluated and its value printed. break1 reads its next command from the teletype. the value of a break command is not printed. occur.Brkcoms The fourth argument to breakl is brkcoms. Whenever brkcoms=NIL. If brkcoms is not NIL.s. He would set up a break with brkcoms=( EVAL (PRINT X) OK). the value of brkcoms for the corresponding call to break1 will be defaulted to NIL.£! uses brkcoms: it sets up a break with two commands.set to NIL. as in the above example with the command (PRINT X). and the file must be opened. Brkfile The break package has a facility for redirecting ouput to a file. which would have the desired effect.15 + + + + .s . If you desire to see a value. you must print it yourself.s i. The variable brkfile should be set to the name or the file. The function ill.s. it is possible to specify a list of break conunands. or whatever the user specifics. Whenever brkcoms is not NIL. and a Ju·L L tnteractive break. a list of break commands that breakt interprets and executes as though they were teletype input. and the second is the command GO. 9-----------------------------------------------------------------------------Normal ly. when a user breaks or traces a function. suppose the user wished to see the value of the variable ~ after a function was evaluated. brkcom. as described in the discussion of break and breakt below. One can think of brkcoms as another input file which always has priority over the teletype. break1 takes as its next command car[brkcoms) and sets brkcoms to cdr[brkcoms]. 9 For example. 15.

command is defined as a macro.g.. breakt will go ahead and call lispx anyway. break1 simply appends its definition. or lispx command.. command is not contained in breakmacros. and will always go to the terminal. which is a sequence of commands. If spelling correction is unsuccessful. to the front of brkcoms.• commrmdn) . turn off echoing. since the atom may also be a misspelled history command. brkfile is initially T.. it is treated as a lf the function or variable as before. output due to TRACE. either via brkcoms or the teletype. e. change or disable the interrupt or line-editing breakresetforms expressions suitable for use in conjunction with resetform + + + + + 10----------------------------------------------------------------------------I f the command is not the name of a defined function. debugging them by breaking or tracing may + be difficult. because INTERLISP might be in a 'funny• state at the time of the + break.. bound variable.. and goes on. The user puts ·on interact. 15..16 . it searches the list breakmacros for tho command. etc.All output resulting from brkcoms will be output to brkfile. e. ) . (macro command 1 command 2 . The form If the of breakmacros is .g. break1 will attempt spelling correction using breakcomslst as a spelling list. break reset forms is designed to solve this problem. Breakmacros Whenever an atomic command 1s given break1 that it does not recognize..to Example: the command ARGS could be defined by including on breakmacros: (ARGS (PRINT (VARIABLES LASTPOS T))) + Breakresetforms + If the user is developing programs that change the way a user and INTERLISP + normally + characters. Output due to user typein is not affected.

and !OK.17 + + . etc. + 15. but nevertheless allow the user to :interact in the break in the "°" normal fashion. expression Break Functions breakt[brkexp. or command. + Because a lower function might have changed the state of the system with respect to one of the these expressions! + + 15. ~ When the break expression is evaluated via an EVAL. OK.brktype) is an nlambda. The command EVAL causes brkexp to be evaluated.g. is to occur. the expressions on + breakresetforms are again evaluated. RETURN and brkcoms or The commands. are the only ways to leave breok1.brkcoms. Other 11----------------------------------------------------------------------------i . or GO. 12 When the break ~ is exited via an OK. taken from interpreted. an identifying Conunands are then the teletype GO. interruptchar. ~. breakt first + restores the state of the system with respect to the various expressions on + breakresetforms. brkoxp is evaluated and returned as the value of brenk 1 . line length. brkwhen determines whether a break If its value is NIL.brkwhen.brkfn. Otherwise a break occurs and message is printed using brkfn.e. Thus + the net effect is to make the break invisible with respect to the user 1 s + programs. and their values saved. e. the value of each form is its 'previous state. and saves the value on the variable !value. When (if') breakl evaluates each control return.s to break1. all have this property. GO.(section 5). !GO. setreadtablEi". radix.3 When a break occurs.. breaki again restores state. RETURN. print level. OK. and saves the values. so that the effect of 1 12 + evaluating the form can be undone by applying car of the form to the value. 11 on + breakresetforms before any interaction with the terminal.

(For control-H breaks. 15. . on fn1-IN-fn2 exactly as described above. the input buffer was cleared at the time the control·H was typed.commands be can brktype breakmacros. f~.when. i. breakO first calls a function which changes the name of fn1 wherever it appears inside of fn2 to that of a new function. if the break returns a value. Value is fn. and via breaks.. · ERRORX for error breaks. see Section 16. brkex~. is not aborted via t or control-D. Adds fn to the front of the list brokenfns. the input buffer will be restored (see Section 14). (RP LAC A IN FOO) . a but where one is only interested in th·e call from a specific function. an equivalent and ~· as Puts property BROKEN on property list of fn with value a gens:rm defined with the original definition. breakO[fn. fn1-IN-fn2. brkfn. brkwhen. If fn is non-atomic and of the form (fn1 IN fn2). For error breaks.18 e. the input buffer is cleared and saved. INTERRUPT defined is break1 for NIL user for for control-H breaks. and when.e.) In both cases. initially defines as fnt.coms] sets up a break on the function fn by redefining fn as a call to breaki with definition of fn. This procedure function that is useful for breaking on is called from many places. brkcoms. Puts property BRKINFO on property list of fn with value (BREAKO when corns) (For use in conjunction with rebreak).g. which it Then breakO proceeds to break.

fn1-IN-fn2 and adding in addition to breaking fn1-IN-fn2 to the list brokenfns.g. e. breakO adds fn1 to the property value for the property NAMESCHANGEO on the property list of fn2 and adds the property ALIAS with the value (fn2. fni) to the property list of fn1-IN-fn2.! is not found in fn2.O is called for each member of fn using the same values for when. the value of breakO is a list of' the individual values.• breakO[(FOOl ((PRINT PRINl) IN (F002 F003))).!l is non-atomic. If fn1 is found in fn2. etc. This distributivity permits the user to specify complicated break conditions on several functions without excessive retyping.. If' f. PRINT•IN·F003. breakO returns the value (fnl NOT FOUND IN fn2). If !!!. ~· and file specified in this call to breakO. PRINT-IN·F002. 15 . whereas brenl~in only works on interpreted functions. (NEQ X T):(EVAL ?= (Y Z) OK)] will break on F001.(PRINT IN FIE). If fn is nonatomic and not of the above form.19 . but can be performed even when FiV2 is compiled or blockcompiled. PRIN1-IN·f002 and PRIN1·IN·F003. break. This will enable unbreak to recognize what changes have been made and restore the function fn2 to its original state. It is similar to breakin described below.

and cdr the forms the user wishes to see. This sets up a break with commands (TRACE ?= (NIL) GO). cdr[list]. only the value of Y will be printed for F002. break[F001 (F002 (GREATERP N 5) (EVAL))] equivalent breakO[F001. (GREATERP N 5). £!!!. it For each atomic argument. performs For list.break[x] is a nospread nlambda. and will serve for most uses. performs break.20 . For each atomic argument. i. 15.?=. TRACE(F001 (FOOZ Y)) will cause both F001 and F002 to be traced. (EVAL)] trace(x] is a nospread nlambda. he can perform TRACE ( ( fn)).list]. j3---------------------••-•••••-•••••••••••••-•••o••••••••••••••••••••-•••••••• The flag TRACE is checked for in breakt and causes the message 'function : • to be printed instead of (function BROKEN). it example.O[atom.i.£! performs: breakO[car[list]. All the arguments of FOOl will be printed. it performs breakO[atom:T:(TRACE ?= NIL GO)J 13 For each list argument. For each apply[BREAKO.T] to and breakO[F002.T].GO]] For example. In the special case that tho user wants to see only the value. i l l is the function to be traced. Note: the user can always call breakO himself to obtain combination of options of break1 not directly available with break and ~· These two functions merely provide convenient ways of calling breakO.e.list[TRACE.

or AROUND that point. (BEFORE CONDO). before allowing the computation to proceed. For breakin AROUND. 14 breakin then inserts the break BEFORE. 15. j4--------------------------------····-----·--···------------·----------------A STOP command typed to TTY: produces the same effect as an unsuccessful edit command in the original specification. particular SETO expressions. since the value of the break. For example. at a specified location in an interpreted function.Break in Break in enables the user to. In both cases. AFTER. For breakin BEFORE or AFTER. and examine its value. For example.in can be used to insert breaks before or after prog labels. and breakin types (NOT FOUND). first t~e or AROUND. the user can use the EVAL command to evaluate that form. (AFTER COND Z 1) will insert a break after the predicate in the first cond clause. is irrelevant. break. AFTER that point. (AFTER BF (SETQ X &)) after the last place X is set. e. Note that (BEFORE TTY:) or (AFTER TTY:) permit the user to type in commands to the editor. The user specifies where the break is to be inserted by a sequence of aditor commands. However. if foo calls fio. put the call to break1 BEFORE that point. the editor aborts.e. This is because breakin operates by calling the editor and actually inserting a call to breakl at a specified point inside of the function. the break expression will be the In this case. a call to break1. These commands are preceded by BEFORE.g.e. wh 1 ch editor has found the specified i. inserting a break in foo before the call to fie is similar to breaking fie. insert a break.9 predicate. and exit from the editor with OK. (BEFORE COND) will insert a break before the occurrence of cond. or even the evaluation of a variable.21 . or AROUND that point. e.. i. if the user inserted a break after a £2!1.g. locate the correct point. For example. indicated form. AFTER. and verify it for himself using the P command if he desires. the break expression is NIL. breakin uses to determine what to do once point.

A special check is made to avoid inserting a break inside of an expression headed by any member of the list nobreaks. The message typed for a break. for example.e. (SETQ )( actually be inserted AFTER (SETQ X &) .comsJ breakin is an nlambda. T is used. (FOO BROKEN AFTER CONO 2 1).where. the break will and a message printed to this effect. break in returns (fn UNBREAKABLE) as its value. and return something else if he wished. BREAK INSERTED AFTER (SETQ X &). or typing to be printed. if (GO L) appears before the this break would never be activated. since the break would not be reached.when. breakin[fn. If fn where specifies where in the the call to breakl is to be (See earlier discussion).in break. by expression.. breaking (AROUND (EQUAL X V)). breakin (AFTER L) will not insert the break inside of the GO expression. he would be powerless to alter the flow of computation if the predicate were not true.!l!! are similar to when and £2. definition of' fn inserted.22 . control-E.. except that if when is NIL.!!l! for breakO.(AFTER (EQUAL X Y)). for BEFORE or AFTER breaks. where fn is the name of the function inside of which the break was inserted. i. label L..g. e. since For example. Similarly. e. ~ and £2. but skip this occurrence of L and go on to the next L. is a compiled function. breakin types SEARCHING . will cause the full identifying message Any error.. user requests a break (AFTER X) in (PROG . (EQUAL X Y). look at its value. 15. is· ((fn) BROKEN). i f the &) • 0 )..g. in this case the label L. break in checks to make sure that the break is being inserted at a 11 safe 11 place. he can evaluate the break However. If fn is interpreted. initialized to (GO QUOTE D).

unbreakO[ fn] restores f. can be inserted with a single call to breakin by using a list of the form ((BEFORE . the most function recently on broken function. ~. location breakin types Ir it is found. (NOT FOUND) and exits.e. unbreak[] will unbreak all functions on brokenfns. It first sets brkinfolst to NIL. in reverse order. and the adds the property BROKEN-IN with property BRKINFO with value (where when corns) to the property list of of the list fn. )) also possible to call break or for where. and conversely to breakin a function which has been redefined by a call to break or unbreak[x] unbreak is a ~· nospread nlambda. ) (AROUND . It takes nn indefinite number of functions modified by break.. 15. and adds fn to the front brokenfns~ Multiple break points. ~ It is on a function which has been modified by breakin. to their Value is list of values of unbreakO. break in value T....while it calls the If editor. or breakin and restores them original state by calling unbreakO. the specified by where is not found. unbreak[T] unbreaks just the first brokenfns.. i.23 If !!l was not .u to its original state.

or definition of a Unbreakin is automatically called by unbreak if fn has property BROKEN-IN with value T on its property list. rebreak[] rebreaks everything on brkinfolst.24 . i. i. unbreakin is called to edit it back to its original state. unbreakin[ fn] performs the appropriate editing operations to eliminate all changes made by breakin. 15. ~· and Value For rebreak.e. If no information is found for a particular function. If fn was modified by breakin.broken. rebreak[x] is an nlambda. (front of) brkinfolst.. no. All functions break that were created by the dummy are Adds property value of BRKINFO to eliminated. the function in which fn appanrs is restored to its original state.. the name Value is fn. each function on for break( s) operation. Note: unbreakO[(fn1 IN fn2)] is allowed: unbraakO will operate on fn1-IN·fn2 instead. value is (NOT BROKEN) and no changes are made. information.e. value is (fn .NO BREAK INFORMATION SAVED). If fn was created from (fn1 IN fn2). fn may bo either function. searches brkinfolst performs is a the corresponding list of values corresponding to calls to breakO or break in.spread function for rebreaking functions that were previously broken without having to respecify the break. rebreak[] is the inverse of unbreak[J. if it hns a property ALIAS.

rebreak[T) rebreaks brkinfolst.2!!! was found. and advising. just the the first function break most on recently unbroken. it does not modify the definition of fn in the process of producing a 11 clean 11 version of the definition. varsflg=T for backtrace a la BTV varsflg=T. making. virgin fn[ fn. FOO UNADVISED. and prints the changes it FOO UNBROKEN. flg] is the function that knows how to restore functions to their original state regardless of any amount of breaks.to) changes all occurrences of from to lQ in fn. e.BTV• 15.. If flg=NIL.skipfn .e.g. NAMES RESTORED. as for prettyprint.g. It is used by the compiler. is FOO Value is the virgin function definition.!:. i. changename[fn.!s=T as for the compiler and define. i. b~ktra.from. If skipfn[stkname[pos]J prints skipfn is back trace is T. may be compiled or blockcompiled.ce[ pos1. prettyprint. f. any modifications of property lists.• form 11 flg . it works on a copy.e. define.allflg) pos 1 to pos2. they can be names of variables.!!! and fn Note that 1Q do not have to be functions. etc.varsflg . etc. (including all variables). 11 form 11 flg=T . it physically restores the function to its original state. compiling and saving exprs. is and skipped . I~ f. otherwise Value is fn if Does not perform NIL. pos2 .25 pos not from NIL. or any other literals.2. f.t. e. breakins.

varsflg:T, allflg:T

15.26

0

BTV!

Index for Section 15
Page
Numbers
AFTER (as argument to breakin) ................. .
ALIAS (property name) .......................... .
ARGLIST[X] .....................•................
ARGS (break command) ........................... .
AROUND (as argument to breakin) ............•....
back trace

........................ , ............. .

BAKTRACE[FROM;TO;SKIPFN;TYPE] .........•.........
BEFORE (as argument to brea~1n) ..............•..
BREAK [ X ]

NL~

break cornr:iands

....•........... , •...••. .:. •••••••.•••
..••...•......•.•.••...••••• , •.•.•

break expression ............................... .
BREAK INSERTED AFTER (typed by breakin) ........ .
break package .................................. .
BREAKCOMSLST (break variable/parameter) ........ .
BREAKIN[FN;WHERE;WHEN;BRKCOMS] NL ...........•...
BREAKMACROS (break variable/parameter) ........•.
breakpoint ..................................... .
BREAKRESETFORMS (break variable/parameter) ..•...
BREAKO[FN;WHEN;COMS;BRKFN;TAIL] ................ .
BREAKl[BRKEXP;BRKWHEN;BRKFN:BRKCOMS;BRKTVPE) NL
BRKCOMS (break variable/parameter) ...........•••
BRKEXP (break variable/parameter) ...........•.•.
BRKFILE (break variable/parameter) ............. .
BRKFN (break variable/parameter) ...........•....
BRKINFO (property name) .........••.••...........
BRKINFOLST (break variable/parameter) ....•.••.••
BRKTYPE (break variable/parameter) .......••.•••.
BRKWHEN (break variable/parameter) ..•...........
BROKEN (property name) ....•............•........
BROKEN (typed by system) ...............•.....•..
BROKENFNS (break variable/parameter) .•.....•.••.
BROKEN-IN (property name) •.....••.........•.•...
BT (break command)

..............•..•.....•.•...•

BTV (break command) ............................ .
BTV! (break command) ............•...............
BTVlil (break command) ................•...........
CHANGENAME[FN;FROM;TO] ................•.........
control-D ...................................... .
control-E ...................................... .
control-H
control-P

....................................... .
....................................... .

debugging .....................................••
EDIT (break command) .....•....................•.
editing compiled functions ...•....•.............
ERROR![] SUBR

................................... .

EVAL (break command) .....•.............•......••
EVALQT[CHAR] ..................................•.
( f n 1 I t~ f n 2 )

. . . . . . . . . . . . . . . . . . . • . . . . . . . . . ...... .

(fnl NOT FOUND IN fn2) ...•.................•.•.•
fn1-IN-fn2 .................................•....
GENSYM[CHAR] ..............................•••.•.
GO (break command) ...............•......•..•...•
input buffer ................................... .
IN? (break command) ..............•.•.•......••..

LASTPOS (break variable/parameter) •••..••..••••.
NAMES RESTORED (typed by system) ...•.....•.••.••

INDEX.15.1

15.7,21
15.19,24
15. 10
15.8, 10
15.7,21
15.9-10,25
15.25
15.7,21
15.1,7,20,23
15.7-15
15.6,12

15.22
15.1-26
15. 16
15.2,7,19,21-24
15.16,18

15.2
15.16
15.18-20,22,24
15.1-2,4-18,20·22

15.9, 15-18
15.6-7,9,11-12,14,17·18
15.15
15.8,17-18
15 .18. 23·24
15.23-24
15.18
15.17-18
15.18

15.4
15.18-19,23
15.23-24
15.8-9
15.8,10

15. 10
15.8,10
15.25
15.6, 18
15.6,22
15.18
15.10
15.1
15.8,11-13

15.25
15.7
15.7,15,17,21
15.5
15.18,24
15 .19
15.18-19,24
15.18
15.6-7,15,17
15.18
15.8,13

15.8·10,12
15.25

Page
Numbers
NAMESCHAtrnEo (property name)
••••••••••.•••.•••••
(NO BREAK INFORMATION SAVED)
••••••••••••••••••••
NOBREAKS (break variable/parameter)
••..•.•.•.•••

( f~OT BROKEf~)

..•.•••.••••..•.•••••••••..•••••••••

(NOT FOUND) (typed by break)
•••••••••.••••••••••
( UOT FOUUD) (typed by break in)
................ ..
NOTE: BRKEXP NOT CHANGED. (typed by break)
••••••
OK (break cornrnand)
.•••••..••••••••.••.•. , •••.•••

prompt character
RE BREAK[><] NL*

............................. .- .. .
••.•..••••••••••••••••••••••••••••

RETEVAL[POS;FORM) SUBR
••••••• ; •••••••••••••• ~ •••
RETFROM[ POS ;VALUE] SUBR
......................... .
RE TURIJ (break command)
•••.••••••••••••••••••••••
REVERT (break command)
.•••••••••••••••.•••••••••
SEARCHING ••• (typed by breakin)
••••••••••••••••.

spelling correct1on

spelling list

•••••••••••.•••••••••••••••••

................................... .

STKARG[N;POS) SUBR
••••••••••••••••••••••••••••••
STKEVAL[POS;FORM] SUBR
••••••••••••••••••••••••••
STOP (edit command)
•••••••••••••••••••••••••••••

TRACE[ X] NL*
........•..•••.••.•••••• • •...•.-•••••
TTY: (edit command)
•••••••••••.•••••••••••••••••
UB ( breaK Coraman·d)
•••.••••••••••••••••••••••••••
UNADVISED (typed by system)
•••••••••••••••••••••
ur~BREf\K[ x] NL*
•••••••••••••••••••••••••••.•••••••
(UNBREAKABLE)
•••••••••••••••••••••••••••• , ••••••
UNBREAKirJ[ FN]
•••••••••••••••••••••••••••••••••••
UNBREAKO[FN;TAIL)
•••••••••••••••••••••••••••••••
UNBROKEN (typed by system)
..................... .

U.S.A. breaks

.................................. .

U.O.F. breaks
.............•••••••••••..•..••••••
\ 1 alue
of a break
...•...•...•.•.•••..•••.•...••••
VARIABLES[ POS]
••••••••••••••••••••• , ••••••••••••
VIRGINFN[FN;FLG]
••• •· •••••••••••••••••••••••••••
! EVAL (break command)
•••••••••••••••••••••••••••
! GO (break corrunand)
•...•..••.••••••.•.•••.•...••
! OK (break colTll':'land) ..•.••.•••••••••••••••••• , •••
!VALUE (break variable/parameter)
•••••••••••••.•
**BREAK** (in backtrace)
.•.••••.••••••••••••••••
**EDITOR** (in backtrace)
•••.••..•.••.•••...••••
"'*TOP:R"' (in bt1ckt"race)
•..•••••••••••••.•••••••••

->

(break corrunand)

: (typed by systeni)

••....•....•..•.•.••..•..•..•.

······~······················

= (break cor.unand)
•.•.•.....••.••..•...•.••.••••.
? (break cor.unand) •.••.••.••.•••••••••.•••.••••••
?= (break command)
.•.•••••.•••.••.••.•.•••.•••••
@ (break command)
..•..••••••..•.••.••••.••••••••
t (break command)
..•..•.•••••••.••.•.•••••••••••
.. (typed by system)
....•.•...•.••••.••••••.•••••

INDEX.15.2

15.19
15.24
15.22
15.24
15.9
15.21,23
15.12
15.6-7,12,15,17
15.4
15.18,24
15.5
15.5
15.6-7,17
15.14
15.22
15.16
15 .16
15.9
15.9
15.21
15.1,7,15,20,23
15.21
15.8
15.25
15.19,23·24
15.22
15.24
15.23-24
15.25
15 .10
15 .11
15.6
15.10
15.25
15.7
15.7,17
15.7,17
15.7,17
15.9
15.9
'15.9
15 .11
15.4
15 .10
15.14
15.8·9
15.8-9,12
15.7.17
15.4

SECTION 16
ERROR HANDLING

16.1

Unbound Atoms and Undefined Functions

Whenever the interpreter encounters an atomic form with no binding on the pushdown list, and whose value
the

function

faulteval.

contains the atom NOBIND, 1 the interpreter calls
Similarly,

faulteval

is called

when

a

list

is

encountered, £2..!: of which is not the name of a function or a function object. 2
The value returned by faulteval is used by the interpreter exactly as though it
were the value of the form.

faulteval is defined to print either U.B.A., for

~n~ound

!tom, or U.D.F., for

yn.Qefined function, and then to call breakl giving it the offending form as
.

brkexp.

3

.

Once inside the break, the user can set the atom, define the function,

return a specified value for the form using the RETURN co1M1and, etc., or abort

i-------------------------·------------------·····--·-·-·--·------------------All atoms are initialized (when they are created by the read program) with

their value cells (car of the atom) NOBIND, their function cells NIL, and
their property lists(cdr of the atom) NIL.

2

See Appendix 2 .for complete description of INTERLISP interpreter.

3

If DWIM is enabled (and a break is going to occur), faulteval also prints
the offending form (in the case of a U.B.A., the parent form) and the name
of the function which contains the form. For example, i f FOO contains
(CONS X FIE) and FIE is unbound, faulteval prints:
U.S.A. FIE (in FOO] in (CONS X FIE). Note that if DWIM is not enabled, the
user can obtain this information after he is inside the break via the IN?
command.

16.1

the break using the

f

command.

If the break is exited with a value,

the

computation will proceed exactly as though no error had occurred. 4

The decision over whether or not to induce a break depends on the depth of
computation, and the amount of time invested in the computation.

The actual

algorithm is described in detail below in the section on breakcheck.
it

to

say that the

parameters affecting this decision have 'been

Suffico
adjusted

empirically so that trivial type-in errors do not cause breaks, but deep errors
do.

16.2

Terminal Initiated Breaks

Control-H

Section 15 on the break package described how the user could cause a break whon
a specified function was entered.

The user can also indicate his desire to go

into a break at any time while a program is running by typing control-H. 5 At
the next point a function is about to be entered, the function interrupt is
called instead.

interrupt types INTERRUPTED BEFORE followed by the function

4-----------------------------------------------------------------------------A similar procedure is followed whenever ~ or apply* are called with an

undefined function, i.e. one whose f.!llll is NIL. In this case, faultapplx
is called giving it the function as its first argument and the list of
arguments to the function as its second argument. The value returned by
fau 1 tapply is used as the value of ~ or apply*. faultapply is definod
to
print
U.O.F.
and
then
call
breakl
giving
it
(APPLY (QUOTE fn) QUOTE args)) as brkexp. Once inside the break, the usor
can define the function, return a specified value, etc. If the break is
exited with a value, the computation will proceed exactly as though no
error had occurred. faultapply is also called for undefined function calls
from compiled code.

5

As soon as control-H is typed, INTERLISP clears and saves the input buffer,
and then rings the bell, indicating that it is now safe to type ahoad to
the upcoming break. If the break returns a value, i.e., is not nborted via
' or control·D, the contents of the input buffer before the control-H was
typed will be restored.

16.2

name, constructs an appropriate break expression, and then calls break1.

Tho

user can then examine the state of the computation, and continue by typing OK,
GO or EVAL, and/or retfrom back to some previous point, exactly as with a usor
break.

Control-H breaks are thus always

1

safe'.

Note that control-H breaks

are not affected by the depth or time of the computation.

However, they

occur when a function is called, since it is only at this time

tha~

is in a "clean" enough state to allow the user to interact.

only

the system
Thus,

if

a

compiled program is looping without calling any functions, or is in a I/O wait,
control-H will not affect it.

Control-B, however, will.

Control-B

Control-B is a stronger interruption than control-H.
an immediate error.

It effectively generates

This error is treated like any other error except that it

always causes a break, regardless of the depth or time of the computation. 6
Thus if the function FOO is looping internally, typing control-B will cause the
cor.iputation to be stopped, the stack unwound to the point at which FOO was
called, and then cause a break.

Note that the internal variables of FOO are

not available in this break, and similarly. FOO may have already produced some
changes in the environment before the control·B was typed.

Therefore whenever

possible, it is better to use control·H instead or control-B.

Control-E

If the user wishes to abort
type control-E.

~

computition, without causing a break, he should

Control-E does not go through the normal error machinery of

6-----------------------------------------------------------------------------However, setting helpflag to NIL will suppress the break. See discussion
of breakcheck below.

16.3

scanning the stack, calling breakcheck, printing a message, etc. as described
below, but simply types a carriage-return and unwinds.

16.3

Other Types of Errors

In addition to U.B.A. and U.O.F. errors, there are currently 28 other error
types
etc.

in

INTERLISP,

e.g.

P·STACK OVERFLOW, NON-NUMERIC ARG, FILE NOT OPEN,

A complete list is given later in this section.

When an error occurs,

the decision about whether or not to break is handled by breakcheck and is the
same as with U.S.A. and U.D.F. errors.
action that follows depends on the
to

occur

following

evaluation

ATTEMPT TO RPLAC NIL error),

ty~e

of

Ir a break is to occur,

of error.

For example, if a break. is

(RPLACA NIL (ADD1 5))

the message

the exact

printed will

(which
be

causes

an

(RPLACA BROKEN),

brkexp will be (RPLACA UV W), U will be bound to NIL, V to 6, and W to NIL,
and the stack will look like the user had broken on rplaca himself.

Following

a NON-NUMERIC ARG error, the system will type IN followed by the name of the
most

recently entered function,

effectiv~ly

and then (BROKEN).

be in a break tnstde of this function.

The system will

then·

brkexp will be a call to

ERROR so that i f the user types OK or EVAL or GO, a ? will be printed and the
break maintained.

However, i f the break is exited with n. valu.e Via the RETURN

command, 7 the computation will proceed exactly as though no error had occur.red.

16.4

Breakcheck - Uhen to Break

The decision as to whether or not to induce a break when an error occurs is
handled by the function breakcheck. 8 The user can suppress all error breaks by

8

Breakcheck is not actually avaUable to the user for· advising or breaking
since the error ~ackage is block-compiled.

16.4

setting the variable helpflag to NIL (initially set to T).
decision

is

affected

by

two

factors:

the

length

of

If holpflag:T, tho
time

spent

in

tho

computation, and the depth of the computation at the time of the error. 9 If the
time

is

greater

than

helptime

or

the

depth

is

greater

than

helpdepth,

breakcheck returns T, meaning a break will occur.

Since a function is not actually entered until its arguments are evaluatod, 10
the depth of a computation is defined to be the sum of the number of function
calls plus the number of internal calls to eval.
expression

Thus if the user types in the

[MAPC FOO (FUNCTION (LAMBDA (X) (COND ((NOT (MEMB X FIE)) (PRINT X]

for evaluation, and FIE is not bound, at the point of the

U.B~A.

FIE error, two

functions, mapc and cond, have been entered, and there are three internal calls
to

eval

corresponding

to

(COIJD ((IJOT (MEMS X FIE)) (PRINT X))),

the

evaluation

of

the

forms

(NOT (MEMS X FIE)), and (MEMB X FIE). 11

The depth is thus 5.

breakcheck begins by searching back up the parameter stack looking

for

an

errorset. 12 At the same time, it counts the number of internal calls to eval.
As soon as (if) the number of calls to eval

exceeds helpdepth, breakcheck can

stop searching for errorset and return T, since the position of the errorset is
only

needed

when

a

break

is

not going to occur.

Otherwise,

breakcheck

9-----------------------------------------------------------------------------Except that control-B errors always break.
10

Unless of course the function does not have its arguments evaluated, i.e.
is an FEXPR, FEXPR*, CFEXPR, CFEXPR*, FSUBR or FSUBR•.

11

For complete discussion of the stack and the iriterpreter, see Section 12.

12

errorsets are simply markers on the stack indicating how far back unwinding
is to take place when an error occurs, i.e. they segment the stack into
sections such as that if an error occurs in any section, control returns to
the point at which the last errorset was entered, from which NIL is
returned as the value of the errorset. See page 16.15.

16.5

continues searching until either an ~rrorset is found 13 or the top of the stack
is reached.

Breakcheck then completes the depth check by counting the numbor

of function calls between the !!I.Q! and the last error set, or the top of the
stack.

If the number of function calls plus the number or calls to eva 1

(already counted) is greaier than or equal to helpdepth, initially set to ~. 14
breakcheck returns T. Otherwise, it records the position of the last errorset,
and the value of errors et 1 s second argument, which is used in deciding whether
to print the error message, and returns NIL.

breakcheck next measures

the

length of time spent in

the computation

by

subtracting the value of the variable helpclock from the value of (CLOCK 2). 15
If the difference is greater than helptime milliseconds, initially set to 1000,
then

a break .will occur,

i.e., .breakcheck returns T,

otherwise

variable helpclock is rebound to the current value of (CLOCK 2)

NIL.

Tho

for each

computation typed in to lispx or to a break.

The time criterion for breaking can be suppressed by .setting helpt;l.me to NIL
(or a very big number), or by binding helpclock to NIL. Note that .setting
helpclock to NIL will not have any effect because

~elpclock

is rebound by lispx

and by break.

If breakcheck is NIL, i.e., a break is not going to occur, then if an errorset
was found, NIL is returned (via retfrom) as the value of the errorset, aftor
first printing the error message if the errorset•s second argument was TRUE.

13----------------------------------------------------------------------------If the second argument to the errorset is INTERNAL, the errorset is ignored
and searching continOes.

See discussion of errorset, page 16.15.

14

Arrived at empirically, takes into account the overhead due to lispx or
break.

15

Whose value is number of milliseconds of compute time.

16.6

See Section 21.

If there was no errorset,
evalgt.

the message is printed, and control returns to

This procedure is followed for all types of errors.

Note that for all error breaks for which a break occurs, break1 will clear and
save the input buffer.
t

If the break returns a value. i.e., is not aborted via

or control-D, the input buffer will be restored as described in Section 15.

Error Types

16.5

There are currently forty-five

error types in the INTERLISP system. 16 They are

listed be low by error number.

The error is set internally by the code that

detects the error before it calls the error handling functions.

R

It is also the

value returned by errorn if called subsequent to that type of error, and is
used by errormess for printing the error message.

Nost error types will print the offending expression following the message,
e.g.,

NON-NUMERIC ARG NIL is very common.

causes a break. (unless helpflag is NIL).

Error type 18 (control-B) always
All other errors cause breaks

if

breakcheck returns T.

0

NONXMEM

( INTERLISP-10) reference to !!..Q!l•e;:sistent !n£.!!!Ory.
Usually indicates system is very sick.

Currently not used.

1

2

P-STACK OVERFLOW

occurs when computation is too deep, either with
respect to number of function calls, or number of

io··------------------·-····-···············-········
sor:ie of these errors are implementation dependent,
0

····-···-----------------

INTERLISP-10 but may not appear in other INTERLISP systems.

16.7

i.e.

appear

in

+
+

variable bindings . 17 Usually because of a nonterminating recursive computation, i.e. a bug.

3

ILLEGAL RETURN

call to return when not inside of an interpreted

4

ILLEGAL ARG • PUTO

second argument to putd (the definition) is not

NIL, a list, or a pointer to compiled code.

5

ARG NOT ATOM - SET

first argument to set, setg, or

~

(name of the

variable) is not a literal atom.

6

ATTEMPT TO SET NIL

via set or setg

7

ATTEMPT TO RPLAC NIL

attempt either to rplaca or to rplacd NIL with
something other than NIL.

8

UNDEFINED OR ILLEGAL GO

ru? when not inside of a

fil:.Q.9,

or ru? to nonexiStent

label.

9

FILE WON'T OPEN

from infile or outfile, Section 14.

10

NON-NUMERIC ARG

a numeric function e.g. iplus, itimes, igreaterp,
expected a number.

+

+
+
+

+
+
+
+

17----------------------------------------------------------------------------In INTERLISP-10, the garbage collector uses the same stack as the rest of

the system, so that if a garbage collection occurs when deep in n
conputation, the stack can overflow (particularly if there is a lot of list
structure that is deep in the car direction). If this does happen, tho
garbage collector will flush thestack used by the computation in ordor
that the garbage collection can complete. Afterwards, the error message
STACK OVERFLOW IN GC - CMPUTATION LOST is printed, followed by a reset[],
i.e. return to top level.

16.8

11

ATOM TOO LONG

In INTERLISP-10, > 100 characters.

12

ATOM HASH TABLE FULL

no room for any more (new) atoms.

13

FILE NOT OPEN

from an 1/0 function, e.g. read, print, closef.

14

ARG NOT ATOM

e.g. E.!ll called on a list.

15

TOO MANY FILES OPEN

I

16

END OF FILE

from an input function, e.g. read, readc, ratom.

16 including terminal.

Note: the file will then be closed.

17

ERROR

cal,l to

18

BREAK

control B was typed.

19

ILLEGAL STACK ARG

a stack function expected a stack position and was

0

given something else.

This might occur

arguments to a stack function are reversed.

if'

the
Also

occurs if user specified a stack position with a
function name, and that function was not found on
the stack.

20

FAULT IN EVAL

artifact

See Section 12.

of

bootstrap.

Never

occurs

after

faulteval has been defined as described earlier.

21

ARRAYS FULL

system will first initiate a GC:

1,

and i f no

array space is reclaimed, will then generate this
error.

16.9

22

DIRECTORY FULL

( INTERLISP-10) no new files can be created until
user deletes some old ones and expunges.

23

FILE NOT FOUND·

file name does not correspond to a file in the
corresponding directory.

Can also occur if file

name is ambiguous.

24

25

not used.

UNUSUAL CDR ARG LIST

a form ends in a non-list other than NIL, e.g.

(CONS T . 3).

26

HASH TABLE FULL

see hash link functions, Section 7.

27

ILLEGAL ARG

Catch-all error.

Currently used by evala,

arg,

funarg, allocate, rplstring, and sfptr.

28

ARG NOT ARRAY

elt or

~

given an argument

that

is

not

a

pointer to the beginning of an array.

29

ILLEGAL OR IMPOSSIBLE BLOCK

(INTERLISP·lO)

from getblk or

relblk.

See Section 21.

for internal use.

30

31

LISTS FULL

following a GC: 8, if a sufficient amount of list
words have not been collected, and there is no unallocated space left in the system, this error is
generated.

16.10

32

ATTEMPT TO CHANGE ITEM OF INCORRECT TYPE

+

Before a field of a user-data type is changed, the

+

type of the item is first checked to be sure that

it is of the expected type.

+

generated.

See section

If not, this error is

23.

+

33 . ILLEGAL DATA TYPE NUMBER The argument is not a valid user-data type number.

See sections

34

DATA TYPES FULL

23.

+
+

All available user-data types have been allocated.
See sections 23.

35

for internal use.

36

for internal use.

37

READ-MACRO CONTEXT ERROR

Occurs when a read is executed from within n

+

read-macro function and the next token is a ) or a

+

].

38

ILLEGAL READTABLE

See section 14.

+

The argument was expected to be a·valid readtablo.

+

See section 14.

39

40

41

ILLEGAL ARG - SWPARRAY

(INTERLISP~10)

SWAPBLOCK TOO BIG FOR BUFFER

ILLEGAL ARG - SETSBSIZE

See section 3.

(INTERLISP-10) An attempt was made to

swap in a function/array which is too large for

+

the swapping buffer.

+

See setsbsize, section 3.

( INTERLISP-10) The argument to setsbsize must be

+

either

+

NIL

or a number between

section 3.

16.U

O

and 128.

See

+

+

42

ILLEGAL ARG

43

USER BREAK

~

SWPPOS

Error

corresponding

to

1

hard•

user-interrupt

character. See page 16.16.

+

+

(INTERLISP-10) See section 3.

44

TOO MANY USER INTERRUPT CHARACTERS

Attempt to enable a user interrupt

+

chartacter when all 9 user channels are currently

+

enabled.

+

45

ILLEGAL TERMINAL TABLE

See page 16.16.

The argument was expected to be a valid terminal
table. See section 14.

+

In addition, many system functions, e.g. define, arglist, advise, l2!.z, exrt,
etc, also generate errors with appropriate messages by
16.14)

calling~

(see page

which causes an error of type 17.

Error handling by error type

Occasionally the user may want to treat certain error types different than
others, e.g. always break1 never break, or perhaps take some corrective action.
This can be accomplished via errortypelst.

errortypelst is a list of elements

of the form ( n expression), where n is one of the 28 error numbers.
breakcheck

has

been

completed,

but

before

any

other

action

is

After
taken,

errortypelst is searched for an element with the same error number as that
causing the error.

If one is found,

and the evaluation of the corresponding

expression produces a non-NIL value, the value is substituted for the offender,
and the function causing the error is reeentered.

For this application, the following three variables may be useful:

16 .12

If the function was ITIMES. 1 should be used. break. NIL means one will not. and the function in question was !PLUS. (16 16. position errorpos of the function in which the error occurred. always break. Error Functions errorx(erxm] is the entry to the error routines. Otherwise. errorx[ (10 T)] errorx calls or (PLUS Thus T). but by the effect of the evaluation. following errorn[ ] and is either induces a break or prints the message and unwinds 16 . cadr the "offendor 11 e. 'set ting' the error either (10 T). errorn[] is used to determine the error-message.g. Otherwise. (SETO BREAKCHK NIL)) would prevent END OF FILE errors from ever breaking.~ errormess is the error number. type and argument.g. T means a break will occur. e. Note that the latter case is achieved not by the value returned. i.13 . ADD1. RPLACA.check. setting BREAKCHK to T.e. -stkname[errorpos] might be IPLUS. (10 NIL) corresponds to NON-NUMERIC ARG NIL error. If ~=NIL. etc. 0 should be used for the NIL.6 Similarly. value of breakcheck.e. putting [10 on (AND (NULL (CADR ERRORMESS)) (SELECTQ (STKNAME ERRORPOS) ((!PLUS ADD1 SUBl) O) (!TIMES 1) (PROGN (SETO BREAKCHK T) NIL] errortypelst would specify that whenever a NON-NUMERIC NIL error ARG - occurred. INFILE. For example. or SUBl. breakchk i. seterrorn[ erxrn] is performed.

Note that errorx can be called by any program to intentionally induce an error type. 16 . help(mess1. mess2))]. and whether or not to print a message.to the last errorset. T) otherwise print. HELP! is used for the message. function !. otherwise a carriage return.mess2. prints its message and than Otherwise errorx[(17 (messl . (If both mess 1 and. Le.. help is a convenient way to program a default condition.Q."NOT A FUNCTION") will print FOO NOT A FUNCTION. error( "NON-NUMERIC ARG". the message is simply ERROR. calls it generates an error of type 17.) If nobreaki:T. printed. any of applications.14 tho . ~· and then calls If both mess1 and mess2 are NIL.!:!. mess2 are NIL. in which case the decision as to whether or not to break.g . e. error(mess1. the for However. calls ~ error!. will print NON-NUMERIC ARG T and error[FOO.mess2] prints messt and mess2 a la break1. or to terminate some protion of a program which theoretically computation is never supposed to reach.nobreak) The message that is (will be) printed is mess 1 (using prin1 ). is handled as per any other error. using print if mess2 Then mess2 is is a string. followed by a space i f mess1 is an atom.!: will most be more useful.

errorn[] returns information about the last error in tho form (n x) where n is the error type number and is the expression which was printed out after the (would error have ~ been) message. type of function.e.error! [ ]18 progranunable control·E. ersetg and nlsetg more useful: ~· In most (described below) are If no error occurs in the evaluation of y. i. errcirn[] is (10 T) •. Note that errorset is a lambdaand that its arguments are evaluated before it is entered. the value of errorset is NIL. the value of errorset is a list containing one element. reset[] Progranunable control·D. 16. i. errormess[u] prints message corresponding to yielded !!· an errorn that For example. immediately returns to the top level. 19 error set is a !!:!!!.• immediately returns from last errorset or resets.!:• so the names "u" and 11 v 11 don't actually appear on the stack nor will they affect the evaluation. Thus following (PLUS T). errorset[x) means eval is called with the value of cases.e .15 . If an error did occur. i. the value of eval[u].e. errormess[(lO T)J would print NON-NUMERIC ARG T errorset[u.v) 19 performs eval[u]. ii·----------------~------------------------------------------~---------------Pronounced "error-bang".

and associate characters. OUTPUTBUFFER. if an error occurs. and USER. INTERLISP characters. this errorset returns NIL.e. BREAK. nlambda. i. are assigned as well as defining his respectively. RUBOUT. control·O. ERROR. STORAGE. If y=INTERNAL. control·E. if y=NIL it is not. performs errorset[nlsetx. Lo. the error message is printed. equivalent to ( ERSETQ (FOO)) (ERRORSET (QUOTE (FOO)) T). However. the errorset is ignored for the purpose of deciding whether or not to break or print a message.t). performs ersetq[ersetx] errorset[ersetx.NILJ. nlsetq[nlsetxJ + Interrupt characters + This section describes how the user can disable and/or redefine + interrupt + INTERLISP is initialized with 9 interrupt channels which we shall call: + PRINTLEVEL. If y=T. Each In . 16. and control-U. control·B. HELP. nlambda.The argument y controls the printing of error messages if an error occurs. RESET. + addition. own interrupt control·P. + of these channels independently can be disabled. the user can enable up to 9 new interrupt channels. or have a new interrupt 20 + character assigned to it via the function interruptchar described below. control·S.16 control·H. control·D. the etrorset is in effect for the purpose of flow of control. To + these + delete/rubout.

it must be the name + of one of the 9 INTERLISP interrupt channels given + above: + HELP. USER. This option is used in connection with undoing and resetform. interruptchar ( reenabling If char tho was previously defined as an interrupt character. Soft interrupts are implemented by calling interrupt with an appropriate third argument.hardflg) + terminal interrupt code..typ/form. 21 A soft interrupt is like control·H: it does not occur until the + next function call. 23 + + retrieving the corresponding form from the list userinterruptlst once inside of errorx. assigns char channel is disabled. PRINTLEVEL. to interuptchar to restore that state. A + control·E or control-D: it takes place as soon as it + is typed. if a character is enabled as a user interrupt. + + The current state is an expression which can be given back. but for some reason it is not found on user interrupts. .with each channel an interrupt character and an expression to be evaluated when + that character is typed. In either case. 23 + If typ/form is a literal atom. • • + 1 16. for rubout/delete is 28..17 ~ + + + + + .22 If typ/form=NIL. and for space is 2~. if to that channel. an UNDEFINED USER INTERRUPT error will be generated. The terminal interrupt codes for the control characters can be obtained with chconl. for esc is 27. previously disabled). £h!! If typ/form=T. + 'hard' interrupt is lik~ User interrupts can be either 'hard' or 'soft'. + 21----------------------------------------------------------------------------Hard interrupts are implemented by generating an error of type 43. that + interpretation is disabled. + the current state of char is returned without + changing it. + The terminal interrupt code for break is O. and 22. and then obtaining the corresponding form from userinterruptlst. char is either a character or a interruptchar[char.

Any interruptchar the Tho intorrupt reset form or resetlst ( soo interruptchar[T] will restore all INTERLISP channels to their original 16 . interruptchar can be used conjunction with + otherwise soft. of are undoable. char is enabled as a usor + interrupt character. and typ/form is the form that + is evaluated when char is typed. calls to value Note: + state. + in + section 5). and disable all user interrupts.+ If typ/form is a list. + expression which when given back to 1nterruptchar + will restore things as they were before the call + to interruptchar.18 . + All + addition. interruptchar is ln an Thus. + will be hard if hardflg=T. + previous interpretations or char are disabled.

..............M] FSUBR .....7.....12-13 16....1-16 16..... ERROR[MESS1.. BREAKl[BRKEXP........ GO (break......... EVAL (break command) .. ...... FILE NOT OPEN (error message) ....7....................10 16..•....•.....8 16.......................... .............. conunand) ....... error types ...............................•.8 16.. error handling .... 10 16...9 16.....16....V] SUBR ..............................•....... EVALA[X.... ......... ......... ERRORMESS[ U] ...ARGl. .......9 16.... DATA TYPES FULL (error message) .......... ...3-4 16..•.. ERRORSET[U. ...•....2 16....10 16..........•.............10 ........ ....2 16 ... DWif1 . •........•.........7-13 16..NOBREAKJ ... ........................13 16...........BRKWHEN.. ....... .......Index for Section 16 Page Numbers APPLY[FN... ERRORTYPELST (system variable/parameter) .................14 16..........FAULTARGS] .9 16.•........ FAULT IN EVAL (error message) .......•• ..••••••••••••••••••••••••••••••........9.•.....••.. .7 16.........1 16.. ....... . ERRORX[ERXM] .........••• 11•••••••••• El T[ A ....12............ control-E con trol-H ......3-4 16...............••... BREAKCHECK ..............14 16...•........•.•..•..15 16.1-3. .. ERRORJJ[ J SUBR ...3.....•... function objects ..••.....9 16.. ARG NOT ATOM ...... FILE rior FOUIW (error message) ...4 16.A] SUBR ...... .... FILE WON'T OPEN (error message) .......................ARGS] SUBR ......... .....BRKFN.ARGn] SUBRA .... ARRAYS FULL (error message) ....9 16.15·16 16.....•.........8 16...15 16.7........8 16...••......9 16.•...2 16.........MESS2........•..... ATOM HASH TABLE FULL (error message) .9 16.........•......10 16............... ERSE TO[ ERSE TX] NL ••••••••••••••••••••••••••••••• EVAL[X] SUBR ......6......9 16......2......... 1 16. bell (typed by system) .... error number ..........BRKCOMS.7........... ATTEMPT TO SET NIL (error message) . ....•. ... ARG NOT ARRAY (error message) ··············'···· ARG NOT ATOM (error message) ............... ·· ...... 15 16.2 16.... •••.9 16.. ...•..14·16 16. .......... FAULTEVAL[FAULTX] NL* ...••.10 16.... ATOM TOO LOt~G (error message) ......2-3 16 .• (BROKEN) (typed by system) .... ATTEMPT TO RPLAC NIL (error message) .•..................... .....9 16.. 10 16...11 16.............. ............ ....... FUf·JARG ............ ..•... .4 16........ ARG[VAR...... END OF FILE (error message) .15 16........... .......•... i 16.. ATTEMPT TO CHANGE ITEM OF INCORRECT TYPE (error message) ....................... HASH TABLE FULL (error message) ... FAULTAPPLY[FAULTFN... ERROR (error message) .................1.... GC: 1 (typed by system) ...•.............•.9 16........ ..BRKTYPE] NL BRKEXP (break variable/parameter) .3........ N] SU BR ....•............••• INDEX..•.•....................... APPLY~[FN....12-13 16... control-D ..11 16.....•................•.. DIRECTORY FULL (error message) ........ control-B . ....15 16.....•..•••••• function definition cell ........... BREAK (error message) ................5-6......1 16...............9 16 ...5................••............•.......10 16..........•....................14-15 16........•...2-7......................• ERROR! [] SUBR ..7........... GETBLK[I~] SUBR .......•.1-2. ...... ........•....SET (error message) ....10 16........

1.•.• 16....... ..• ·16..• 16......•..8 UNDEFINED USER INTERRUPT (error message) ••••••. 16...S.14 ILLEGAL ARG (error message) .. (error message) •..••••• 16....3...........1 IfHERRUPT[ INTFN.1-2.......6 RE TURIJ (break command) .••••••••••.•....••.•• t<L 7 READ-MACRO CONTEXT ERROR (error message) ••••••.....4.7 NON-NUMERIC ARG (error message) •...........10 RESET[ ] SLTBR .........12 unbound atom ......7 interpreter . ..••.••...•..•...10 ILLEGAL ARG .... .•• 16......A....2 interrupt characters ..12 IN (typed by system) ...........10 SETA[A..••....•............•••••...9 TOO MANY USER INTERRUPT CHARACTERS (error message) 16.....••••••.SWPPOS (error message) ... •••• 16 .......5-6 HELP! (typed by system) .10 NLSETQ[NLSETX] NL ..•.N.....••••....••••••••....••• 16.••...MESS2] .5-6 HELPFLAG (system variable/parameter) .... 16.••.•.. 16..••.. 16 ....4 input buffer ....12 user interrupt characters ..•.•••••.........16 INTERRUPTCHAR[CHAR.. ..... 16..••.•.•. ...... 16.....•...•• 16.....•....• 16.....•..••••.•.f·J........• 16...••••• 16 ......•... 16.11 ILLEGAL ARG ...••..•• ·16.....10 USER BREAK (error message) •.11 SFPTR[FILE.4 INDEX ...11 ILLEGAL ARG .•••••..•.• 16...•..•• 16...••••.2 IN? (break command) ...•.. 16...... 11 ILLEGAL OR IMPOSSIBLE BLOCK (error message) •••....•..•...SETSBSIZE (error message) ••••••••• 16..VALUE] SUBR ..• 16 ...••••..................• 16...•• 16 ..1 LIS TS FULL (error message) .•..•........... 16 ...•..••••..12 ILLEGAL DATA TYPE NUMBER (error message) •••••••• 16..6 HELPDEPTH (system variable/parameter) •.•••..V] ..•••...8 SWAPBLOCK TOO BIG FOR BUFFER (error message) 16.2 ....•••••••...11 ILLEGAL RETURN (error message) ....• 16 ....•..•.•...HARDFLG] •.... 16......1 P-STACK OVERFLOW (error message) ..••...... (error message) •. 16 ...••.PUTD (error message) •••••••••••••• 16..• 16.......................•.•••• 16 ....17 INTERRUPTED BEFORE (typed by system) .......••••••••. INTARGS..•.......F....... 16...1 UNDEFINED OR ILLEGAL GO (error message) ..15 RETFROM[POS.•••.4 U.•. 16.......Y] SUBR ••••••••••••••••••••••••••• 16 ........•.••......2.16 U.• 16 ...... . ..1...COMPUTATION LOST (error message) ........•.•...• 16 ..••..•.1 undefined function ..•• 16.•.....3-4 property list ..9 ILLEGAL TERMINAL TABLE (error message) •.•...17 UNUSUAL CDR ARG LIST (error message) •..•.•...•..•••.• 16 .. .•....8 ILLEGAL STACK ARG (error message) .••••.. ..•.SWPARRAY (error message) •••.•.•.....8 OK (break cor:unand) ............. 16............11 terminal initiated breaks ..•••••••••••••••• 16...•...••.....TYP/FORM.•..........5...Page Numbers HELP[MESS1.....8 ILLEGAL ARG ...••••.. INTYPE] .•......• 16 .• 16 .•..•...4 RPLSTRING[X.....10 SETSBSIZE[N] SUBR ••••••••••••••••••••••••••••••• 16..•..•••...• 16......•.••.••••••••••••••...•.•••••.......•.....16 .....•....• ...•• 16 ...2-3 TOO MANY FILES OPEN (error message) ......ADDRESS] SUBR ....D.10 STACK OVERFLOW IN GC .••••...•••••••••.•..10 ILLEGAL READTABLE (error message) .••.15-16 r~OBir4o .••.•...•.14 HELPCLOCK (system variable/parameter) ....••••••• 16..••••••••••••..• 16....••••••• 16.N] SUBR •• ...7 HELPTIME (system variable/parameter) ...•• 16 .................1 r~ONXMEM (error message) ..........•.•....... 16 .11 RELBLK[ADDRESS.

.•......••...1 16...4 16......2 16...••••• t (break command) .......2..Page Numbers value cell .. value of a break ..•.7 ..•......16.••....••.....3 16............••••••••••••••••••••••••••• INDEX....• ? (typed by system) •••••••••••••••••••••••...

.

.-. the computation continues as though no error had occurred.--.. 2 Currently. (and what mistakes he had been making) as guides to the remedy of the error. Otherwise... it is discussed in ~ 1 [Tei2].SECTION 17 AUTOMATIC ERROR CORRECTION a THE DWIM FACILITY 1 Introduction 17. Teitelman. is automatically whenever called evaluation of an INTERLISP expression.JHI ------was ----designed ------. ---------.. etc.-------. errors.IIM. ------------------------.. and implemented by W. ----D\. e. DWIM only operates on unbound atoms and undefined function 17 . an error 2 occurs the in DWIM then proceeds to try to correct the mistake using the current context of computation plus information about what the user had previously been doing. certain kinds of parentheses errors. . The fol lowing protocol illustrates the operation of D\. or an unwind to the last errorset. ---.. as described in Section 16. the procedure is the same as though DWIM had not intervened: a break occurs... misspellings. To correct these types of errors we have implemented in INTERLISP a DWIH facility. If DWIM is able to make the correction. short for DO-What· I-Mean.1 ..g.1 A surprisingly large percentage of the errors made by INTERLISP users are of the type that could be corrected by another LISP programmer without any information about the purpose of the program or expression in question.

there is an extra left parenthesis in front of the T that begins the final clause in the conditional.Example The user defines a function f. notifies the user of this. (LAMBDA (N) (CONO ((ZEROP N9 1) ((T (!TIMS N (FACCT 8SUB1 NJ (FACT) ~DEFINEQ((FACT No. similarly. and finally.te that the definition of fact contains several mistakes: itimes and fact have been misspelled. the 8 in 8SUB1 was intended to be a left parenthesis. D\. PRETTYPRINT would normally print (FACCT NOT PRINTABLE) and exit.ru:! of one argument. At this point. the 9 in N9 was intended to be a right parenthesis.0 . error occurs. and DWIM is called. U• The value of fact[n] is to be n factorial.[ 1] Since there is no fun ct ion PRETTYPRWT in the system. Note that this is not an INTERLISP error 11.JIM invokes its spelling corrector.JIM proceeds on Finding one that is extremely the assumption that PRETTVPRNT meant PRETTYPRINT. the user wishes to look at its definition using PRETTYPRIIH. D\. which he unfortunately misspells. close. which searches a list of functions frequently used (by this user) for the best possible match. since facet has no definition. [2] and calls prettyprint.F. but the shift key was not depressed. a U . ~PRETTYPRNT((FACCT) =PRETTYPRINT [1) (2] =FACT (3) (FACT (LAMBDA ( N) (COND (( ZEROP N9 1) ((T (!TIMS N (FACCT 8SUB1 NJ) {FACT) After defining fact.Z .

FACT(3] N9 [IN FACT]-> N ) ? YES ((T --))) -> [IN FACT] (COND (COND ( T -.[4) During its execution.3 For .condition.)) ITIMS [IN FACT] -> HIMES FACCT [IN FACT) ·> FACT 8SUB1 [IN FACT) -> ( SUBl ? YES 6 .(6] In this particular example. the user was shown operating in TRUSTING mode. (T (!TIMES N (FACT (SUBl NJ) FACT The user now calls his function fact. occur. Following the last correction. The user can also 'operate in CAUTIOUS mode. so that OWIM would not be called as described above. Thus with the aid of DWIM. However. the user prettyprints the new.. now correct. . pp FACT [4] (5) (6) (FACT [LAMBDA (N) (COND ((ZEROP N) 1) . 6 is Finally. in which case DWIM will inform him of intended corrections before they are made. definition of f. and allow the user to approve or disapprove or them. 17. prettyprint is able to determine that the user wants to see the definition of the function fact. the error five errors is corrected.. the value of fact(3). printed. it is obviously not what the user meant.. which gives DWIM carte blanche for most corrections. and the computation allowed to continue as if no error had occurred..[3) and proceeds accordingly.[5] At each point.!£1. and owrn is called five times. This sort of mistake is· corrected by hav~ng prettyprint itself explicitly invoke the spelling corrector portion of DWJM whenever given a function with no expr definition. a message printed describing the action taken.

Sample output is given below.• YES FACCT [IN FACT]•> FACT 7 ••. so that the and fifth questions.. it is important to note that even when DWIM i. DWIM automatically user need intervene only when he does not approve. and experience with perhaps fifty different users indicates we have been very successful.)) ITIMS [IN FACT)-> ITIMES? . the user would have had to intervene anyway i f D\.D. and almost never mistakenly corrects an error. responded for him on the third and fourth •. if the user does not respond in a specified interval of time./IM the · computation.. no harm is done: 8 since an error had occurred. i7.IIH took. YES 8SUB1 [IN FACT] ·> ( SUB1 ? NO U. We have not yet had such an incident occur. user responded to the first. It is this benign quality of DWIM that makes it a valuable part of INTERLISP. UNDOes the DWIM change using UNDO described in Section 22. DWIM the proceeds with the correction. simply interrupts Thus. and information was lost before the user could interrupt. no action.most corrections. .A. o-FACT( 3) N9 [IN FACT] -> N ) ? YES U. i--------~-----------~--------------------------------------------------------Except perhaps if DWIM's correction mistakenly caused a destructive conputation to be initiated. .le ( 1J [2] [3J (4J [SJ have put a great deal of effort into making DWIM 'smart 1 . or if aborts D\. DWIM seldom fails to correct an error the user feels it should have.s wrong. T [IN FACT] FIX? YES [IN FACT] (COND ((T --))) -> ( COND ( T . mistakenly corrects an error. the user . However. (8SUB1 BROKEN) \. and makes the correction he would have had to make without DWIM.4 .B.F. Note that second.

etc. 6 DWIM always acts as though approveflg were NIL. as well as for processing the editor's E command. 4--------------------------------------------------------------·--------------INTERLISP arrives with DWIH enabled in CAUTIOUS mode. no approval necessary. 8·9 errors.e. or from IF. or resulting from macro expansions. so that corrections to them will never require approval. ORR commands etc. 0 For certain types of corrections. or OWIM[T) for TRUSTWG mode. for CAUTIOUS mode. e. LP.g. commands typed directly to the editor are treated as type-in. run-on spelling corrections. DWIM will not. Functions that call the spelling corrector directly. such as editdefault (Section 9). regardless of the ~etting of approveflg. followed by a carriage-return.g. and then continue. DWIM[CJ sets approveflg to T. DWIM always informs the user of its action as described below. Spelling Correction Protocol The protocol used by DWIM for spelling corrections is as follows: correction occurs in type-in.23. and thus approval will be requested if approveflg=T. i. e.2 Interaction with DWIM DWIM is enabled by performing either DWIM[C]. in the case of editdefault. specify whether or not the correction is to be handled as type· in.15. 6 In either case. print a followed by the correct If the spelling. See page 17. DWIM will ask for approvali in TRUSTING mode. The setting or approveflg determines whether or not the user wishes to be asked for approval before a correction that will modify the definition of one of his In functions. For corrections to expressions typed in by the user for immediate execution. approveflg=T. i.. are not treated as type-in. . 5 Typed into lispx. For example. whilo OWIM[T] sets approveflg to NIL. lispx is used by evalgt and break.17.5 . 4 In addition to setting dwimflg to T and redefining faultoval and faultapply as described on page 17. 17 . Commands given as an argument to the editor. dwim always asks for approval. CAUTIOUS mode.e. DWIM can be disabled by executing DWIM(] or by setting dwimflg to NIL.

have elapsed. print the incorrect spelling. Type space or carriage· return.user types: DWIM types: If ~csETQ FOO (NCOCN FIE FUM)) =NCONC the correction does not occur in type•in. until dwimwait seconds. then checking to see if anything has been typed. etc. nor will his type ahead be lost. See-footnote on pag~ 17. in which case DWHI wi 11 · wa 1 t indefinitely. 9 Equal to dwimwait seconds. and wants to insure that DWIM does not get 'impatient' and answer for him.g. Otherwise. and then the correct spelling. DWIM does not make the correction. 2.15. DWIM will type followed by the default answer. Do nothing: in which case DWIM will wait a specified interval. followed by [IN function-name].. make the correction and continQe. approveflg=NIL. 10 The default is always YES unless otherwise stated. DWIM will not confuse his type ahead with the answer to its question.7 Then. Thus i f the user has typed ahead before a DWIM interaction. and proceeds with the correction. thore will be a delay of at most 1/2 second before DWJM responds to the user's answer. DWIM types 0. 4. Type t. Type control-E. He can: 1. then clears and saves the input buffers. 5. it dismisses again. 3. This option is intended for those cases where the user wants to think about his answer. 6. ·>. Type Y.3. thh has the same effect as typing N. Type N. . 7-----------------------------------------------------------------------------The appearance of ·> is to call attention to the fact that the user's function will be or has been changed. 8 Whenever an interaction is about to take place and the user has typed ahead.wait for approval.6 . restoring them after the interaction is co1:1plete. print a few spaces and a ? and then. for error correction. 9 and if the use~ 0 has not responded. !TIMS [IN FACT]·> !TIMES as shown on page 17. 17. and furthermore guarantees that the error will not cause a break. and does not make the torrection. owrn types several bells to warn the user to stop typing. DWHI operates by dismissing for 500 milliseconds. if e. Thus. DWIM types ES. 8 The user then bas six options. If not. print a carriage return.

17. e.g. The user can then respond with Y.The procedure analogous. control-E. . space. however far back that may be. for If spelling correction on other the correction is being than handled INTERLISP as errors type-in. FOO 8CONS FIE FUH] CONS (A B C 0) ~(SETO =( Otherwise. ::=FACT as shown on page 17. D\. Note that since the spelling corrector itself is not errorset protected.7 .2. In these cases.on page 17. the proposed ii----------------------------------------------------------------------------The DWIM error correction routines are errorset protection. DWIM prints a carriage-return and returns the correct spelling. and returns it to the· function that called owrn. followed by the correct spelling.11 M prints = followed by the correct spelling. carriage return. and lets the calling function decide what to do next. owrn prints a few spaces and a ? and then waits for approval.g. incorrect spelling. Otherwise. N. Parentheses Errors Protocol As illustrated earlier . 11 The former simply instructs the spelling corrector to return NIL.3. is 0\. the latter causes an error which unwinds to the last errorset. [IN function-name J. DWIM will correct errors. consisting of typing 8 for left parenth~sis and 9 for right parenthesis. error occurs in type-in. the interaction with the user is similar to that for spelling correction.owrn prints the Then if approveflg=NIL. e. Otherwise. ->. typing N and typing control-E may have different effects when the spelling corrector is called directly . or do nothing as described. DWIM types user types: DWIM types: lispx types: = followed If the by the correction./IM prints the offending atom.

1. followed by one then on the of next the line above the corresponding correct form of the COND.F.g.& (T -·))).D. 2.((T --))). a message incorrect in type-iri. 17. and 3.8 .e. 13 If the error occurs correction. forms of COND. followed by ·>. D\. i. the erro~ will occur. e. 111 13 For U. T Errors Protocol DWIM corrects certain types of parentheses errors involving a T clause in a conditional. i.e. and prints consisting of [IN function-name J.correction. a few spaces· and a ?. the T clause appears inside a previous clause. D. (CONO -. DWIM simply types T FIXED and makes the Otherwise if approveflg=NIL. (COIJD •• (-.F. the T clause appears outside and immediately following the COND. i. T errors that are not one of these three types. and then waits for approval.g. OWIM makes the correction. i2-----------------------------------------------------·----------------------except the waiting time is 3 dwimwai t seconds. namely errors of the form: (COIW --) (T ··). 1. U. the T clause has an extra pair of parentheses around it.e.~.IIM takes no corrective action at all. e.

3. (CONO ·-) (T --).e. 'OK TO REEVALUATE' and then prints the expression corresponding to &. DWIM must then decide how to proceed with the computation. DWIM continues with the form after the COND. otherwise DWIM aborts. owrn cannot know whether the last clause of the COND before the T clause succeeded or not. and IPLUS are all on okreevalst. DWHI continues by reevaluating &.IIM can do this if the form is atomic. In case 2. i. 14 i4·---------------------------------------------------------------------------If DWIH can determine for itself that the form can safely be reevaluated. if the T clause had been inside of the COND.[IN FACT] ( COND (COND ((T ··))) ( T •• )} ·> as shown on page 17. DWIM then proceeds exactly the same as when approveflg=NIL. would it have been entered? the user 'CONTINUE WITH T CLAUSE' (with a default of YES). several spaces.(-- & (T --))). and each of the arguments can safely be reevaluated.D. Therefore DWIM asks If the user types N. If approveflg=T. Since this value is no longer owrn asks the user. e.4. 17. or defaults. T. the value of the expression corresponding to &. and a U. DWIM has a different problem·. The user then has the same options as for spelling corrections and parenthesis errors. (CONO -. CONS. and then FIX? and waits for approval. Having made the correction. O\. around. the form that originally followed the T clause. i. In case 1. or car of the form is a member of the list okrcevalst. D\.e. If the user types V. T error will then occur (even though the COND has in fact been fixed).e. After moving the T clause to its proper place.D. (SETQ X (CONS (IPLUS Y Z) W)) is safe to reevaluate because SETQ. makes the correction and prints its message. If the user types Y or defaults.g.F.IIM prints U. it does not consult the user before reevaluating. as shown on page 17. DWIM must return as the value of the CONO.9 . followed by [IN function-name]. i.F.

e. in the sense described below. Its task is to find that word on splst which is closest to xword.g.3 Spellin~ Correction The spelling corrector is given as arguments a misspelled word (word means literal atom). there is no problem with continuation. and rel respectively.g. etc.((T --))). or if it finds two or more words equally close. a spelling list (a list of words). so no further interaction is necessary. its value is NIL~ otherwise its value is the respelling. e. xword. This word is called a rel specifies the minimum 'closeness' between~ re~pelltng of and a respelling. In the event that the spelling corrector finds a word on splst with no disagreements. CONS to CONSS. PRTTVPRNT is 'closer' to PRETTYPRINT than CS is to CONS even though both pairs of words have the same number of disagreements. If the spelling corrector cannot find a word on splst closer to xword than rel.ing a list of those that are closest. but briefly 'closeness' is inversely proportional to the number of disagreements between the two words.10 . splst. The spelling the corrector operates by proceeding down splst. and keep. Certain differences between words are not counted as disagreements. and computing closeness between each word and xword. e. the spelling corrector continues through the entire 17.1 6 The exact algorithm for computing the spelling metric is described later on page 17. and ~irectly proportiorial to the length of the longer word.20. and a number: xword. Otherwise.In case 3. or a doubled letter. it will stop searching and return this word as the respelling. CONS to CNOS.g. for example a single transposition. 17. (COND -.

the spelling corrector searches for those words on splst that match xword. all three.spelling list.£!!! is interpreted as the correct spelling of the misspelled word. FOO$ matches FOOl and FOO. the spelling corrector operates somewhat differently. If the spelling corrector it interacts with the user as described earlier. $FOOS matches In this case. 'closest• word. If the spelling corrector finds one and only one respelling. and returns NIL. the spelling corrector prints AMBIGUOUS. the respelling is moved to the front of splst. i f xword is CONZ. CONS would be ambiguous if both CONS and CONO were spelling list. regardless of whether or not the user approves of the spelling corrector's choice. In the special case that the misspelled word contains one or more alt-modes. but not NEWFOO. i f xword spelling corrector will probably return CONS as the respelling. For example.g.11 identical with the misspelled . Synonyms Spelling lists also provide a way of defin. and if' more than one respelling is found. e. Then i f it has found one and only one returns this word as the respelling. VONS. Since many respellings are of the type with no disagreements.ing synonyms for a particular + context. where an alt-mode can match any number of characters (including 0). For both spelling correction and spelling completion. the spelling corrector will not be able to return a respelling. is it the However. and + i l l as the antecedent for that word. this procedure has the effect of considerably reducing the time required to correct the spelling of frequently misspelled words. the entire spelling list is always searched. If a dotted pair appears on a spelling list (instead of just an + atom). it interacts with the user as de~cribed earlier. on the For example. Instead· of trying to find the closest word as above. since CONZ is equally close to both CONS and COND. If i l l is + 17 . . finds an acceptable respelling.

or make L be synonymous with + LAMBDA by adding (L .addition to these spelling lists. filelst.lists apply only when DWIM is enabled. the antecedent is returned without any interaction or approval boing + necessary. 17 Only if the function has a definition. These are documented undtir their corresponding sections.12 . Thus if the user typed CALLS(EDITF) and later typed CALLLS(EOITV). e. since the association or L with LAMBDA occurs + only in the appropriate context. 26 Spellings! is a list of functions used for spelling correction when an input is typed in apply format. e. automatically adds to.· brokenfns. edi tcomsa. + adding (OTHERWISE . editf. LAMBDA) to lambdasplst. the user could make OTHERWISE mean the same as EL. typing CALLS(EDITF) will cause CALLS to be added to spellings1. and occasionally prunes. pr et tycomspl st. four lists used solely for spelling correction: spellings!. and userwords. since .g. clispforwordsplst. ill!!!• e. spellings2. 17 For example. lispxcoms.g. and are also indexed under 'spelling lists. a function and arguments. Various system packages have their own spellings lists. ELSE IF) to clispifwordsplst. spellings3~ the spelling list for unbound Similarly. i. + as a variable without confusion. i.SEIF by Note that L could also be used Spelling Lists Any list of atoms can be used as a spelling list. EDTIF(FOO).e. * etc.e. the user could make IFLG synonymous with CLISPIFTRANFLG + by adding (IFLG . spellings3. the system maintains.+ word.g. is undefined. etc. CLISPIFTRANFLG) to + atoms.' In . the name of the function is added to spellingst. load. etc. 17.spellingsl would i6-------------------------------------------------------·--------------------All of the remarks on maintaining spelling . For example. tcompl. as indicated by dwimflg:T. makefile. Whenever lispx is given an input in appiy format. and the func~ion Spellings! is initialized to contain defineg.

typing (SETQ FOO (REVERSE (SETQ FIE ··)))will add both FOO and FIE to spe l lings3. advise. a procedure that would make spelling correction intolerably slow. and advisedfns. break. !1£.then contain CALLS. breakmacros. defineq. the correction would not succeed. or functions used for spelling correction for all other It is initialized to contain functions such as addt. !l.ill or ~· for example. Userwords is a list containing both functions and variables that the user has referred to e. e.2.g. when a file is loaded./hen ever lispx is giVen an atom to evaluate.g. 19 Only if the atom has a value other than NOBIND. the name of the function is Whenever added to For example. editf.2• list. 18 Spellings2 is. cond. ~· append.13 . Spellings3 is initialized to edi tmacros. Function names are added to it by define. defineq. brokenfns. a list undefined functions. the alternative to using spelling lists is to search the entire oblist. setg. etc. 17 . spellings2. Atoms are also added to spellings3 when they are set by a lispx input. return. Spellings3 is a list of words used for spelling correction on all unbound atoms. typing (RETFROH (STKPOS (QUOTE FOO) 2)) to a break would add retfrom to spellings2.!1£• print. \. load (when loading compiled code). and prettyprint. by ~· Function names are also added to spellings2 define. ia·------------------------------------------------·-·------------------------1r CALLLS(EDITV) were typed before CALLS had been •seen' and added to spellingsl. Userwords is initially NIL. DWIM would be successful in correcting CALLLS to CALLS . editf. correction by arglist. However. unsavedef. the name of the atom is added to spellings3. and whenever they are set via !. 19 Atoms are also added to spellings3 whenever they are edited by editv. etc. Userwords is used for spelling prettyprint. by breaking or editing. unsavedef. all of the variables set in the file are added to spellings3. lispx is given a non-atomic form.

!£!!Y. i. editp. 30. th~ front of that section. Since the spelling corrector moves each word selected as a respelling to the front of its spelling list. New words are added to the corresponding spelling list at the front of its temporary section. the word is thereby moved into the permanent section.) lf the length of the temporary section then exceeds a specified number. the last (oldest) word in the temporary section is forgotten. he can then edit it by simply typing EOITF().14 . initialized to 30. deleted. and the respelling of NIL is defined to be the value of last word. and thereby slowing down spelling correction time. 30.e. tho variable lastword is always set to the last word added to userwords. i. or loading unsavedef. 17. Each of the above four spelling lists are d~vided into two sections separated by a NIL.load. #spellings2. etc. 20----------------------------------------------------------------------------Except that functions added to spellings1 or spellings2 by lispx are always added to the end of the permanent s•ction. This procedure prevents the spelling lists from becoming cluttered with unimportant words that are no longer being used. i f the user has just defined a function. spellings3 and userwords is given by the value of j{!spellingst. spell ings2. it is considered important and wi 11 never be forgotten. (when loading compiled code. the last function or variable referred to by the user. if the word no action is taken. Thus. #spellings3. and 60 respectively. userwords at the same tim• as they are added to exprs to property lists) Variable names are added to spelli~gsl. editf. 20 (If the word is already in the temporary section. the second section contains the temporary words. prettyprint. it is moved to is in the permanent section.e. and #userwords. or prettyprint it by typing PP(). Thus once a word is mi spelled and corrected. The first section contains the 'permanent' words. The maximum length of the temporary secti'on for spellings 1. .In addition.

IIM's intended correction by answering N as described on page 17. the time required is only 1 millisecond.15 . 22 If the user answers with t./hen D\. DWIM called reteval with (I TIMES U (FACCT 8SUB1 N)). i. Since the interpreter uses the value returned by faulteval exactly as though it were the value of the erroneous form. dwimblock returns NIL. otherwise unwinding to the last errorset.A.D. when D\.6. i. If D\.IIM or is ~ is enabled. faulteval and faultapply proceed exactly as described in Section 16.4 Error Correction As described in Section 16. undefined function. dwi~block exits by performing reteval of the corrected form.S.F. 21 17.Using these values. Thus in the example at the beginning of the chapter.6) dwimblock is exited by performing reteval(FAULTEVAL. 2i----------------------------------------------------------------------------If the word is at the front of the spelling list. function object. an error is generated at the position of the call to faulteval.IIM can (and· is allowed to) correct the error. message. the computation will thus proceed exactly as though no error had occurred. by printing a U. given an or a non-atomic form gr of which is not a it calls the function faulteval. or if DWIM cannot decide how to fix the error. as of the position of the call to faulteval or faultapply.e. or U. faulteval and faultapply are redefined to first call dwimblock. the average length of time to search a spelling list for one word is about 4 milliseconds. a part of the D\. the time is proportional to the length of the list: to search a spelling list of length 60 takes about 7 milliseconds. (see page 17. or i f he indicates disapproval of D\. 22 ln this case. \. If the word is not on the spelling list. it calls function Similarly./IM package. when f'aultapply. 17. the entire list must be searched. If the user aborts by typing control·E.(ERROR!)].IIM determined that ITIMS was !TIMES misspelled.e. and going into a break i f the requirements of breakcheck are met. whenever the interpreter encounters an atomic form with no binding.

The 8 does not have to be the first character of the atom.) 2.g.g. i t would not be possible to repair the cause of the error.16 . OWIM assumes the user wants the next expression quoted. If CLISP (Section 23) is enabled. D\. Assuming that the user approves if he is asked. i.e. DWIM also changed (with rplaca) the expression (IT!MS N (FACCT SSUB1 N)) that caused the error.g. N-1 is transformed to (SUB1 N). Again no message will be printed or approval asked. e.g. DWIM assumes the 9 was int. If the first character of the unbound atom is 1 . (If no expression follows the '• DWIH gives up. the 7 is treated as a '• e.In addition to continuing the computation. If the atom begins with a 7. If the atom contains a 9. the action taken by DWIM for the various types of errors in each of these categories is summarized below. Unbound Atoms 1. that the entire expression was affected by the missing left parenthesis. If the unbound atom is just ' itself. if the user types (SETO X (LIST (CONS SCAR Y) (CDR Z)) Y). e. Error correction in DWIM is divided into three categories: undefined cars of form. al though DWIM could correct the misspelling each time it occurred. The protocol of DUIM's interaction with the user has been described earlier. e. (CONS X '(ABC)) will be changed to (COrJS X (QUOTE (ABC))). DWIM also repairs the cause of the error whenever possible. the CLISP transformation is performed and the result returned. For example. DWJM will handle (CONS XSCAR Y) correctly. DWIM assumes that tho user (intentionally) typed •atom for (QUOTE atom) and makes the appropriate change. 'FOO.g. 5. 4. 17 . If the atom contains an 8. and then (QUOTE FOO). performed (EVAL (LIST X Y)) and the value of x was a misspelled----ruricuon./IM assumes the 8 was intended to be a left parenthesis. DWIM assumes that the user did not notice the mistake. and the atom is part of a CLISP construct. and calls the editor to make appropriate repairs on the expression containing the atom. 23 Thus in the. 7FOO becomes 23----------------------------------------------~------------------------------ If the user's program had computed the form and called eval. and no approval requested. and undefined function in ~· unbound atoms. above example. 3. No message is typed. e. the expression will be changed to (SETO X (LIST (CONS (CAR Y) (CDR Z)) Y)).ended to be a right parenthesis and operates as in number 3.

ibdasplst. D\. followed by 'UNSAVED'. returns this value. e. owrn attempts spelling correction using the lambda and prog variables of the broken function./HI supplies (X). If car of the form is F /L. if. DWHI attempts spelling correction on £2. Otherwise. For example. car of the first expression is not the name of a function. followed by theprintout associated with the execution of the P cor. 17 . DWIM gives up. dwimuserfn is discussed below. followed by •./Illl changes the F /L to FUllCTIOll(lAMBDA. Thus. FOR. If car of the form is T. and continues.g. D\. and every elemontTn the first expression is atomic. the QLAHBOAs of SRI's QLISP are handled in this way. initially (LAMBDA NLAMBDA).8. Undefined car of Form 1. If the user omits the variable list.g.!: of the definition us~9g as spelling list the value of lar.ibdasplst if he elects to define new 'function types' via an appropriate dwimuserfn. No approval is requested.17 + + + . e. (F/L (Y) (PRINT (CARY))) is changed to (FUUCTION (LAMBDA (Y) (PRINT (CARY))). and the result returned as the corrected form. i. performs an unsavedef. i f the user defines the function foo and then types P.IIM prints car of the form. at which point he can continue editing foo. DWIM calls dwimuserfn. DWIM attempts spelling correction using spellings3. (F/L (PRINT (CAR X))) becomes (FUllCTIOIJ' (LAMBDA (X) (PRINT (CAR X)))). followed by EDIT. For example. he will see =FOO. D\. DO et al. D\. DWIM assumes the user wants to be in the editor editing the last thing he 'referred to./HI will supply (X) when correcting (F/L (PRINT (CDR X)) (PRINT (CAR X))). DWIM assumes a misplaced T clause and operates as described on page 17.g. WHILE. 4. If the unbound atoms occurs in a function.e. 5./HI determines that the user has supplied the variable list when more than one expression follows F/L. and the error occurred in type-in. 9. 3.unand. the definition is to be found on 24·-----------------------------·------~-------------------------------------·The user may wish to add to lar. D\. the effect is the same as though the user typed EDITF (). followed by the atom. or one of the CLISP iterative statement operators. If dwimuserfn=T. No message is printed and no approval requested. · 6. If the atom is an edit command (a member of editcomsa).6. If car of the form has a function definition. If£!!: of the form is IF. DWI~! 8. and if it returns a non-NIL value. 10. If the unbound atom occurred in a type-in to a break. If car of the form has an EXPR property.e. 2. DWIM attempts spelling correction using as a spelling list the list of lambda and prog variables of the function. If all fail. 7. If£!!: of the form has a property FILEDEF. the indicated transformation is performed.

and CLISP is enabled. and car of the form is part or a CLISP construct. the entire file is to be loaded. <NEWLISP> 's directory.g. file and cdr the relevant functions. car is the name of the. 14. DWIM attempts spelling correction on ~ of the form using lambdasplst as spelling list. Undefined Function in Apply 1. and the function nane contains a CLISP operator. ( APPEND FIE FUM) • 17. cplists. of spelling correction.g. intended. and if so makes the corresponding change. 11. operates as in 11. D\. Otherwise. and if found.!: of the definition using lambdasplst as spelling list. · 13.. If dwinuserfn=T. or in a type-in while in a break. If car of the form is a small number. DWIM will type MEMBERX [IN FOO] ·>MEMBER X? . or <LISP>' s directory. performs an unsavedef and continues. DW'IM gives up. e. (. If CLISP is enabled. the indicated transformation is performed. and if it returns a DWIM returns this value. If 9. OWIM checks to see i f the last character in car of the form is one of the lambda or prog variables. 3. edita. breakdown. and the pattern match compiler andrecord capability or CLlSP are implemented in this fashion. 2. attempts spelling correction using spellings2 as the If all fail. e. If a list. i f approveflg=T. circlmaker. If the user approves. 8. and the error occurred in type-in. DW'IM assumes a right parenthesis was 10. If the error resulted from type-in. If the value of the property is atomic.a file. If the function has a definition.g. undefined ~ of form. · 12. D\. e. • 7. The ptotocol followed will be the sane as for that.CONS8CAR X).. DWHI prints its name followed by UHSAVED 1 .IIM assumes the form is really an edit command and operates as described in case 6 of unbound atoms. car of the form contdns an 8. DWIM first checks tOS"ee if the file appears in the attached directory. e. DWIM assumes a left parenthesis was intended e. the user types FOO.g.g. If car of the form is a list. 4. If successful. and loadfns will be used. DWIM spelling list. DWIM performs the indicated transformation. If 1 the function has an EXPR property. 15. No approval ii requested. and i f the first na1 characters are the name of l\ defined function. If the error occurs in a function. no~·Nll DWIM value. (MEMBERX Y) will be changed to (MEMBER XV). dwimuserfn is called. If the function has a property FILEDEF. If car of the form is an edit command (a member of editcomsl). types "SHALL I LOAD" followed by the file ~ame or list of functions. If car of the form contains a 9. owrn loads the function(s) or file.18 DWIM proceeds as in case 6 of . DWIM returns the corrected expression itself. and continues the computation.IIM attempts spelling correction on £!!. ( No-N-1) becomes (SETO N (SUB1 N)).

Therefore. F/L. DWIM operates as in 7. If the 'function' is a list.5. DHIMUSERFN Dwimuserfn provides a convenient way of adding to the transformations that DWIM performs. i. this value is treated as the form used to continue the computation. DWIH will call dwimuserfn before attempting spelling correction. e. but after performing its other transformations. e. 11. 5 owrn gives up. Otherwise DWIM attempts spelling correction using S[!ellingsi as the attempts spelling correction using seen in9s2 as the spelling list. 8. If the function is a number and the error occurred in type in. and attempts spelling correction.. etc. dwimuserfn is called./IM assumes a left parent.IIM attempts spelling correction the list using lambdasplst as spelling list. 7. and if it returns a non-NIL value. and then enables it by setting dwimuserfn to T. The user defines dwimuserfn as a function of no arguments.g.g. EDIT8FOO]. the user might want to change atoms of the form $X to (QA4LOOKUP X). pro~eeds as when Note that in the event that dwimuserfn is to handle the correction. Otherwise DWIM spelling list.e.hes is was intended. it is also responsible for any modifications to the original expression.g. 9. Dh'Hl assumes the function is an edit command. D\. this valuo is treated as a form to be evaluated and returned as the value of faulteval or faultapply. on~ of a 10. CLISP. If dwimuserfn returns a non-NIL value. D\.e. e. If all fail. 6. 17 . the user types (on one line) 3 -1 P. e. if dwimuserfn returns NIL. 8. If dwimuserfn=T. In order for dwimuserfn to be able to function. DWIM dwimuserfn is not enabled. Otherwise. e.19 several of DWJM's internal .g. and operates as described in case 6 of unbound atoms. DWIM simply takes its value and returns it. i. user types F COND. 9. it needs to know various things about the context of the error. If the function is the name of an edit command (on either edi tcomsa or editcomsl). If the function name contains an 8. it will be eual-ed.g. 17.

variables have been made SPECVARS (See Section 18) and are therefore "visible" to dwimuserfn. faultargs for undefined functions in list of arguments.~~ 17. for example. faultapplyflg' ls T for undefined functions in ~· (Since faultargs may be NIL. ( faul tfn is TYPE-IN when the error occurred in type-in. 17. For undefined functions in ~. Below are a list of those variables that may be useful. minus this number is then the relative agreement or closeness. count as one di~agreement. tail is the tail car of which is the unbound atom. and use this number divided by the length of the longer of the two words as a measure of their relative disabreement.e.20 One Most . type-in? true if error occurred in type-in. parent is the form in which the unbound atom appears. i. since faultx is atomic in both cases). faultapplyflg is necessary to distinguish between unbound atoms and undef inod function in ~. faultx for unbound atoms and undefined car of form. faultargs is tho Spelling Corrector Algorithm The basic philosophy of DWIM spelling correction is to count the number of disagreements between two words. or argument to eval.----rilus dwimuserfn can replace the atom by another expression by performing (/RPLACA TAIL expr) parent for unbound atom errors.e. faul tfn name of function in which error occurred. expr definition of faultfn. the superform in which the error occurs. tail for unbound errors. foul tx is the name of the function. CONS and CONX differ only in their last character. faultx is the atom or form. i. Such subs ti tu ti on errors so that the two words are in 75% agreement. tail is a tail of parent.6 ~. and EVAL or APPLY when the error occurred under an explicit call to EVAL or APPLY). dwirnifyflg true if error was encountered during dwimifying as opposed to during running the program.

and taking this into account when deciding whether to reject shorter words. xword. 26 fn=fHL is equivalent to fn=(LAHBDA NIL T).21 . since doubled letters are not counted as disagreements. arguments: a word. 17. is not rejected. Words not satisfying fn. a spelling list. skor operates by scanning both words from left to right one character at a time. ~el. splst. or those obviously too long or too short to be sufficiently close to xword are immediately rejected. For example:-cONNSSS and CONS have a relative agreement of 100.e substitution error is permitted in words of four characters or longer. spelling correction on shorter words is possible since certain types of differences such as single transpositions are not counted as disagreements. For example. as and an optional functional argument. the current word on splst. 28 Characters are considered to agree if they are the same characters: or 25----------------------------------------------------------------------------Integers between 0 and 100 are used instead of numbers between 0 and 1 in order to avoid floating point arithmetic. and ~ is 5 characters long. 28 skor actually operates on the list of character codes for each word. 26 so that a singl. However. 26 chooz proceeds down splst examining each word.) chooz handles this by counting the number of doubled characters in xword before it begins scanning splst. if rel=70. 27 Special treatment is necessary for words shorter than xword. This list is computed by chooz before calling skor using dchcon. and fn respectively. skor. (Certain teletype diseases actually produce this sort of stuttering. words longer than 7 characters will be rejected. The central function of the spelling corrector is chooz. choo2 takes a minimum relative agreement. 27 If tword. so that no storage is used by the--ent'ire spelling correction process. For example. ~ computes the number of disagreements between it and xword by calling a subfunction.calls to the spelling corrector specify rel=7o. AND and NAO have a relative agreement of 100.

22 . and neither are.11 proceed accordingly. for example. a displacement by more than two positions is counted as a disagreement. as do Land/..e. and skoring continues.e. If the procedure is the same except that the character is removed from ~. etc. i. skoring continues on the rest of the characters in ~ and the and tword. i. skor checks to see if either character is the same as one previously encountered. + + + 17. In this case. If the first character in xword and tword do not agree. and not counted as -----------------------•••••••••••••••••••a•J•••••••••••••••••••-••••••-•-••••• 29 For users on model 33 teletypes. 1 with ! . Certain other terminals. and if so. Characters that agree are ·discarded.e. as indicated by the value of model33flg being T. xword and tword are considered to disagree. a special check is first made to see i f that character is equal to t. @and P appear on the same key. and continues by comparing the rest of tword with ~ tword has the same or fewer characters remaining than as described above. ~ characters. e.appear on the same teletype key (i. 30 In this case. skoring is aborted. and D\. of tword. the character is considered accounted-for. In either case. and O and .. time. ~. N on same key as t. both characters are now considered as accounted for and are discarded. transpositions are not but by look. or if the character in ~ is a lower case version of the character in tword. i.IIM wi. . the user might also want to set model33flg to T. (In other ~ords. and not accountedfor at that lookahead. 29 etc. a double character typo.he previous character in xword. The initial value for model33f1Q is NIL. N and L. equal to previously unaccounted-for remaining than xword.g.. or to the next character in xword.of · two or fewer handled by positions is counted as a tranposition. a shift mi$take). 30 Whenever more than two characters in either xword or tword are unaccounted for. Anderson Jacobs terminal. and tword has more characters removes and saves the first character.) A displacement . have keyboard layouts similar to the model 33. If the ffrst character in xword and tword do not agree. • a~r~es with : .e.back.

subs ti tut ion errors count as only one disagreement. spelling correction on very such as edit This permits short words.g. The rationale behind this is that transpositions are much more comr:ton for fast typists. plus the number of tranpositions. value is NIL. enables DWIM in cautious mode. IPLILX and !PLUS will be in 80% agreement with fastypeflg=T. whereas more deliberate typists are not as likely to combine tranpositions and other mistakes in a single word. not two. enables DWJM in trusting mode. e. dwimify(x] 2S is a form or the name of a function. XRT->XTR. For all other values of ~· generates an error.a disagreernent. Otherwise making xword sufficiently long by adding double characters would make arbitrarily close to tword. 17. 1 f 2S=T. transpositions are not counted. fastypeflg is initially NIL.7 DWIM Functions dwim[x) If If ~=C. and (2) if there are no unaccounted-for characters and no disagreements. ~=NIL. value is CAUTIOUS.. value is TRUSTING. tho value of skor is the number of unaccounted-for characters. i. with two qualifications: ( 1) if both xword and tword have a character unaccounted-for in the same position. 31 When skor has finished processing both xword and tword in this fashion. the 'length' of xword is also decremented. the two characters are counted only once. plus the number of disagreements. XXXXXX would correct to PP. 32 17.g. commands. and therefore can use more conservative metric.e. and should not be counted as disagreements.23 . disables DWlM. dwimi fy performs all corrections and transformations that 31----------------------------------------------------------------------------In this case. for example. only 60% with fastypeflg=NIL . 32 it be Transpositions are also not counted when fastypeflg=T. e.

to spellings 1 (at end of (at end of Used by lispx.splst. 17.24 . Used by load when loading exp rs to property lists. Used by defineg.would occur if :i were actually run. addspell sets lastword to x when splst=NIL. if splst=2. If splst=O. dwimi fy is undoable. adds permanent section). splst can also be a spelling list. and in its temporary section. adds!$ to userwords and spellings3. adds ]. See page 17 . adds ~ to userwords spell ings2. addspell takes no action. adds !$ to userwords. four spelling lists as and t. to the front of that section. addSpell moves ::. in which case !l is the (optional) length of the temporary section. addspell[x. If splst=1.n] Adds ::: to one of the dwimifies current expre~sion. 55·-------~------------------·---------------------·-··-----·------------------ If x is already on the spelling list. 0 or 3.! permanent section). ~ to spellings2 Used by lispx. ow edit macro.o fOllows : 33 if splst=NIL. If ~ is not a literal atom. If splst=3.14 for complete description of algorithm for maintaining spelling lists.

fn. misspelled? checks to see if xword is really misspelled.splst. and no approval is requested. the correction is handled in type.flg. i.!9=NIL. interactions fixspell performs described all earlier. of the including requesting user approval if necessary.25 not .splst.fn] If xword=NIL misspelled? alt-mode. and xword is not typed.fn) fixspell[xword.e.in mode. 17. without asking for approval.rel.!9=T. i. xword is typed (before the =) and approval is requested if approveflg=T: If tail is successful. of and ~ the is correction replaced by is the .e.tail. or prints = followed by the value of lastword. If the or $ ~=NIL value of the respelling is (alt~mode).£!!:.misspelled?[xword. and returns this as the respelling.flg:tail.tieflg) 34 The value of fixspell is either the respelling or xword or NIL. misspelled? ~imply returns Otherwise misspelled? computes and returns fixspell[xword:rel. lastword. approval is never requested. If !. NIL.tail.flg.rel:splst. ~· In this case. Otherwise. i f fn applied to xword is true. or xword is already contained on splst. If !.

. tail would be changed to fixspell AFTER would return (AFTER COND 2 3). nor modify !ill• the idea being that the calling program will handle those tasks. (subject to and user approval where n0cessary). 36 If tail=T.?pl st is found with the same degree of 'closeness'. replaced by the two words. If f:ixspell determines that 35---------------------------------------------------·------------------------In this case. fixspell will also perform run-on corrections. or fewer characters than tho second word. 86 If tieflg=T and a tie occurs. the first word is taken as tho correct spelling.xspell is called to correct £fil: of and one. In addition.respelling (using .e. tail is value of example. fixspoll will correct misspellings caused by runnin. returning a dotted pair of the two words in the event the correction is of this type.26 . In addition. 1 Run-on 1 spelling corrections can be suppress~d by setting the variable runonflg to NIL (initially T).{rplaca). 17 . 35 In this case. the default will be N. i. fixspell NIL. fixspell is the first f:l. user approval is always requested.e. more than ono word on . no correction. returns i. If tieflg=Nil and a tie occurs. if the first word contains either fewer than 3 characters.5 seconds. if the For the two edit command (MOVE TO AFTERCOND 3 2) with tail=(AFTERCOND 3 2). the value of fixspell is a list of the respellings * if (even there is only one). The time required for a call to fixspell with a spelling list of 'length 60 when the entire list must be searched is . If tiefl9=All.g words together. and fixspell will not perform any interaction with the user.

the time required is . tho timo required is proportional to the number of words with which xword is compared.the first word on the spelling list is the respelling and does not need to search any further.e.27 . being roughly . i.01 seconds (varies slightly with the number of characters in the words being compared. ln other words. with the time for one comparison.) The function chooz is provided for users desiring spelling correction without any output or interaction: 17. one call skor.02 seconds.

g. to correct its spelling. of and NIL * fncheck[fn.FOO). (BREAK • FOO).2! will be a dott~d pair of 'the two * words.IIM. 39 If fn is the name of a function or spelling correction is successful. tail.. otherwise it prints fn NOT A FUNCTION and generates a non-breaking error. tho The task of fncheck is to check whether fn is the name of a function and if not. 88 chooz does not perform spelling completton. fncheck adds the (corrected) name of the function to userwords using addspell.. . etc. 11:2a . tetflg.nomessflg. 89 Since fncheck is called by many low level functions such as arglist. tieflg)37 corrected The value of xword 38 spelling ·of chooz is NIL. ' • fixspell above.spellflg] consists is not words (BREAK FOO) for (BREAK . e. for internal use by DWIM. and returns it as its value.g. e. unsavedef. or the chooz • performs • splst. rel..chooz[ xword. • •.!! are as described under no interaction and no output . 37----------------------------------------------------------------------------chooz has some additional arguments. fncheck· simply returns NIL. nomessflg informs fncheck whether or not the calling function wants to handle the unsuccessful case: if nomessflg is T. • J ll1! If running two the misspelling • • together. and !. only spelling correction. value of £!12. splst: tail:: fn. spelling correction only takes place when dwimflg=T. so that these functions can operate in a small INTERLISP system which does not contain D\.

bcompl. Many other system functions. and edita. to to fourth the spelling value of spe 11 flg corresponds argument. breakO. lastword wi 11 be returned. breakO wants to define a dummy one. 17. i. for since if fnchcck cannot produce a function. brecompile. tcompl. printstructure however calls fncheck with nomessflg=NIL. it calls fixspell with two different spelling lists. Similarly. fncheck is currently used by arglist. breakl calls fixspell on unrecognized atomic inputs before attempting to evaluate them. unsavedef. printstructure. and recompile all if their input file(s) won't open. lispx calls fixspell on atomic inputs using a list of all lispx commands. approval will be asked i f DWIM was enabled in CAUTIOUS mode.e. first with brokenfns. so misspelled? that if misspelled? 1 s perform fn=NIL. prettyprint. and if that fails. using as a spelling list a list of all break conunands. spelling list. advise. if approveflg=T. since it cannot operate without a function. chngnm. breakin.29 .fncheck calls correction. breakO calls fncheck with firstfn. flg. If spellflg=T. call misspelled? makefile calls misspelled? using filelst as a Finally. lastfn. example. load. When unbreak is given the name of a function that is not broken. nomessflg~T calls. For example. call misspelled? or fixspell directly. with userwords.

... DWIMIFY[X....••••••......••............. LASTWORD (dwim variable/parameter) ..•......•.•...............SPLST....••.. ....BRKFN..22 17.. .....REL....15...... FNCHECK[FN.•.BRKTVPE] NL BROKErJFIJS (break variable/parameter) •....•..... .....••...PROPFLG) . DWIMUSERFN (dwim variable/parameter) ........Index for Section 17 Page Numbers ADDSPELL[X...•.......•..17v19 ... spelling correction protocol ..•..•...•.. approval (of dwim corrections) •••........5-9...5.......•........ FIL .SPLST.....9 17.SPLST.V) SUBR •••••••••••••••••••••••••••••• EXPR (property name) .SPLST...26 17.. .5.. BREAKl[BRKEXP...... DWIMWAIT (dwim variable/parameter) ....5·7 17..... FILEDEF (property name) ......•....26 17...........• SHALL I LOAD (typed by dwim) ..NOMESSFLG...•.. control-E ·························"············· DW (error message) .21•23 17 ..29 17.• ...•.9 17..29 17. BREAKCHECK ...19 17..6 17 .. 23 17.. FAULTAPPLY[FAIJLTFN...... CHOOZ[XWORD.•........••.......20 17..17 .24-25...•..10-12...NDBLS..•..•.. 17....•........FAULTARGS] ..•...15....18-19 17....5...19 17..•...........27-28..22 17.... .•...•.29 17.............. 15 17...29 17.. DWIMFLG (dwim variable/parameter) .••••.CLST.....•........... .....••.•....N] .....17-18 17......14. MODEL33FLG (dwim variable/parameter) ..25.28-29 17.17......SOURCEFILE] MISSPELLED?(XWORD.....2..11 17..REL....•.5 17.. FASTYPEFLG (dwim variable/parameter) .18......•...1 17...................20-23......•.....12...5 17.... 18 17....17 17.•.23-24 17 ..1·29 17.•..25-26......•.....24........•••• CAUTIOUS (DWIM mode) ... •.....•..29 17........................29 17.12~15..... ....5-9.........19 17..BRKCOMS.....• alt-mode (in spelling correction) AMBIGUOUS (typed by dwim) •••........ · • · · · · · · · · · · · · · keyboard layout .....•. . ..... EOITCOMSA (editor variable/parameter) ..•.TAIL...26 17.. RETEVAL[POS..•......•.........6. FILELST (file package ~ariable/parameter) .... ............ OKREEVALST (dwim variable/parameter) ....•...29 17.• . ERRORSET[U........9 17.. spelling corrector ....3.... OK TO REEVALUATE (typed by dwim) .•...•.... MAKEFILE[FILE....... 5... EDITCOMSL (editor variable/parameter) ...L] .•......•••• bell (typed by dwim) ....•........•. LAMBDASPLST (dwim variable/parameter) ...... LISPX ..5.....25 17 .....•..•........•.•.5..28 17....29 17...FORM] SUBR ·········~················ RUNONFLG (dwim variable/parameter) ... EDITDEFAULT ..BRKWHEN.•.... DWIM variables .16-18 17..•..•.17-19 17.••..FLG.21....5.17-18 17...12-14.SPELLFLG.FLG..•.•.15 17...28 17..TIEFLG....• .. .........••...15 17...23 17.....17-19 17. ....... .....•.......••.••...FN] .......••.•••• APPROVEFLG (dwim variable/parameter) ...28 17.....•...... run-on spelling corrections •...............••.......•............11 17.....•••..23.•...24 17..........11..8 17.TAIL.• error correct ion .........•.3...29 17. FAULTEVAL[FAULTX] NL• ..••••••••• DWIM interaction with user ........FN.5..• FIXSPELL[XWORD............CLST] •• CLISP ••••••••o••••••••••o•••coo•o••o•••••••••·••• CONTINUE WITH T CLAUSE (typed by dwim) •..••....••• DWIM[X] DWIM ...........••..•.15 17...REPRINTFNS...•.....OPTIONS.•.25.••••••••••••••••• spelling corrlpletion 0 ••• .•••......• SKOR .29· 17.......... •••••••.TAIL:FN:TJEFLG...6-7.•........•••...... APPROVALFLG] .....REL...... spelling lists ···············••••oe•••••••••••o• INDEX....1-29 17 . .

••.•.14 17..•. T (typed by dwim) ..........•...13-14.. ..•••••......4..•...•........•. command) ...•••..B..........•. ...7...••••••••.5....13-14..24 17....••..4 17....•••••.••.•••••. 17....•..24 17......... synon~s T FIXED (typed by dwim) ...2 .•.. ......23 17.......17-18 17....... ..D...••.. undefined function .A. . T FIX? (typed by dwim) .....••.••. .•.. .....•.6°7 (typed by dwim) ........ 11 17...••.•..24.•. ......•• 11...•....••• 17......•.... (typed by dwim) .••• $ (alt-mode) (in spelling correction) ...12-14.•••••.15-19 17.•...•.... asst...••• ur~SAVEDEF[X.•.24 17..•.••...•• #SPELLillGS2 ( dwim variable/parameter) •.....F... ...17..........18-19....•...2....•.8 17.16 8 (instead of left parenthesis) ••••••••••••••••• 17.5.....7.15 17.6-7 INDEX...2.••... UllDO ( prog...28-29 17....•..•...•••...G 7 (instead of') ...... .14 17..•......17...3-4.14 17....•..••.... 17..3.•.• ..16... unbound atom . (error message) .. 11........18 = (typed by dwim) •.•. ....••• .......•. 11..Page Numbers SPELLIHGSl (dwim variable/parameter) SPELLillGS2 (dwim variable/parameter) SPELLIHGS3 (dwim variable/parameter) .. UIJSAVED (typed by dwim) .7 ? (typed by dwim) ... ......2.........•... F..8 17....15 17.17-18 17..16 17.•.15-19 17...•...• (error message) ........ 25 17..../IM mode) ..•.• #SPELL IrlGS 1 ( dwim variable/parameter) . U..16..TYP] •••••••••••••••••••••••••••••••• USERWOROS (dwim variable/parameter) ......••.8 17. D..... TRUSTHJG (O\........ U......•..... I -> • • "' • • • • • • e • e e e • • e e e 0 I • e 0 • • e ••••• 0 •• I • e ' e ' ' e ' •• ' 17..19......•...•••••..14 17....•.•.......•• #USERWORDS (dwim variable/parameter) •.D.18-HI 9 (instead of right parenthesis) •..13-14.....••..F....••. U.••• U..• tJSPELLHIGS3 ( dwim variable/parameter) •.

.

or it may be written onto a file for subsequent loading. to compile from a producing a corresponding file which contains a functions in compiled form which can be quickly loaded. the user has the option of specifying whether the code is to be saved on a file for subsequent loading. i. bcompl. i. The first ~uestion is: i-------------------------·----------------------------------·-----------------The INTERLISP-10 compiler itself.e. so as to be available for immediate use. In either case. were written by W. and brecompile. The resulting code may be stored as it is compiled. The compiler in INTERLISP-10 also provides a means of specifying sequences of machine instructions via ASSEMBLE. symbolic set of An alternate way of using the compiler is to compile from functions already defined in the user's INTERLISP system. the compiler will ask the user certain questions concerning the compilation. tcompl. and is· the responsibility of A. Hartley.K. The user interfaces.SECTION 18 THE COMPILER AND ASSEMBLER 1 18. was written and documented by. or both. In this case. Teitelman.1 The Compiler The compiler is available in the standard INTERLISP system.e. or the functions redefined. The most conunon way to use the compiler is ( prettydef) file. recompile.1 . It may be used to compile individual functions as requested or all function definitions in a standard format LOAD file. 18. the part that actually generates code.

the user will want to answer this question with either ST or f.Z file. and no storing of definitions is performed. File name file is opened if not already opened.. the rest of the questions which would otherwise be asked. . which will also specify an answer to . and compiled code is written on th~ Example: . However. f means the· user is only interested in compiling to a file.LISTING? The answer to this question controls the generation of a listing and is explained in full below. In both cases. COMPILE((FACT FACTl FACT2)) LISTING? ST OUTPUT FILE: FACT. the compiler will then ask the user one more question: OUTPUT FILE: to which the user can answer: N or NIL no output file. for most applications. 18.COM (FACT COMPILING) (FACT REDEFINE0) 2 (FACT2 REDEFINED) (FACT FACT1 FACTZ) . . ST means the us or wants the compiler to STore the new definitions.

The variable lapflg is set to the answer. redefined. or NIL for NO. Possible answers are: 1 Prints output of pass 1. the LAP macro code. YES Prints output of both passes. the function compset is called which asks a number of questions.COM for subsequent loading. The variable lstfil is set to the answer. NO Prints no listings. 3 2 Prints output of pass 2. Those that can be answered •yes' or 'no' can be answered with YES. 18.f. These variables are set by the \. The questions are: LISTING? The answer to this question controls the generation of a listing. svng. and NO. If the answer is affirmative. 1. the machine code. answers to the 'compset' questions./hen any of the top level compiling functions are called.This process caused the functions FACT. and FACTZ to be compilod. 18. Y. lcfil and lstfil which determines various modes of operation. llr. or T for YES. and the compiled definitions also written on the file FACT. N. cornpset will type FILE: to allow the user to indicate where the output is to be written.3 .2 Compiler Questions The compiler uses the free variables lapflg. FACTl.

and S makes no change. F. The variable strf is set to NIL. and S makes no change. 3. ST STore new definitions.There are. + They are: S §ame as last setting. forget exprs. so questions 2 and 3 would not be asked i f 1 were answered with S. The compiled code is stored and the function definition changed. 2. svflg is set to T. The answer ST or STF for the first question implies YES for this question. three other possible answers to LISTING? . REDEFINE? YES Causes each function to be redefined as 1t is compiled. SAVE EXPRS? If answered YES.4 . F implies NO. The variable !!!f is set to T. F Compile to file (no definition of functions). Otherwise they are discarded. and the exprs are saved on the property list of the functfon name. NO Causes function definitions to remain unchanged. STF .each of which specifies a complete mode for compiling. The answer ST for the first question implies YES for this question. 18. ST.§!ore new definitions. F or STF implies NO. or STF. Implicit in these three are the answers to the questions on disposition of compiled code and expr 1 s.

SUBRR. or NIL. CFEXPR) 3.5 . output will not be the file named is already open. OUTPUT FILE: If the compiled definitions are to be written for later loading.mbda !toms). EXPR. the compiler will first look for a definition among the functions in the file that is being compiled. spread (FSUBR. FEXPR. CFEXPR*) CEXPR~) In attempting to determine which of these three is appropriate. 18. If is If you answer T or TTY:.4. 18. not spread (FSUBR*. EXPRitt. assumes the function is a lambda. the compiler will look for other information which can be supplied by the user by including nlambda nospread functions on the list !l!fil!!! (for n.3 Nlambdas When compiling the call to a function. If the function is not contained there. tcompl. it will continue to be used. since in the absence of other information.!lfil!:!bda !ist). 6 the compiler The function can be defined anywhere in any of the files given as arguments to bcompl. done. NO. brecompile or recompile. the output will be typed on the teletype (not particularly useful). Evaluated (SUBR. FEXPR*. you should provide the name of a file on which you wish to save the code generated.!· 4 If the function is not contained in the file. that If you answer N.l!. 6 or ~-----------------------------------------------------------------------------Including functions on lams is only necessary to override in-core nlambda definitions. The free variable lcfil is set to the name of the file. Unevaluated. and including nlambdn spread functions on the list nlaml (for !. Unevaluated. 2. and including lambda functions on the list l!m. CEXPR. the compiler must prepar~ the arguments to the function in one or three ways: 1.

the compiler compilos the original expression as a call to a lambda-spread that is not yet dofinod.6 . its arguments are to be evaluated. it is maintained for the user's benefit.4 Global Variables Variables that appear on the list globalvars or have the property GLOBALVAR. CLISP (Section 23) uses compileuserfn to tell the compiler how to compilo · iterative statements. the compiler will automatically handle calls to that function correctly. compiler assumes that·the function is of type 1. so that the user can check to s~e whether any incorrect assumptioris were made • . nlaml. value of) cornpileuserfn giving it as arguments f_Q!.. the compiler doos (APPLY* COMPILEUSERFN (CDR form) form). and compile the calling function correspondingly. or lams. i.arguments evaluated. with value * T~ are called global variables. if thore are type 2 or 3 functions called from the functions being compiled. 7 The names of functions so treated are added to the list n1 ams (for !Ssumed lamda!). i. a reference to the value of this variable i.out the function. 5-----------------------------------------------------------------------------Before making this assumption..e. or the compiler will incorrectly assume that their . lf tho function is defined at compile time. If it is not defined. 18. In other words. or is handled via a macro. are to be Note that this is only necessary if the compiler does not 'know' ab. and pattern match constructs. its function type is assumed to be the desired type. it is compiled instead of form. they must be included on· nlama or nlaml.on the list nlarna. 18. If a non·NIL value is returned. or is contained in the same group of files as the functions that call it. Such variables are always accessed through their value cell when they are used freely in a compiled funtion. If NIL is returhed.e. i. IF~THEN·ELSE statements. definition. the compiler will look for a current If the function is defined.e. alams is not used by the compiler. of th~ form and the form itself. and thoy are only defined in a separate file. the. 6 7 In other words.s equivalent to (CAR (QUOTE variable)). the compiler calls (the. if the value of compileuserfn is not NIL. regardless of whether or not it appears on the stack.

FOO UNBROKEN~ If the function is not defined as an expr. For .i. and a message printed out. or a control-D was typed. and the function has been modified by break. the variables must be re. editmacros. e.e. as opposed to tcompl ur bcompl (which uses ~ the definitions on a file). or brecompile. and if they are to be restored to their original values. reset again. et a1. * brokenfns. its property list is searched for the property EXPR (see savedcf. especially for deep computations. via t1 compile. the global variable would not be restored to its original value. entered.• (SETO globalvar new-value) form example.. i. i. * e. (SETO variable value) is equivalent to (RPLACA {QUOTE variable) value). unless otherwise specified. or advise. rebinding these variables t1 have on their property lists the property GLOBALVAR with T. All system parameters.5 Compiler Functions Note: when a function is compiled from its in core definition.set to their new values.. 1. 18. #rpars. the stack is not even searched for this variable when the compiled function is Similarly.e. The function reset var (described in Section 5) provides a convenient way of resetting global variables in such a way that their values are restored even if an error occurred or control-D is typed. o.7 .. 8 Thus.g.. recompile.g. trace. section 8). are global variables. if an error occurred during the evaluation of form. breakin. dwimflg. value will not affect the behavior of the system: instead.. it sets the top•level value. the user (SETO globalvar old-value). If i------------~---------------------------------------------~--~---------------Since the stack does not have to be searched to find the values of these variables. 18. a considerable savings in time is achieved. might Note write that in this case.e. it is first restored to its original state.

+ definition Otherwise. definitions Value is are being ~· dumped to a file. its value is used for the compilation. compile[x. See Section 23.e. is tcompl.. T. and which 18 .g.8 causes the message COMPILED .+ there is a property EXPR. list[x] is compile first asks the standard compiler questions.def] compiles def. or and def recompile. symbolic load prettydef). 9 compilot is used by compile.. tcompl[files] tcompl is used to 'compile files'. it file (e. the compiler prints ( fn NOT COMPILEABLE). flg] ~ is a list of functions (if atomic. used). given a that (1) file' by that the original a special FILECREATED expression appears at the front of tho file which contains information used by the filo package. produces a one file.· and then compiles each function on ::. contains· def is dwimified before a If CLISP compiling. using its in~core If compiled definition. dwimifycompflg declaration.. the file is closed unless flfl=T. redefining~ if strf=T. compilel[name. If there is no + EXPR and the compilation iS being performed by recompile or brecompilo. except created 'compiled contains the same S-expressions as symbolic i. of the function is obtained from the file (using the loadfns). and goes on to ·the next function.

to be printed when tho file is loaded. i:i tcompl[(SVM1 SYM2)J produces two files.g. 11 and (3) . expressions of the form (DECLARE: -. before the other expressions in the symbolic file. + . tcornpl(<BOBROW>FOO. g.3] produces FOO.TEM. This 'compiled' file can be i:i loaded into any INTERLISP system with load. e. 13 tcompl processes each file one at a time. reading ia----------------------------------------------------------------------------The actual string printed is the value of compileheader... The actual suffix used is the value of the variable compile.e.COM. files 1s a list of symbolic files to be compiled (if atomic.ext. (2) every dofineg in the symbolic file is replaced by the corresponding compiled definitions in the compiled file.9 + + + + + .ON 10 followed by the date. 18. regardless of 11Jhere tlley appear tn the symbolic file. The version number will be the standard default. SYMl . The file name is constructed from the name field only.COM and SYM2. the output from for tho compilation of each symbolic file is written on a file of the same name suffixed with COM. The user can reset compile. 11 12 13 for example to The compiled definitions appear at the front of the compiled file. The user can reset compileheader~ distinguish between files compiled by different systems. which is initially COM. list[f11es) is used). 12 o.DONTCOPY --) that appear 1n the symbolic file are not copied to the compiled file. without adversely affecting any of the system packages. tcompl asks the except questions.. i. initially "COMPILED ON".COM on the connected directory.ext or rename the compiled file after it has been written. compiler standard OUTPUT FILE: Instead.

since their definitions would be superfluo~s when operating with the compiled file.nside of those functions will not propagate outside. this option might be used for functions that compile open. brecompile. ·For each DEFINEQ expression. 16 nlama. 16 and adds LAMBDA's to the list lams. page 18. For example.elow. nlaml. recompile. 17 except for those functions which appear on the list dontcompilofns. 14 and the FILECREATED expression is written onto the output file. 18. 16 described earlier.in * the entire file. and lams are rebound to their top level values (using resetvar)by tcompl. The value of tcompl is a list of the names of the + + + + + + + 14------------------------------------------------------~----D----------~------ for use by recompile and brecompile which use the same low level funtions as tcompl and bcompl. All other ex·pressions are collected to be subsequently written onto the output file. 17 and writes the compiled definition onto the output file. tcompl compiles each funtion. Expressions beginning with DECLARE: are processed specially as described b. For each expression.10 .30. the list of functions ~hat FILECREATED were marked as changed by the file package (see section 14) is not~d. 16 so that calls to these functions will be compiled correctly. initially NIL.5. Note that dontcompilefns can be set via block declarations page 18. and blockcompile. compile. tcompl adds any NLAMBDA's in the DEFINEQ to nlama or lam1. so that any additions to these lists while i. After processing the file in this fashion. bcompl. tcompl ihen writes onto output file the other expressions found the in the symbolic file.

output files. tags -1- e. 18 .) '°" Each expression in cdr of a DECLARE: form is either evaluated/not-evaluated and + copied/not-copied de. to set up macros. all files are + properly + and closed. DECLARE: (see section 14) has two principal + applications: ( 1) to specify forms that are to be evaluated at compile time. to + indicate which expressions appearing in the symbolic file are not to be copied + (Normally. + (QUOTE MACRO))) could be used to -> to the output file. for the DOEVAL@COMPILE (or EVAL@COMPILE) (DECLARE: DOEVAL@COMPILE DONTCOPV (OEFL!ST and and/or (2) DONTCOPV. but at a considerable savings in time by compiling selected functions and copying from an earlier tcompl or recompile file the compiled definitions for the remainder or the functions in the file. If the closed. initially set for copy and not-evaluate.. Recompile does this by using the It produces a compiled file similar to one that would have been produced by tcompl. expressions are not evaluated and are copied. e. Recompile The purpose of recompile is to allow the user to update a compiled file without recompiling every function results of a previous in the file. compilation of any file and the (partially complete) compiled file is deleted.. + presumably to affect the compilation.11 . ~ set up macros at compile time. + DECLARE: for the purposes of compilation. .pending on the settings of two internal state variables. All files are properly termina tod is + aborted via an error or control-D. compila~ion.g.g. These state variables can be reset + remainder of the expressions in the DECLARE: by means of the.

21 After this initial scan of pfile.ext. 20 A map is built i f the symbolic file does not already contain ono. pfileCOMS means FOOCOMS. output automatically goes As to with tcompl.COM. 21 The filemap enables recompile to skip over the DEFINEQ' s in the file by simply resetting the file pointer.12 . COM. compiled fns definitions that indicates which functions may bo in pfilo are to be recompiled. For examplo.. drives rec. or with buildmapflg=NIL.ompile. all constructions of the form pfile. except for OUTPUT FILE:.cfile. 19 In general. pfile. if pfile=<BOBROW>FOO.ext. where ill is the value of compile.TEM..£.COM means FOO.recompile(pfile. etc. and simply skips over the DEFINEQ's.. pfileBLOCKS. not fns. have been changed or defined for the first time since cfi le was made. are performed using the name field only. it was written in an earlier system. .f.g. recompile uses the filemap (see section 14) 20 to obtain a list of the functions contained in pfile. recompile asks the standard compiler questions.fns) pfile is the name of the ~retty file to bo compiled. so that in most cases the scan of tho symbolic file is very fast (the only processing required is the reading of the non-DEFINEQ's and the processing of the DECLARE: expressions as described earlier).3.il! is the name of the £Omp·iled f i lo containing copied.g. Note that pfile. e. e.1 8 the 19 recompile process pfile the same as does tcompl except that DEFINEQ expressions are not actually read into core. pf ileCOMS. + + + + + + 18 . Instead. etc.COM. recompile then + + ia----------------------------------------------------------------------------or pfile. pfile.

Jrom. an fn NOT FOUND error is In other words. lf cfile=NIL. generated. 18. but which has already been loaded (since using tcompl would require reading the file in a second time). pfile.ti:!! are NIL.COM If both is used for copying ill and £. 23 If ·a function recompiled. recompile to be its recompile definition from cfile..processes the functions defined in the file. compiled and copies it (and all obtains sub functions) pfile. 25 pfile. generated functions.COM. and in fact does not have to exist. processing out * all other expressions that were collected in the prescan of pfile. is NIL. or R (2) fns=T or EXPRS and the function is an expr. is not after writes output the all R file.13 +. + + + + + . or (4) fns=ALL. fns is 22·------------------~---~----------------····--·--···---··-----------·-------. 24 to Finally. i. and recompile aborts. same name as output file but a different version number (one less) than the output file. recompile For determines whether or not the function is to be (re)cornpiled. cfile is superfluous. Functions that are members of dontcompilefns are simply ignor'ed. if cfile. for example. R A function is to be recompiled22 if ( 1) fns is a ~ list and the function is a member of that list. This option is useful.e. each function in pfile.COM is used. or R (3) fns=CHANGES and the function is marked as having been changed in the FILECREATED expression. If the function does not appear on cfile. 23 24 26 In this latter case. to compile a symbolic file that has never been compiled before.. the file used for obtaining compiled definitions to be copied.

and then simply recompile[file] to update the compiled file. If recompile is aborted due to an + pfile . by recompile. 18. + + 27 The loadfrom would be unnecessary if the compiled file had been previously loaded.tydef automatically outputs a suitable DECLARE: expression to indicate which functions in the file (if any) are defined as NLAMBDA' s. the user can perform a loadfrom (section 14) Open Functions When a function is called from a compiled function. a system ioutine is invoked + + + ----------------------------------------------------------------------~-----···26 This is the most common useage. and therefore wi 11 be exprs. the functions· the user has changed will have been unsavedefed by the editor.COM. 30 Since pret. Thus the user can perform his edits. makefile would from the symbolic file. since this would also result in the file having been 1 noticed 1 • 28 As described in section 9. 29 and then perform recompile[pfileJ. + to 'notice' a symbolic file. 29 As described in section 14. the new (partially completo) + compiled file will be closed and deleted. dump the file. the editor would functions not already loaded. + + + + + + + + + 18 .6 even when the corresponding symbolic file has not been For example. 26 The value of recompile is the new compiled file. or even looked at. + recompile is designed to allow the user to conveniently and efficiently update + a + (completely) loaded. calls to these functions will be handled correctly. 27 and then simply edit the functions he wanted to + change. Typically. meaning recompile all exprs.14 automatically load those copy the unchanged functions . even though the NLAMBDA functions themselves may never be loaded. 30 compiled file. 28 call makefile. + error or control-D.set to T.

!DIFFERENCE. CAR. LRSH. ARRAYP. FMINUS. LIST. FLOATP. Therefore below is a list of those functions which whon compiled do not result in function calls. they do not result in Other larger functions such as .!. FLENGTH. 31 The following functions compile open in INTERLISP-10: AC. !TIMES. MAP. MAPLIST. . FLAST. FMEMB. CONS. ASSEMBLE. CAAR. SOME. FDIFFERENCE. LITATOM. FNTH.. ILESSP.QLQ. this function calling time will be a significant percentage of the total time required to use the function. UNDONLSETQ.a up to If the amount of time spent inside the function is small.g. !MINUS. always compiled 'open'. ARG. As a result. LOC. EVERY.e. FSTKARG. RESETFORM. GO.. CDDDAR. selectq. LSH. SETQ. FIX. e. LLSH. RESETSAVE. NOTANY. * PROG. RESETVAR. ATOM.g. IPLUS. FLOAT. NULL. SETN. RETURN. MAPC. MAPCON. NOTEVERY. IGREATERP. TYPEP. FRPLACA. NUMBERP. EVQ. MAPCONC. 11t RSH.15 . OR. FTIMES. ADDl. NLSETQ. FGTP. CLOSER. FRPLACD. !QUOTIENT. FIXP. BLKAPPLY. PROGN. . tHVP. EQ. GETHASH. LOGXOR.6. SMALLP.. VAG. STRINGP. CDDDDR. It is useful to know exactly which functions are compiled open in order to determine where a program is spending its time. mapc. ~are Therefore. NOT. 18 . many 'small' functions. !REMAINDER. i. etc.. MAPCAR. function calls can talc. BLKAPPLY~. OPENR. MINUSP.that sets up the parameter and control push lists as necessary for variable bindings and return information. FASSOC. £. RPTQ. are compiled open because they are frequently used. SUB1. SETARG. SELECTQ. AND. FUNCTION. ZEROP 3i------------------•••••••••••••••••••••••••-•••••••••••••••••••••••••••••••e• The user can also affect the compiled code via compileuserfn. not. 350 microseconds per call. COND. NEQ. described in footnote on page 18. RESETLST. FPLUS. LOGAND.£!!. FCHARACTER.g_.. LOGOR. FQUOTIENT. CDR. ~ PROG 1.:• cdr. a function call. APPLY•. ERSETQ. LISTP. NLISTP. Note that the next section tells how the user can make other functions compile open via MACRO definitions. SUBSET. FSTKNTH.

7 Compiler Macros The INTERLISP. ~ and uses it to. so that these will not be affected by macro definitions.(atom expression) A macro definition beginning with an atom other than LAMBDA.by placing the macro definition on tho property list of the corresponding function. or NIL.. so. if any. NLAMBOA..~-~.compiler includes a macro capability by which the user can affect the compiled code.. 33 The compiler has built into it how to compile certain basic functions such as f. of the function wherever it appears in a function being compiled.. {LAMBDA (X) (COND ((GREATERP X 0) X) (T (MINUS X)))) for abs. allows computation of the INTERLISP expression that is to be compiled in place of the form. ~· etc. Thes• functions are listed above. )or (NLAMBOA ..!:. )or (NLAMBOA .. under the ·property MACRO . ) A function can be made to compile open by giving it a macro definition of tho form (LAMBDA .-..(LAMBDA ••.. i. direct the compilation.16 .. it compiles as an open LAMBDA . The atom which starts the macro definition is bound to cdr of the 32--~~-.e.2.-~.e..~ within a function to define a MACRO... The effect is the same as though the macro definition were written in place. 33 The three different types of macro definitions are given below.. 32 Whon the compiler begins compiling a form.... (1) Open macros .or NLAMBDA expression..~~. This saves the time necessary to call the function at the price of more compiled code generated. that the user could change the way they compile.~~CDECL~~E-CDEFLisr-:::·cQ~OTE·~~c~o)))-~.·. · 18 .g.~. some of thorn are themselves implemented via macros. However. (2) Computed macros . DECLARE is defined ~he same a~ QUOTE and thus can be placed so as to have no effect on the running of the function.~~~-~.18. it retrieves a macro definition for of the form. ). Macros are defined..

This is a way of giving direct instructions to the compiler if you understand it. A substitution macro. fassoc. 84 For example. atom INSTRUCTIONS. nlsetg. Thus.· flast.. (SUBPAIR (CAR macrodef) (CDR form) (CADR macrodef)). 18 . It is then assumed the evaluation was done for effect and the necessary code. if the result of the evaluation is the.(NIL expression) or (list expression) Each argument in the form being compiled is substituted for the corresponding atom in ~ of the macro definition. The expression following the atom is then evaluated. For example. 36 list is actually compiled more efficiently. (3) Substitution macro . and the result of the substitution is compiled instead of the form. mapcar. i. has been added. Note the recursion in the macro expansion. The functions. Note that abs could be compiled open as shown earlier or via a substitution macro. list could be compiled this way by giving it the macro definition: [X (LIST (QUOTE CONS) (CAR X) (AND (COR X) (CONS (QUOTE LIST) (COR X] This would cause (LIST X Y Z) to compile as (CONS X (CONS Y (CONS Z NIL))). sutit. and fnth are all compiled open using substitution macros.form being compiled. zerop. 85 Ersetg. i f any. however~ would cause (ABS (FOO X)) to compile as (CONO ((GREATERP (FOO X) 0) (FOO X)) (T (MINUS (FOO X)))) and consequently (FOO X) would be evaluated three times. mapc. neg. add1. nlistp. 34----------------------------------------~-----------------------------------In INTERLISP-10. (ADD1 (CARY)) is compiled as (IPLUS (CARY) 1). flength.e. the macro definition of add1 is ((X) (!PLUS X 1)). and ~· are compiled via macro definitions of this type. map. fmemb. no code will be generated by the compiler. and the result of this evaluation is compiled in place of the form.17 . mapconc.

Q or return cannot be used inside of a com. 18 . but also each of the function c•lls to its functional argument. 38 and then FOOt will call FOOAOOOn each time it must use its functional argument.9 is outside.. FOOl will be called with two arguments.g. )) •. see Section 11. this savings in time cost space. 30----------------------------------------------------------------------------except when they are compiled open. i. as an open LAMBDA expression. and FOOAOOOn. 37 This gensY!J! function will be called at run ~ime. Thus you save not only the function call to FOOl. (FOOl X (FUNCTION .18. example..8 FUNCTION and Functional Arguments· Expressions that begin with FUNCTION will always be compiled as separate functions 36 named by attaching a gensyrn to the end of the name of the function in which they appear. ten~ eleve~ For function calls will Of course. Note that a considerable savings in time could be achieved by defining FOOl as a computed macro of the form: (Z (LIST (SUBST (CAOADR Z) (QUOTE FN) def) (CAR Z))) where def is the definition of FOOl as a function or Just its first argument and FN is the name used for its functional argument in its definition. X. 37 nlsetg and ersetq expressions also compile using gensym functions. as is the case with most of the mapping functions. above the nlsetg or ersetg.e. ) and compiled. if F001 operates on a list of length be saved.•.. and the user must decide which is more important. a 11. The expression compiled contains what was previously the functional argument to FOOl. e. Thus if FOO is defined as (LAMBDA (X) . As a result.piled nlsetq or ersetg if the corresponding 2!Q.. 38 or an appropriate funarg expression.. then when FOO is run. FOOAOOOJ.18 .

The effect is thus the same as though there were several different entry points. etc. compilation is a single. function. the compiler block has nine entries. compiling a block consisting of just a single recursive function may be yield great savings if the function calls itself many times. The output of a block. usually large. 39 For the error block has three entries. interrupt. functions all 'know• where the variables are stored. Function calls between the component functions of the block. equal. since the block However. called entries. However. count are block compiled in INTERLISP.9 Block Compiling Block compiling provides a way of compiling several functions into a single block. Calls from within the block to functions outside of the block look like regular function calls. it can be broken. advised.e. i. 18.19 . and the price of using a free variable.. the entry functions call the main block with their name as one of its arguments. and jumps to the portion of the block corresponding to that entry point. is paid only once .g.18. except that they are usually linked (described below). Thus. are vory fast. This function looks like any other compiled function. nt the top. errorx. These must be specified when the block is compiled. printstructured.. is entered. Specvars One savings in block compiled functions results from not having to store on the stack the names of the variables bound within the block.when the block. namely the time required to look up its value on the stack. A block can be entered via several different functions. ~· and. it must be included on 39·-----------------------------------------------------·---------------------Actually the block is entered the same as every other function. e. Similarly. and fault 1. i f a variable bound in a block is to be referenced outside the block. example. and the block dispatches on the name.

~hen the variable is bound.. but the error functions must be able to obtain its latest value. Should the variable in fact be referenced before it is bound. 18. their free values above the block are never used.e. helpclock is on specvars. i. of the value of the free variable at the time of entry to the block can be avoided by putting the variable name on the list localfreevars. Future references to that variable during this call to the block will be normal. a rather time-consuming process wi 11 take place. the value wi 11 be stored in the proper stack position. 4 ° For example. when a block is entered. the old pointer is saved and a pointer to the new binding is stored in the original stack position. When any of these variables are rebound in the block. It frequently happens that variables used freely within a block are in fact always bound within the block prior to the free reference. all variables which are used freely by any function in the block are looked up and pointers to the bindings are stored on the stack. but which are always bound (by somo other block function) before they are referenced. Normally. If a variable is on localfreevars. Invisible to the user. its value will not be looked up at the time of entry. since it is rebound inside of lispxblock and editblock.e. Localfreevars Localfreevars is a feature designed for those variables which are used freely by one or more of the block functions. the program will still work correctly.the list specvars.20 . i. . will not cause a trap. The reference will cause a trap which will invoke code to determine which variable was referenced and look up the value. The unnecessary lookup.

then each time the block is entered via FOOZ. F001 rebinds X. evg does two things: it returns the value of its argument. is intended primarily for use in conjunction with localfreevars.e. 18. (EVO X) in F002. i. suppose a block consists of three functions. In order to avoid this. ( EVQ X) has the effect of (EVAL (QUOTE X)) without the call to eval (if X is an atom).·and F003 using X freely. it must be included on the list retfns. F001. with FOOl and FOOZ being entries. and also stores that value in the binding slot for the variable so that no future references to that· variable (in this call) will cause traps. This will circumvent the trap by explicitly invoking the routine that searches back up the stack for the last binding of X.. If ::s is a number. evg is another compiler artifice for free variables references. w~ere Xis bound in F001.21 . However. but when entered via FOOZ. using evg in these situations can result in a considerable savings. FOOZ. a trap will occur when F003 first references X. if the function is to be returned from retfrom. e.g. the trapcount is reset to that number. Retfns Another savings in block compilation arises from omitting most of the information on the stack about internal calls between functions in the block. and F003. evq For example. and its higher value obtained.· Since the time consumed by the trap can greatly exceed the time required for a variable lookup. but not in FOOZ. the user intends X to be used freely. trapcount returns the cumulative number of traps caused by localfreevars that were not bound before use. Thus.trapcount[x] is a function to monitor the performance of block compiled code with respect to localfreevars. If~ is NIL. when used with localfreevars. If X is on localfreevars. the user can insert. if a function•s name must be visible on the stack.

BI. The block library feature simply eliminates the burden of supplying this definition. NOT ON BLKFNS. its code appears at each place where it is called. provided it has an expr definition at compiie time.of the block functions. that all functions on blkapplyfns must be in the block. If blkapply or blkapplY"' is given a function not on blkapplyfns. and blkapply* in place of apply•. whereas when a function is compiled open. out If the first argument to to ·be one of the entries to .. a call to ~ from inside a block would be the same as a call to any other function outside of the block. RO. place of apply.using blkapply in.22 . not run time. 18. and BO in the editor are handled this way. For block compiling. For example. It is just a convenience since the user ·cane always achieve the same effect by specifying the function(s) in question as one. and by. and furthermore. without the overhead of leaving the block and reentering it. the calls to the functions handling RI. the block1 reentered. Blklibrary Compiling a function open via a macro provides a way of eliminating a function call. LO. This is don. LI. Note however. that blkapplyfns must be set at comptle time. ~ the block would have turned to be blkapplyfns enables a program to compute the name of a function in the block to be called next.a by including on the list .Blkapplyfns Normally. the effect is the same as a call to !£ill or apply• and no error is generated. the same effect can be achieved by including the function in the block. blkapplyfns those functions which will be called in this fashion. or an error is generated (at compile time). A further advantage is that the code for this function will appear only once in the block. The block library feature provides a convenient way of including functions in a block.

like feature. At call time. nleft. If not. Thus. it first check to see i f the function being called is one of the block functions. length. included as part of the block.To use the block library feature. 18. nconct. obtained from. literal i. lispxwatch.e. last. we would will survive through user modification (or destruction) of basic functions (unless the user specifically requests that the system packages also be modified).!!!££. For linked function calls. This protection is achieved by linked function calls... i. when the us or or otherwise modifies the definition of the function FOO. its def in i ti on is arid it is automatically The functions . every function that subsequently calls it instead calls the modified function. 18.e. memb. the property value. retrieved from where it was st~red is defined. place the names of the functions of interest on the list blklibrary. this is clearly not a For the user may wish to break on basic functions such as print. not from the function definition cell of the called function as it is for non· linked calls. equal.10 Linked Function Calls Conventional (non-linked) function calls from a compiled function go through the function definition cell. and their EXPR definition on the property list of the function under the property BLKLIBRARYDEF. of BLKLIBRARYDEF.is obtained at link. ~. two different types of calls are illustrated in Figure 18•1. which are used by the break package. the definition of the called function is obtained from its function definition cell at call time. table of when the calling function the calling function. When the block compiler compiles a form.23 These . and /rplnode already have BLKLIBRARYDEF properties. rplaca. oval. to guarantee that the system packages In other words. For calls example. time. advises. nth. etc. and the function is on blklibrary.. breaks. from the system functions. the definition of the called function. and stored this in definition the is in the literal table.

e. i. linked function calls are possible. from standardly compiled functions.Note that while function calls from block compiled functions are u.sual ly linked. linking function calls and blockcompiling are independent features of the INTERLISP compiler. and frequently employed. and those from standardly compiled functions are u. 18.24 ...sua l ly non· linked..

LINKED CALL NON-LINKED CALL CALLING FUNCTION DEFINITION CELL DEFINITION LINKED CALL NON-LINKED CALLING FUNCTION DEFINITION CELL OLD DEFINITION NEW DEFINITION FIGURE 18-1 18.25 .

! uses two literals and hence produces slightly larger compiled functions. the call is linked.e. et al.. the call is not linked: (5) If block compiling. 18. all calls from standardly compiled functions will not be linked. (4) If nolinkfns=T. If a function is not defined at link time.. help. that (1) takes precedence over (2).26 When the function . whereas a linked function £!!. However. the call is not linked: (2) If block compiling .calls from a block compiled function (except for specify those to functions on nolinkfns) will be linked. Note (3) If the function appears on linkfns. all of their calls will be linked. Linkfns otherwise. Thus if the user does not all . if a function appears on nolinkfns.and the function is one of the block functions. it is linked instead to t~e function nolinkdef. the call is linked: (6) If linkfns=T... i.Note that normal function calls require only the called function's name in the literals of the compiled code. ~. the call to it is not linked. Nolinkfns is initialized to various system functions such as errorset. broak1. The compiler's decision as to whether to· link a particular function call is determined by the variables linkfns and nolinkfns as follows: (1) If the function appears on nolinkfns. the call will go outside of the block. when an attempt is made to link to it.e. linkfns is set to T so that even though these functions are not block compiled. the call is internal as described earlier. is initialized to NIL. even if it is one of the functions in the block. etc. when compiling system functions such as breakl. arglist. i. error. i.!.e. the call is linked: (7) Otherwise the call is not linked.

trace as . Functions which must be visible on the stack should not be linked to. Otherwise.fn. nolink. it will call faultapply and proceed as described in Section 16. e. . a list of functions. relink relinking operations.is later defined. If the function is now defined. Otherwise. i. and the rest of the pushdown list functions (Section 12) will not be able to find it. break[(FOO IN FIE)). performs the corresponding relink[WORLOJ is possible because laprd maintains on linkedfns a list of all user functions 18. and that stkpos. Note that this name does not actually appear on the stack.e. Relinking The function relink is available for relinking a compiled function. and continue the call. i. the link can be completed by relinking the calling function using relink described below.. if a function is run which attempts a linked call that was not completed.. break on fn1·IN·fn2 and advise fn1-IN·fn2 all work correctly for linked function calls.e. the name of a function. printstructure. i. include them on nolinkfns when compiling a function that would otherwise link its calls. nolinkdef is called. calls. where FOO is called from FIE via a linked function call.27 containing any linked calls. Linked function calls are printed on the back..g.. retfrom.e. it was defined at some point after the attempt was made to link to it. updating ali of its linked calls so that they use the definition extant at the time of the relink operation.def will quietly perform the link. relink[fn] fn is either WORLD. where fn is the namo of the function. or an atom whose value is a list of functions.

globalvars. since those definitions will be extant at the time it is rend and defined.compilo. compiler messages. and in a file. F003 are defined (in that orde~) Similarly. there is no 'blockcompiler' per se. FOOl will be linked to the old F002 and F003. and brecompile. and recompile.ZS . retfns. Using block declaratiohs describ~d below. the user can intormix in a single file functions compiled normally. It is important to stress that linking takes place when a function is defined. whether or not to link a function call. Thus. and for determining Note that all of the previous remarks on macros.11 The Block Compiler There are three user level functions for blockcompiling. functions compiled normally with linked calls. changing FIE is not sufficient. blkapplyfns. corresponding to compile. FOO must .syslinkedfns is a list of all system functions that have any performs linked both relink[ WORLD] calls. i. Similarly. bloc. relink[linkedfns] and relink[syslinkedfns] •. special treatment for Instead. F003 will link to the new FOOl and F002. and each call the others via linked calls. Only The user would have to perform relink[ FOOFNS) following the load..lock compiled functions. and b. The value of relink is fn. if FOO calls FIE via a linked call.e. a flag is set to enable specvars. when a new version of the file is loaded. F002 will link to the new F001 and old FOOJ. and a bug is found in FIE.be relinked. 18. bcompl. 18. All of them ultimately call the same low level functions in the compiler. etc. all apply equally for block compiling. tcompl. if FOOL F002.. when blockcompiling.

if more than one entry is specified. list[blkname) is used. e. e. However. ~BLOCKCOMPILE(EQUAL) blockcompile asks the standard compiler questions and then begins compiling. list[blkname) is used.Blockcompile blockcompile(blkname.. the block name can also be one of the blkfns. or of if entries:NIL. (COUNT COUNT!)) ~BLOCKCOMPILE(COUNT If blkfns is NIL.flg) blkfns is a list of the functions comprising the block.. 18. e. The value blockcompile is a list of the entries. e. the file is closed unless f. 41 If entries is NIL. I ~BLOCKCOMPILE(SUBPRBLOCK (SUBPAIR SUBLIS SUBPR) (SUBPAIR SUBLIS)) Each or the entries must also be on blkfns or an error is generated. blkname is the name of the block. . BLOCKCOMPILE(FOO (FOO FIE FUM) (FOO)). entries a list of entries to the block. As with compile.g. The output of a call to blo~kcompile is one 41··---------------------------------------------------------~----------------If only one entry is specified. NOT ON BLKFNs.blkfns.g.entries. the value is blkname.g. an error CAN'T BE BOTH AN ENTRY AND THE BLOCK NAME.!Jl=T.29 will be generated. i f the compiled code is being written to a file.g.

block declarationsi editblock. have implemented a special prettydef command to facilitate this commmunication. we... entries.• blockn) where each.function definition for blkname. The user includes in the third argument to prettydef a command of the form (BLOCKS block 1 .block 1 is a block declaration.blkname. The form of a block declaration is: (blkname blkfn 1 .. et. editfindblock~ 18. the value of editblocks is shown below.. bcompl and brecompile described below are sensitive to these declarations and take the appropriate action. value) expressions indicate the settings for variables affecting the compilation. block functions. (v:ar0 • value)) blkfn 1 .. blk.g. e. linking.. The (var .. block 2 •.fnm are the functions in the block and correspond to blkfns in the . al. These entry functions ·are very short functions which immediately call . Block Declarations Since block compiling a file frequently involves giving the compiler a lot of information about the nature and structure of the compilation. specvars.30 and edit4e. blkfnm (var 1 • value) .call to blockcompile. plus definitions for each of the functions on entries if any... As an example. It consists of three .

g. 42------------~------------------------------------------------~--------------The BLOCKS conunand outputs a DECLARE expression. 18. 43 Expressions of the form (var 11 form) will cause form to be evaluated and the resulting list used as described above. linkfns. bind blkapplyfns and entries to NIL.ach nonatomic element to ill of the expression if atomic. the list of block functions.g. e. globalvars.. or else to ~ of cdr of the expressions with the current ( rebo1. and entries.g. When the declaration is exhausted. T). which is noticed by bcompl and brecompile. (GLOBALVARS EOITCOMSA EDITCOMSL). the block compiler is called and given blkname.1nd) value. localfreevars. e. (GLOBALVARS * HYGLOBALVARS).£!.. to their top level value. and dontcompilefns nolinkfns. and setting .(RPAQQ EDITBLOCKS ((EDITBLOCK EDITLO EDITLl UNDOEDITL EDITCOM EDITCOMA EDITCOML EDITMAC EDITCOMS EDIT]UNDO UNDOEDITCOM UNDOEDITCOMl EDITSMASH EDITNCONC EDITlF EDIT2F EDITNTH BPNT BPNTO BPNT1 RI RO LI LO BI BO EDITDEFAULT #• EDUP EDIT* EDOR EDRPT EDLOC EDLOCL EDIT: EDITMBD EDITXTR EDITELT EDITCONT EDITSW EDITMV EDITTO EDITBELOW EOITRAN TAILP EDITSAVE EDITH (ENTRIES EDITLO ## UNDOEOITL) (SPECVARS L COM LCFLG #l #2 #3 LISPXBUFS ••COMMENT**FLG PRETTYFLG UNDOLST UNDOLST1) ( RETFNS EDITLO) (GLOBALVARS EDITCOMSA EDITCOMSL EDITOPS HISTORYCOMS EDITRACEFN) (BLKAPPLYFNS RI RO LI LO BI BO EDIT: EDITMBD EDITMV EDITXTR) (BLKLIBRARY LENGTH NTH LAST) (NOLINKFNS EOITRACEFN)) (EDITFINDBLOCK EDIT4E EOIT4El EDITQF EDIT4F EDITFPAT EDITFPATl EDIT4F1 EOIT4F2 EOIT4F3 EDITSMASH EDITFINDP EDITBF EDITBFt ESUBST (ENTRIES EDITQF EOIT4F EDITFPAT EDITFINDP EDITBF ESUBST)) (EDIT4EBLOCK EOIT4E EDIT4E1 (ENTRIES EDIT4E EDIT4E1] Whenever bcompl or b~ecompile encounter a block declaraction 42 they rebind retfns. They then scan the rest of the declaration. 43 e.!: of e. (LINKFNS . gathering up all atoms. specvars. and bind blkname to the first element of the de~laration.31 + . blklibrary.

45 or value of compile. (varn • value)) which means compile fn 1 .. with some compiler variables changed.ext. compiles all of the files at once.32 . he can use a special pseudo-block declaration of the form (NIL fn 1 .. 18. value) •. T)) appearing as a 'block declaration' will cause the six indicated functions to be compiled while linkfns=T so that all of their calls will be linked . in the file that did not and recompile. Furthermore..separately. After finishing all blocks. 45 44-------------------------------------------------------------------------·---Thus if you have several files to be bcompled .) bcompl differs from tcompl in that it.. (If atomic. (NIL CGETO FNTYP ARGLIST NARGS NCONC1 GENSYM (LINKFNS . bcornpl and brecompile treat any functions.. fnm after first setting var 1 •. as explained earlier. (exceptrfor tho$e functions on nolinkfns). fnm (var 1 . you must make several calls to bcompl. app~ar in a block declaration in the ~ame way as do tcompl If the user wishes a function compiled separately as well as in a block. instead of one at a time. or if he wishes to compile some functions (not blockcompile).Note that since all compiler variables ~re rebound for each block declarationi the declaration only has to set those variables it wants changed. in order to permit one block to contain functions in several files .44 Output is to whose name ~ if given. setting a variable in one declaration has no effect on the variable's value for another declar~tion.. list[ files] is used. varn as described above.. For example. otherwise to a file is car[files] suffixed with COM.cfile] files is a list of symbolic files. bcompl bcompl[files.

the page !II block 111 Finally. it compiles those functions not mentioned in one of the block declarations.bcompl that recompile plays for tcompl: 46~-~----------------~---~----------------------------------------------------- In fact. tcompl is defined in terms of bcompl.COM.10). Note that it is permissible to tcompl files set up for bcompl: the block declarat'toris will have no effect. If the compilation is aborted due + to an error or control·D. and then writes out all other expressions.g. bcompl asks the standard except for OUTPUT FILE:. EDIT. then processes each file exactly the 18 . bcompl[(EOIT WEOIT)] produces one file. 18. The value of bcompl is the output file (the new compiled file). The only difference is that tcompl calls bcompl with an extra argument specifying that all block declarations are to be ignored. Brecompile Brecompile plays the same role for . you can bcompl a file that does not contain any block declarations and the result will be the same as having tcompled it. simply Similarly..33 + + + . 46 same as does Bcompl next as described declarations tcompl (see processes above. compiler questions.e. all files are closed and + the (partially complete) output file + ~s deleted.

e.· of symbolic list[files] is used). the block is c. Otherwise. i. After completing 18. For pseudo-block declarations {NIL fn1 . fns] files is a list.opied from cfile as with recompile.!. tho lit entire block must be (is) recompiled.12. where file is the first file in f. output automatically goes to file.!~ brecompile process~s recompile as each file the same as does described on page processes each block declaration.. then If any of the lit functions in the block are to be recompiled. but only those functions so indicated by fns are recompiled. . it contains compiled definitions th.cfile.at may be copied. (if cfile is the compiled file bcompl(filesJ a or previous brecompile.!!. lit The interpretation of fns is the same as with recomp~le. 47 brecompile asks the standard compiler questions except for OUTPUT FILE: As with bcompl.its purpose is to allow the user to update a compiled file without requiring an entire bcompl. brecompile[ files . 18 .CON. corresponding to file~ atomic. all variable of ~ssignments the form are made.•• ).34 the block declaration$.

! is set to T. 18. ai·-----------------------------------------~---------------------------------see footnote on page 18.COM is used. (tho If the compilation is abortod + due to an error or control•D. all files are closed + and + the (partially complete) output file is deleted. producing (numerical) machine languag~ instructions.brecompile processes all functions appear in a block declaration. The value of brecompile is the output file new compiled file).12.12 · Compiler Structure The compiler has two principal passes.hitecture and instruction set for the machine that will run the compiled program. as well as being influenced by the arc. 49 The second pass expands the LAP codo.!!= NIL.48 In addition. 49 The exact form of the macro assembly language is extremely implementation dependent. and that do not recompiling those copying the compiled definitions of the remaining from cfile. The remainder of section 18 discusses LAP for the INTERLISP-10. If + ill. The first compiles its input into a macro assembly language called LAP.35 . brecompile writes onto the output filo the •other expressions• collected in the initial scan or files.!!!. dictated by fns. The output of the second pass is written on a file and/or stored in binary program space. file.£f!1! are both NIL. Finally. 18. fns and if .

Note that assemble is only a compiler directive. each resulting in one or more instructions of object code. 60 Such labels defined in 18. one may write: (IGREATERP (!QUOTIENT (LOC (ASSEMBLE NIL (MOVEI 1 . SN).36 . appear anywhere in an INTERLISP•10 function. Note that assemble may For example. However. . V is a list of variables to be bound during the first pass of the compilation. in INTERLISP·10. it is treated as a label identifying the location of the next statement that will be assemb~ed. Assemble Statements If an assemble statement is an atom. assemble allows the user to write protions of a function in LAP. ·5) (JSVS 13))) 1000) 4) to test if job runtime exceeds 4 seconds. Therefore. the value of the assemble 'form' is the contents of ACt at the end of the execution of the assemble instructions. The format of asse~ble not during the running of the object code. In other words. functions which use assemble must be compiled in order to run. When run. machine language coding can be included within a function by the use of one or more assemble forms.13 Assemble is similar to that of PROG: (ASSEMBLE V s 1 s2 . it has no independent definition. 18. The assemble statements s1 ••• SN are compiled sequentially. .Input to the compiler is usually a standard INTERLISP S·expression function definition.

!: of an assemble statement is a number. The types of assemble statements are described here in the order of priority used in the assemble processor.e.g.9.42. and LAP macros.2fl labels in that they may be referenced from tho current and lower level nested . if an atom has both properties OPD and AMAC.!:.e. .g. the property value) is a number. (3) an assembler macro (i.41. the op-def is a machine instruction. e. etc. appears as £!!: of an assemble statement. Anything else will cause the error message OPCODE? .£2. (1) numbers . If the OPD definition (i. (2) LAP op-defs - (See page 18.£!!.) The property OPD is used for two different types of op-defs: PDP-10 machine instructions. When a machine instruction. If the OPD definition is not a number. redefined via an AMAC. that is. When a LAP macro is encountered in an assemble statement. the OPD will be used. has a property value AMAC): or (4) one of the special assemble instructions given below.Q.If·. e.!2!. HRRZ. CQ... then the op-def is a LAP macro.ASSEMBLE.an assemble form are like . first pass The second pass processing is described in the section on LAP. the statement is not processed in the first pass. Similarly a special assemble instruction may bo The following descriptions are of the processing of assemble statements. its arguments are evaluated and processing of the statement with 18.! or assembles. The forms and processing of machine instructions by LAP are described on page 18. has a property value OPD). If an assemble statement is not an atom. page 18.37 . C.2.!: of the statement must be an atom and one of the following: (1) a number: (2) ·a LAP op-def (i.41.e. the statement is not processed during the first pass but is passed to LAP.

it must be a list of dummy symbols.evaluated arguments is left for the second pass and LAP. and (LDV (QUOTE X) SP) in code results in (LDV X N) in the LAP code. The form and processing of LAP macros . and the resulting list of statements will 18.!: of the macro definition is riot the atom LAMBDA. repeat could be a LAMBDA·macr6 with two argumentsi !!. The definition (i. where N h ~or a~semble the value of SP. (REPEAT 3 (CARl)) expands to ((CAR1) (CARl) (CAR1)). example. There are two types of If car of the macro· definition is the atom LAMBDA. (RETURN (CAR YY))) (T (SETQ YV (TCONC YV M)) (SETQ N (SUBl N)) (GO A))))) If£!!.g. (3) assemble macros - If m of an assemble statement has a property AMAC. The arguments of the macro call will be substituted for corresponding appearances of the dummy symbols in cdr of the definition. assemble macros: lambda and substitution. the definition will' be applied to the arguments of the call arid the resulting list of stat·ements will be assembled.. For example. the statement is an assemble macro call.38 .e. value of property AMAC) for repeat is: (LAMBDA (N M) ( PROG ( YY) A (COND ((ILESSP N 1) . and !!!• which expands into !!. are described on page 18. LDV is a LAP macro.45. occurrences of· !!!•e.

e. then compiled in the usual 6i---------------------------------------------------------------------------~Note that assemble macros produce a list of statements to be assembled. 61 For example. E.39 .g. 1)) (4) special assemble statements CQ (compile quote) takes any number of arguments which are assumed to be regular S·expressions and are compiled in the normal way. An assemble macro which compute. is always no-spread) and the LAMBDA is understood. (CQ (COND ((NULL Y) (SETQ Y 1))) (SETQ X (IPLUS V Z))) Note: to avoid confusion. and expands into instructions to compile the unboxed value of this number and put the result on the number stack.g. (CQ X) is preferred to (LDV (QUOTE X) SP). it is best to have as much of a function as possible compiled in the normal way. ubox could be a substitution macro which takes one argument. to load the value of. whereas compiler macros produce a single expression. (Cs 1 s 2 ••• ) C Csompile) takes any number of arguments which a.e. a number. 18. 1)) Thus (UBOX (ADO! X)) expands to: ((CQ (VAG (AD01 X))) (PUSH NP . The definition of UBOX is: ((E) ( CQ (VAG E)) (PUSH NP .be assembled. The analogous compiler macro begins with an atom.~ to ACl.s a list of statements begins with LAMBDA and· may be either spread or no-spread. (i.re first evaluated.

(FASTCALL fn) Compiles code to call fn. boxing and unboxing routines. (II< . and not on Currently.y] will be in AC1. (PSTEP) calls a function· which increments the compiler variable SP. 52 Example: (CO X) (LDV2 (QUOTE Y) SP 2) {FASTCALL CONS) and cons[x. the statement is ignored. and the number of arguments in AC1.!: to the contents of AC1. SUBR's that expects its accumulators. (SETQ var) Compiles code to set the variable Y2.. For example. • ) * is used to indicate a comment.40 . COREVALS There are several locations in the basic machine code of INTERLISP-10 which may 52··-----------------C·-----------------------------------Q~D$ ________________ _ list may also be called with fastcall by placing its arguments on the pushdown stack. Both C and CQ permit the inclusion of regular compilation within an assemble form. these are Fn must be one of the arguments the ~· push-down and the in the stack.way. 18. E (!valuate) takes any number of arguments which are evaluated in sequence.

COREV~L is written. 18. compiled These are not expected to change. 63 Since these locations may change in different reassemblies of INTERLISP-10. i. The current value of each location is stored on the property list under the property COREVAL.be referenced from compiled code.14 files. the name of the corresponding not its value. and are not stored symbolically on code assemble code. however. 35-------------------------------------------------------~--------------------- The value of corevals is a list of all atoms with COREVAL properties. they are written symbolically on compiled code files. 18. Some of the COREVALs used frequently in assemble are: CONS entry to function CONS LIST entry to function LIST KT contains (pointer to) atom T KNIL contains (pointer to) atom NIL MKN routine to box an integer MKFN routine to box floating number IUNBOX routine to unbox an integer FUNBOX routine to unbox floating number The index registers used for the push-down stack pointers are also included as COREVALS. they should be referenced symbolically in They are: PP parameter stack CP control stack NP number stack LAP LAP (for 1ISP _!Ssembly frocessor) expands the output of the ·first pass of compilation to produce numerical machine instructions.41 .e.

· (2) Machine Instructions .!: of a LAP. .42 . A ( 1)) e. If a LAP statement is not ari: atom. .9). that is. 66 The TENEX JSYS's are not defined.g. the following: (1) a number. .statement is a 'number. one must write (JSVS 107).If£!.. identifying the location of the next statement to be processed. · (ADD 1 . some UUO's also·use the AC field of the instruction. or (3) a LAP macro.e for the property OPD. it is· treated as a label. since.' The general form of a machine instruction is: (opcode ac • @ address (indeK)) Opcode is any PDP•10 instruction mnemonic or INTERLISP UUo.!: of a LAP statement has a numeric valu. (rather than. 55 54----------------------------------------------------------------------------The value is an 18 bit quantity. instead ~f (KFORK)~ 18. £fil: of it must be an atom and one· of.LAP Statements If a LAP statement is an atom. a location containing the number is produced in· the· objec·t code. (1) numbers . A· (1) ( 4) ( 9 )' Statements of this type are processed like machine instructions. (2) :a machine instruction.If £!.. with the initial number serving as a 36-bit op-code. 64 the statement is a machine instruction.

1 pointer The address is a refe~ence e. it Ac is either a number or an atom The low order 4 bits of the number or COREVAL are OR'd to the AC field of the instruction .g. However.g. . = TABLE) labeled is then the location) e.43 of this IS NOT DEFINED") location. with a COREVAL property. number. (CAME 1 . a list.g. Address is the address field which may be any of the following: = constant Reference to an unboxed constant. = 3596). is optional. location A containing the unboxed constant will be created in a region at the end of the function. A location containing the pointer is assembled at the end of the function. have the ( HRRZ 1 • and the current instruction wi 11 address I II 18. any other atom which is treated as a label (the constant is address of the (MOVE 1 . .Ac. address field of the current The constant may be a number o. (HRRZ 1 . if present. g. E. etc. an atom with a property COREVAL (in which case the constant is the value of tho property. the accumulator field.g. and the address of the location containing the constant is placed in the instruction. to.a INTERLISP pointer. TABLE): or an expression whose value is a number. equivalent to (MOVEI 1 . @ ' V). string.! may be used anywhere in the instruction to specify indirect addressing (bit 13 set in the instruction) e. at LOAD time). must be followed by a comma..

is the Otherwise the atom is a label referencing a location in the LAP code. i. number (MOVSI 1 .g. 1 ( 1)) list The form is evaluated. (JRST A 2).44 COREVAL. (SKIPA 1 .g. a system and the value of the coreval. KNILL) .( HRRZ 1 .g.g. e.LAPERROR. The number is the address: e. and its value is the address. The index with (£!£ a of the list) must be either a number. Anything else in the address field causes an error message. KNIL).e. 400000Q) ( HLRZ Z . ( JRST A). A number may follow the address field and will be added to it. or an atom property 18. Index is denoted by a list following the address field. ' (NOT FOUND)) Specifies the current location * function: e. e. e. e . g. (JRST * in the compiled 2) has the same effect as (SKIPA). it is location. literal atom If the atom has reference to (SKIPA 1 . tho address field must be present if an index field is to be used. . address used a e.g. a property COREVAL.g.

the macro· definition is applied to the arguments of the call.llting list of statements is again processed. LAP macro calls comprise most of the output of the first pass of the compiler. 18.45 . 66 LAP statement is the name of a LAP macro.37. and like assembler macros. property OPO. may be either lambda or substitution macros. (3) LAP macros has If £!!!'. In the first case. of a the 0 1 (NP)). In both cases. of these macros are stored on The definitions the property list under the property OPD.(HRRZ 1 • 0 (1)) or (ANDM 1 . and may also be used in assemble. Some examples of LAP macros are shown in Figure 18-2. see page 18. the resl. + + 57 The arguments were already evaluated in the first pass. with macro expansion continuing till the level of machine instructions is reached. the arguments of the call are substituted for occurrences of the dununy symbols in the definition. the statement is a macro call. (LQ2 FIE 3). 67 in the second case.g. i.e. The arguments of the call follow the macro name: e.

(DEFLIST(QUOTE( (SVN (( N P) (MOVE 1 • I N) (HRLM 1 .: (• LOAD QUOTE TO AC) •. __ r.-.·::1'. 0 (AC)))) (RPQ ((V) (HRRM 1 . (VREF A SP)))) (STV ((A SP) (HRRM 1 .•· LOAD QUOTE TO ACl) (* . . . @ • v> >> ( CAR2 ((AC) (HRRZ AC.46 . 1))) (PUSHQ ((X) (PUSH PP I x) )) )) (QUOTE OPD)) STORE VARIABLE NAME) (* (• STORE VARIABLE NAME AND VALUE) . (*LOAD LOCAL VARIABLE TO AC1) (*SET LOCAL VARIABLE FROM ACl) (• LOAD LOCAL VARIABLE TO AC) . P (PP)))) (SVB ((N) ( HRL 1 ' I N) (PUSH PP l))) ( LQ (( X) (HRRZ 1 ' I X)))· ( LQ2 (( X AC) ( HRRZ AC I X))) ( LOV ((A SP) (HRRZ 1 .) (PUSHP (NIL (PUSH PP . (FREF A SP)))) (STF ((A SP) (HRRM 1 (FREF A SP)))) (LDF2 ((A SP) (HRRZ Z ·(FREF A SP)))) (CARl (NIL (HRRZ 1 0 (1)))) ( CDRl (NIL (HLRZ 1 0 (1)))) (CARO (( V) (HRRZ 1 @ I V))) ( CARQ2 (( V AC) cHRRZ Ac .·. (MKLCL NAM)))) (STE ((TY) . -. (PSTEl TY))) (STN ((TY) (PSTNl TY))) (RET (NIL (POPJ CP . @ 1 V) (CLL ((NAM N) (CCALL N • I NAM))) (LCLL ((NAM N) (LNCALL N . . LOAD FREE VARIABLE TO AC) (* iO (•CAR OF AC1 ACl) CDR OF ACl:\ TO AC1) (* . (VREF A SP))')) (LDV2 ((A SP AC) (HRRZ AC . :foigure 18·2 Examples of LAP Macros 18. (•_CAR QUOTE) (* CAR QUOTE TO AC) (* CAR OF AC T~ AC) ")' (* RPLACA QUOTE) (* CALL FN WITH N ARGS GIVEN) (Ill LINKED CALL WITH N ARGS) (* SKIP IF TYPE EQUAL) (* SKIP IF TYPE NOT EQUAL) (* RETURN FROM FN) (* PUSH QUOTE) . LOAD FREE VARIABLE TO ACl) (* (• SET FREE VARIABLE FROM ACl) ' 1.:. (VREF A SP)))) (LDF ((A SP) (HRRZ 1 ..~.

NP. so that it knows where to find the arguments and free variable pointers. the parameter pushdown list contains. and PSTEPN(N) adds N to SP (N can be positive or negative).18. To store unboxed numbers. the parameter All variable bindings and temporary values are stored on pushdown stack. in ascending order of address: 1. anything in the left half of a word on the stack is assumed to be a variable name (see Section 12). it is helpful to know the following things about how compiled code is run. Temporary values.47 . 2. The parameter stack.15 Using Assemble In order to use assemble. points to the last free variable pointer on the stack. use the number stack. where each binding occupies one word on the stack· with the variable name in the left half and tho value in the right half. When a compiled function is entered. index register PP. about PROG and LAMBDA bindings. pointers. should only be used for storing pointers. ·The parameter push-down list pointer. and the arguments to functions to be called. The function PSTEP adds 1 to SP. are pushed on the stack following the free variable The compiler uses the value of the variable SP to keep track of the number of stack positions in use beyond the last free variable pointer. bindings of arguments to the function. In addition. pointers to the most recent bindings of free variables used in tho function. Numbers may be PUSH'ed and POP'ed on the number stack. 18.

s. and is equivalent to: (PUSHP) (E (PSTEP)) (CLL (QUOTE FOO) (PSTEPN •1)) 1) (E In using s. For example: (CQ (IPLUS (LOC (AC)) 2)) There are several ways to reference the values of variables in assemble code..18.48 . to box and unbox a number: ( CQ ( LOC (AC ) )) (FASTCALL MKN) (FASTCALL MKFN) ( CQ (VAG X)) (FASTCALL IUNBOX) (FASTCALL FUNBOX) box contents of ACl box contents of ACt floating box contents of AC1 unboxed value of X to AC1 unbox contents of AC1 floating unbox of AC1 18. be sure that it appears as the first argument to be evaluated in the expression.AC 1.16 Miscellaneous The value of a function is always returned in AC1.f.) (LIST (VARCOMP (QUOTE X)) (QUOTE X) SP)))) . Therefore. fc:w example (CO (FOO (AC))) compiles a call to FOO with the current contents of ACl as argument.f • is available for obtaining the current content~ the pseud9of . function. For example: to put value of X in AC1: (CQ X) to put value of X in ACJ: (LOVZ (QUOTE X) SP 3) to set X to contents of AC1: (SETQ X) to set X to contents of AC2: (E (STORIN (LIST (QUOTE HRRM) 2 (QUOTE .

g. and SP must be updated. recompile. whether from tcompl. and then the function called: e.To c01J. see page 18.g. compiler messages will be printed for these functions botwoon the first message and the second message for fn. (E (PSTEP)) (CLL (QUOTE FUM) 2) ( E ( PST EPr~ . tho compiler prints: ( fn COMPILING) (fn (arg 1 ..49 .14).6. or compile. a function directly.g. words from a comment. e..18)... The second message is printed at the beginning of the second pass of the compilation of fn. If the compilation of fn causes the generation of one or more gensYffi functions (see page 18. freen) tho list of free variables referenced or set in fn. in (free 1 .. argn) (free 1 The first message is printed when the compilation of fn begins. 18.. etc. function names.2 )) ca stack first argument) (a stack second argument) call FUM with 2 arguments) (a adjust stack count) (a and is equivalent to: (CQ (FUM (CAR X) 3. the arguments must be pushed on the parameter stack. 68----------------------------------------------------------------------------Does not include global variables.14)) 18.17 Printout and Error Messages Co~piler For each function compiled. (arg 1 argn) is the list of arguments to fn. e. 58 Thie appearance of nonvariables. and (free 1 . freen) is a good indication of parenthesis errors. (CQ (CAR X)) (PUSHP) (E (PSTEP)) (PUSHQ 3.

(fn . he should use apply*. form is compiled as if apply* had been used. both recompile and brecompile print tho namo of each function that is being copied from the old compiled file to the new compiled file. 69 Then both messages are printed for each entry to the block.e. (fn compiling) is printed for each Junction in tho block. . ((form) . Compiler Error Messages Messages describing errors in the function being compiled are also printed on the teletype. Then a second pa~s message is printed for the entire block. See Section 8. In addition to the above output. These messages are always preceded by •**** Unless otherwise indicated below. i. (FOOBLOCK (FOOBLOCK#O FOOBLOCK. the compilation will continue. If the us or a§---------------------~-------------------------~----------------------------- The names of the arguments to the block are generated by suffixing a number to the block name.2!::m as a function.g.(FOO COMPILING) (FOOA0027 COMPILING) (FOOA0027 NIL (X)) (FOO (X) NIL) The cor:ipiler output for block compilation is similar to normal compilation.NO LONGER INTERPRETED AS FUNCTIONAL ARGUMENT) The compiler has assumed fn is the name of a function. The normal compiler messages are printed for each function that is actually compiled.50 ·~· and e. 18. The pass one message.NON ATOMIC CAR OF FORM) If user intended to treat the value of f.#1) free-variables).

.·.~ -:.9 is a label that was encountered twice during the second pass of the compilation.UNDEFINED TAG) !. and continues the compilation. The second definition is ignored.9 is a label that is referenced but not defined in an ASSEMBLE form. (tg . --- 18. If this error occurs with no indication of a multiply defined tag during pass one.a-. and compiled code to evaluate it.MULTIPLY DEFINED TAG) !2 is a PROG label that is defined· more than once in a single PROG. (tg .-.9 is a label that is referenced during the second pass of compilation and is not defined.MULTIPLY DEFINED TAG. LAP) !..~~~.~. ASSEMBLE) !... Note that earlier versions of tho INTERLISP compiler did treat fn as a functional argument.UNDEFINED TAG.n·d.51 . the tag is in a LAP macro.~~ .~~.9 is a PROG label that is referenced but not defined in a PROG.-~~ ~~ --~e-. (tg .~~.~.~.e· -~~--. he must use ~£~· See Section 8.. LAP} !. 60 (tg ....._w_h_e_n·-~~. ASSEMBLE) !£ is a label that is defined more than once in an assemble form. LAP treats 19 as though it were a corevnl.. 6o.-i~~~ i variable of the function being compiled.UNDEFINED TAG.. (tg . (tg .-.d.intended to treat the value of fn as a function.MULTIPLY DEFINED TAG.

OPCODE? . is used as «n argument to a function that expects numbers. See P«go 18. and the compiler proceeds to the next function to be compiled.USED AS ARG TO NUMBER F~?) The value of a predicate.ILLEGAL GO) S.2. but there are no blkapplyfns or entries declared for th• block. such as GREATERP or EQ. . fn NOT COMPILEABLE.E appears as i l l of an assemble statement. (x - rs GLOBAL) ~ is a global variable. and is illegal.52 . (fn . 18'.36-40 for legal assemble statements. and is also rebound in the function being compiled.USED BLKAPPLY WHEN NOT APPLICABLE) blkapply is used in the block blkname. (blkname . either as an argument or as a local variable. The error message is to alert the user to the fact that other functions will not see this binding.Q. no codo is produced for fn. In this case.Q encountered when not in a fil:.ASSEMBLE) .(fn .ILLEGAL RETURN) return encountered when not in ~· (tg . (op .:ance ! ·iS always accessed directly through· its value cell. if ~ny.9· (fn NOT COMPILEABLE) An expr definition for fn could not be found. such as IPLUS.

fn NOT FOU!W. but did not appear on the blkfns. 18.Same as above compilation.53 . Occurs when recompile definition of fn from or brecompile cfil~. fn was specified as an entry to a block. or else was on blkapplyfns. fn CAN'T BE BOTH AN ENTRY AND THE BLOCK NAME. Generates an error. Generates an error. (fn NOT IN FILE . except generates an error.53. thereby aborting all For example. the compiled See page_ 18.USING DEFINITION IN CORE) on calls to bcompl and brecompile. fn NOT ON BLKFNS. try to copy and cannot find it. this error condition occurs if fn is one of the functions in a block. Generates an error.

..22. ~ .43•44 18. • APPLY[ FN...~·. ..Z9·30..•••••• computed macros ~ . .. . ..• AMAC (property name)..23..30~32~35 BUILOMAPFLG (system variable/parameter) ••./ .. • .. • • • • .ARG1..•.••••.. 36..•...••••••••• comp·iler questions .••••• 18.....••... ~·:· . • •••••••••. library ·.•...16 18....••. .. .• ~ /. ••••••..••••••••••••....••...·........•. COt'1PILEO or~ .. 18.... compiler structure . 15.....••.3Z•35 18. .•. 22 18.•....••••••• DECLARE •... .....a .28..NL• •....... 18... Page· Numbers ('....•.DEFJ .. ALAMS (compiler variable/parameter) •••••••••. • ... • • • • • • • • • • BCOMPL[FILES:CFILE.CFILE.. 18.••••.... .. • • ..••...ARGS J SUBR .•••••••\ ~-~ •• ..3·5 18. ..•. compiler error messages .•• COMPILE.••....·'~...18.FLG....~.••••••• BLKLIBRARY. ••••••••••••••••••••• COREVALS (syst~m variable/parameter) •.7 18.••••••.......3 18 ..41 18.•••••.....40·41 18...• ~.........10 18.30•31 BRECOMPILE[F!LES.FNS.39 18...1·53 18..••••••• compiler macros compiler printout ...••..•• 18.9 18...ARGn) SUBRft ••••.....• BLKAPPLY*[FN....••••.36.•••.••••••••••. ..•••••.22 1... 18...•.23 .......•... •• .... .••••..••....NOBLOCKSFLGJ ...31 18. block. ..8 ... • • • . APPLV 11 [FN.....50·53 COMPILEHEADER (compiler variable/parameter) .12 C (in an assemble statement) . .••••....••••.•.. u compiled file ..• ~ •··•.38 ..••••••. COM (as suffix to file name) ..• compiling NLAMBDAs ....•..30·32 · 1a·. • . .... • . declarations • • • • • • • • • . .11 ... 18... ~ •• ·••••.. ..-8.......... .6 18.. • ... ... • • • • • ..40.•...••.••...•.. coi:npi·ling files .••......•••.28..29.... BLKLIBRARYDEF (property name·) ·..35 18...•••.31 18......37•38 18 ......••.....••••.. .. • .41.5-6 18.: .:. (compiler variable/parameter) • • .•••••.19·35 18 ..9 compiler 18.•••••••••• DECLARE: [ x] .'40..••••••••• AC (in an assemble statement) ••••••••••.. .•••••• CQ (in an assemble statement) •••••••.. ··18....•••.••.. . .7·14.•..33 COMPILE[X:FLGJ · •••••••••••••••..•••••••• AC1 ... • • • • • • • ..• COMPILEl[FN.•••..••.... •• ~ •..•••••••••••••••••• ASSEMBLE .•..".••..ARGn] SUBR~ .. •••....• ASSEMBLE statements .......••••.FLG] •••••. 18~i8~35 · 18 ...••••.. •. • • • .6..•.• COMPSET[FILE.. ..-...• 18.......47·49 18..48 18..6...... ARGS J SUSR ••..••.•...••••••. ~>........••••..•... .•• BLKAPPL Y[ FN ...· ..•...9 18. ... ~ :•... •..• 18...Index. ~ ......... ••••••••••••••••••••••• 0 EC LARE : •••••••••••• -: ..•• block compiler •.•••. .. ........46·4·1..• ·••• ...•• •••••••••••••••••• .11. .28..•...32 18 .....•.. .' •..for Se~iion 18 ......EXT (compiler variable/parameter) •••••...........••... • • • ... ~ . .. .•..16..• ....·t 18..22 BLOCKCOMPILE[BLKNAME..18 1B ..9. • • • • • • • • block...•• ~.. 7.31 18 .39 CAN'T BE BOTH AN ENTRY AND THE BLOCK NAME (compiler error message) ••••••.22 · 18.... •·:·· ASSEMBLE macros . .•......FILES] ••••.......• ~'...43 18.22 18.•.....···!•• .NOBLOCKSFLG] •.48 18..16·17 18...••••.. ..•....49•50 18. AC (in a lap statement) •••••••••••••••....... compiling FUNCTION .• · COMPILEUSERFN (compiler variable/parameter) ••. ••••••••......".....•.8 18...·-~·.•••• .........••... _ 18. . ......•••••••••••• control-D ..• compiler functions ....•• ·. COREVAL (property name) COREVALS •••.....••••••••..32·34 18...ARG1.... ...• .••••. 18.30. .. • • • • • • BLKAPPLYFNS (compiler variable/parameter) .••••••••••••••••••••••••••••••• INDEX.9·...•. • .•••• block compiling . .••..••. .•.•• ·• •••••• .•••••.53 CLISP •··············••••••o•••••••••••••·····•···•••'·•· · 1a •..••.•....... • ... • • ...28•30 BLOCKS (prettydef command) ....••...••. • • • .BLKFNS:ENTRIES.8.15 18. ..••••••••••.•...

....... ENTRIES (compiler variable/parameter) •......•..31 18....•..............9 LOAOFROM[FILE....18 FUIJCTIOll[ EXP..51 (MULTIPLY DEFINED TAG.. FAULTAPPLY[FAULTFN...14 LOCALFREEVARS (compiler variable/parameter) 18...Page Numbers DOEVAL@COMPILE (DECLARE: option) .•....•.........••• 18......51 (MULTIPLY DEFINED TAG....•...............................5........••..3 raachine instructions .•..• 18..... 18... 18 . .........•...OPTIONS:REPRINTFNS.23 18..............•......................... 18 . 18.........•.37 LAP statements ............•.•.......•.6 GLOBALVARS (compiler variable/parameter) ......•...•.............29 18 ...•••••••..10...... 11 18...•................18 18.....•..••......• FUt·JARG . 18.......SOURCEFILE] 18..•..•.•.•.... 18.52 LAMS (compiler variable/parameter) .........2.35.........•........ . 18.. LAP) (compiler error message) ..•. .•..........••• 18... 18.... .•... .• 18.... 18.•...........•.23 functional arguments ..••....... VLIS T) NL ....•.•• 18..13.2-3 LOAD[FILE..•.....•......LDFLG.16-17 MAKEFILE[FILE. .3........•. 18....... FILE: (compiler question) ...31 (ILLEGAL GO) (compiler error message) .......••. F (response to cor.......45 LAP op-defs .....•......40 18... 18..15-16 nacros (in compiler) .......• I ••••••• I ••••••••••••••••• 18. 11 18.....52 INSTRUCTIONS (in compiler) ..37.....52 (ILLEGAL RETURN) (compiler error message) ....32 NLAMA (compiler variable/parameter) .....••. 18.1.. ................................ 18...................3 LAPRD[ Ft·J] ...........7............... ....•.•..•.6..••.4 18..3 18 .......••••. DOflTCOM PI LEF fJS (compiler variable /parameter) DONTCOPY (DECLARE: option) ...•• 18......... ..........•••................ 18....... 18.....10 LAP .... ASSEMBLE) (compiler error message) ......51 tJIL (use in block declarations) ....................•......5 linked function calls ....••.•......• 18. FASTCALL (in an assemble statement) .. EVAL@COMPILE (DECLARE: option) ..31 LSTFIL (compiler variable/parameter) ..20-21............18...17 (IS GLOBAL) (compiler error message) .... 18..FNS.........••.............•••............ 11 18.....7 GLOBALVAR (property name) .19.... 18 ...18 INDEX...5 NLAML (compiler variable/parameter) •••.................•.....•• FILECREATED[X) NL"' . ERSETO[ ERSE TX] NL ........•...... .•• 18.14 (MULTIPLY DEFINED TAG) (compile~ error message) 18..42-45 LAPFLG (compiler va~iable/parameter) ...18 function definition cell .• 18..... ....... .....PRINTFLG] .....lDFLG] .....41-45 MACRO (property name) ................3.. EXPR (property name) .....................•.. DWIMIFYCOMPFLG (compiler variable/parameter) E (in an assemble statement) ..................••..18 global variables .8 18........•..... EVO[ X] .... .....27 LCFIL (compiler variable/parameter) ..........23-28 LINKEDFNS (system variable/parameter) ........... 18.....•.•..26... 18 . ...•....• 18..•......31-32 LISTING? (compiler question) .27 18.......••......•.21 18......•• 18.....•.....40 18.. ...8 18.•... 18.....18 GEfJSYM[ CHAR] ..lpiler question) . ..•.•........27 LINKFNS (compiler variable/parameter) ......41-45 LAP_ macros ......••• 18......5 ULSETO[ NLSETX] NL .. entries (to a block) .... . 18 .........FAULTARGS] ....31 18.Z ......... 18.............. 18......

..••..•....•... RECOMPILE[PFILE..•...•... ' (in a lap statement) ....•.••................•.•..11-14. parameter pushdown list .............17 18.50 18.•.• PSTEPIJ (in an assemble statement) .....47 18..••••.51 18....Page Numbers (NO LONGER INTERPRETED AS FUNCTIONAL ARGUMENT) (compiler error message) .•.............••..•• WORLD (as argument to RELINK) ... RESETVAR[RESETX.....•...•...••••.. SPECVARS (compiler variable/parameter) ...••..40........2..•...... 53 18 .... ..• second pass (of the cornpiler) ......•.•....20..................27-28 18......•...•......47 18......40 18..•....•........ ASSEMBLE) (compiler error message) (UIJOEFirJED TAG.•.•.......3-4.... (OPCODE? .•••••••••••••••••••• UllBROKEIJ (typed by cornpi ler) ..52 18......•.•....•.37. relinking .• IJOLHIKFrJS (cornpiler variable/parameter) ......FNS] ..•.. IJOT FOUIJD (compiler error message) .....35 18.......•. ......42 18. (NOT COMPILEABLE) (compiler error message) . SETO (in an assemble statement) .. . (NOT IN FILE .27 18 ...CFILE......26-27..11..21 18.... NOT COMPILEABLE (compiler error message) ..........ASSEMBLE) (compiler error message) OPD (property name) ..52 18........ TCOMPL[FILES] ..... open macros ....52 18..52 18......••.... ( IJOIJ ATOMIC CAR OF FORM) (compiler error message)............... · · · · · • · "' (in a lap statement) .... .4 18..........•..... S (response to cornpiler question) .. ..•.............50 .....5 18..3 18.•......... STRF (coDpiler variable/parameter) •...•........31 18.•.........•.....42......•......•..51 18..... (UNDEFINED TAG....... SP (in an assemble statement) ......28..•...53 18....•...32-33 18.4 18.....•.. ...............•..•..•.............•.....7-11.. OPCODE (in a lap statement) ....... NOT FOUND (error message) ....... .22...............53 18..4 18.....•....••........• "':iroa::in·1 ( in comp i 1er error messages) .8 18 ..RESETY......... NP (in an assemble statement) ..... REDEFINE? (compiler question) ..••.28.... STF (response to compiler question) ............47 18.31-32 18. OUTPUT FILE: (compiler question) ....2........7-8...RESETZ] NL .8. ...47 18...32 18. NOT ON BLKFNS (compiler error message) ..........•........29.........•..•.. "' (in an assemble statement) ....... SAVE EXPRS? (compiler question) .......7 18..3-4 18.................. number stack ...........43 18......•.. flOL IIJKDEF .• substitution macros .•....•.44 18......21.....•.....................•.... RETFNS (compiler variable/parameter) ..UIJLINKFLG] ...... PP[X] NL* ..47 18 .28 18.....•..47 18......... ...... SVFLG (compiler variable/parameter) .......... SYSLirJKEDFllS (system variable/parameter) ...USING DEFINITION IN CORE) (compiler error message) .••• (USED BLKAPPLY WHEN NOT APPLICABLE) (compiler error message) .4 18.• ( UIJDEF mm TAG) (compiler error message) .16 18....•...•...•.....50 18....14-15 18 ....• open functions ..31 18 .•....52 18.18.....•... .13 18....37....................••....••..•.45 18....•••• INDEX......26-27 18..51 18.27-28 18. TRAPCOUIJT[ X] SUBR ••.. LAP) (comptler error message) (USED AS ARG TO NUMBER FN?) (conpiler error message) . ..... RELIIJK[FIJ.4 18........ ST (response to compiler question) ...••••••••••••••••••••• PSTEP (in an assemble statement) ..40 18.....••..7 18..47 18....................

4 .Page )\lumbars = (in a lap statement) @ (in a lap statement) ••011•••11••••1t•C1••········· lNDEX.18.

.

i. advising Similarly. 1------------------------------~----------------------------------------------Advising was developed and implemented by W.e. Teitelman." and to modify them without concern for their contents or details of operations. This latter feature is especially useful for changing the internal workings of a system function.. as in editing.(SETQ SYSOATE (DATE))) As with break. For example.SECTION 19 1 ADVISING The operation of advising gives the user a way of modifying a function without necessarily knowing how the function works or even what it does. Advising consists of modifying the interface between functions as opposed to modifying the function definition itself. his or someone else's. the user could modify sys~ut to set sysdate ta the time and date of creation by advise[SVSOUT. aside from its convenience. works equally well on compiled and interpreted it is possible to effect a modification which only operates when a function is called from some other specified function. ~. as "black boxes. are examples of the use of this technique: they each modify user functions by placing relevant computations between the function and the rest of the programming environment. The principal advantage of advising. 19 . instead of the interface function and the rest of the world. and broakdo\oJn. break. to modify the between interfac~ one . between two particular functions. is that it allows the user to treat functions. functions.1 .

for complete discussion of sysout/sysin. or spaces directly wolild have affected all ~alls these t. print.2 See Section 14 . The value variable of the body of the original function !value. Advice can also be specified to operate after a function has beeh evaluated. He could then: ADVISE(SYSOUT AFTER (COND ((LISTP !VALUE) ·-))) 2 19.o very frequently used function. can be obtained from tho For example. whereas advising (( PRIIH PRINT SPACES) IN TIME) affects just those calls to pr in 1.g. not sysin. suppose the user wanted time (Section 21) to print the results of his measurements to the file FOO ·instead of the teletype. and spaces from time. check whether his files were up to date.For example. as with breakl. the system will be as it was when the ~ysout Wils performed. 19.1 Implementation of Advising The structure of a function after it has been modified several times by advise is given in the following diagram: 2-----------------------------------------------------------------------------After the sysin. hehce the advice mlist be to sysout. He could accomplish this by ADVISE(((PRINl PRINT SPACES) IN TIME) BEFORE (SETQQ U FOO)) Note that advising prinl. print. e. ·suppose· tho user wanted to perform some computation following each sys in.

ADVICE BEFORE MODIFIED FUNCTION ADVICEN ENTER ORIGINAL FUNCTION EXIT ADVICE 1 ADVICE AFTER FIGURE 19-1 19.3 .

body is the body of the definition. For example. 19. but the rest of the advice AFTER the function would still be executed. (called ADV-PROG. 3------------------~-------------------------------------------~--------------Actually. if any. if (COND ((ATOM X) (RElURN Y))) were one of the pieces of' advice BEFORE a function. piece of advice appeared AFTER the function. . and RETURN.n RETURN. SETQ. X would be returned as the value of the inner ·PROG. 3 4 Note that the structure of a function mo·dified by advise . allows a· piece of advice to bypass the original definition by using the functio. and this function ·was entered with 2:: atomic. functions. The advice (COND ((ATOM X) (_SETQ !VALUE Y))) AFTER the function would have a similar effect. otherwise a form using a gensym which is defined with the original definition .The corresponding INTERLISP definition is: (LAMBDA arguments (PROG (!VALUE) (SETQ !VALUE (PROG NIL advicel ADVICE BEFORE advicen (RETURN body))) advice! ADVICE AFTER advicem (RETURN !VALUE))) where body is equivalent to the original definition. ~ If this samo would be returned as the value of the entire advised function.. ADV·SETQ. !value would be set to ~· and control passed to the advice. to be executed AFTER the function.4 . advise uses its own versions of PROG. 4 and ADV-RETURN) in order to enable advising tho so I f fn was originally an EXPR.

or (AFTER 3) meaning after the third piece of advice.when.what]. function to be modified by advising.. where.! is changed to fn1-IN-fn2 throughout fn2. advice. e. BEFORE is used.what]. and what is the piece of advice. when. or even (: TTY:). constructs END. appropriate edit command and calls the editor Otherwise. arguments in the sense that they can be In other words. omitted in the call to advise. where specifies where in tho advice list the advice is to be inserted. LAST is used.5 . advise(fn. when=BEFORE.19.!!. or TOP. function of two ( fn . If where is specified.what] fn is AFTER. or AROUND. what is the modification. an FIRST. If fn is of the form (fn1 IN fn2). and indicates whether the AFTER. Both when and where are optional arguments. FIRST.what].where. to be advised. advise first checks to see if' it is one of BOTTOM. to insert it the advice at the corresponding location. and what. is to be operate BEFORE. If where=NIL. or a function of three arguments: or a function of four arguments: [ fn .g. or (BEFORE PRINT) meaning before the advice containing print. or AROUND the body of the function where specifies exactly where in the list of advice the new advice placed. LAST. the function or AROUND.st argument. as with break. advice is to definition. Noto If when=NIL. and 19.2 Advise Functions Advise Advise is a function of four arguments: fn.when .where .when . when is either BEFORE. advise can be thought of as a [fn. and operates accordingly. f. that the advice is always the la. fn is tho or pioce of AFTER.

6 . i f getp[name. 6 of) advisedfns. If fn is not defined. So that unadvise[T) always unadvises the last function advised.ADVISED]=NIL.then fni·IN·fn2 is used in place of fn. An appropriate expression definition is then created for Finally. an error is generated.Z.!l!! definition. they are distributed as shown in the example on page 19. so that these functions can also be advised. it is unbroken before advising.8. and RETURN. If f. ·If ~=BEFORE or AFTER. i. SETQ. and the gensym is defined with the original definition of fn. NOT A FUNCTION. 19. 6 If fn is broken.!l is being advised for the Hr st time. fn is added to the (front s- fn.. the that If ~--------------------~--------------------------------------------------------If fnl and/or ~ are lists. the advice is inserted in f. · See page 19.e. Within context. ·a Qensym is generated and stored on the property list of fn under tho property ADVISED. it is moved to the front of advisedfns. 7 If fn has been advised before. either BEFORE or AFTER original body of the function. its position is determined by where. 6 7 Using private versions of PROG.

the body is substituted for ti in the advice. the advice added following all other advice. s---------------------------~--Q-GW•OOOOQDOP•aO•DOQgOO•Qo•-•DOD•a•o•----------- that a record of' all the changes is available for subsequent use in readvising. (AFTER PRINT) .AROUND. Xf when=AROUNO. the value of advise is a list of individual functions. The value of where is ignored. not necessarily in order of appearance of the advice in the definition of fn. is where treated as a command for the editor. see page 19. (BEFORE 3). and the result becomes the new body. e. If fn is non-atomic. and what. Otherwise. e. the advice is inserted as the first piece of advice.where. Finally list[when. or NIL.g. if any. advise[FOO.(RESETFORM (OUTPUT T) ~)]. a 18 breakin.BOTTOM. 8 Note that this property valuo is a list of the advice in order of calls to advise.g.what) added (by addprop) to the value o!f property ADVICE on the property list fn. earlier ones will be embedded inside later ones. advised with every function the same values when. is If where=FXRST or TOP. (but in fn copies) is for In this case. END. The value of advise is fn.8. \vhere~LAST. where.7 . Note that if several pieces of AROUND advice are specified. So 19.

(However if a function is broken at the time it is advised. advinfolst and readvisc thus correspond to brkinfolst and rebreak. editing of advice can be performed on either the function's definition or its property list. unadvise[T] unadvises advisedfns.) Similarly. 9 unadvise saves on the list advinfolst enough information to allow restoring a function to its advised state using readvise. 10 moves the current value of the property ADVICE to In reverse order. advised functions can be edited.Note: advised functions can be broken. unadvise READVICE. 19. including their advice. so that the most recently advised function is unadvised last. unadvise(] unadvises all functions on advisedfns. i. its unadvised state. 10 It first sets advinfolst to NIL. unadvise will still restore the function to but any changes to the body of the dt:tfinition will survive.e. including removing the properties added by advise. unadvise[x] It takes an indefinite number of functions and restores them to their original unadvised state. is a no-spread NLAMBDA a la unbreak. the the most first function recently of advised function.. is a no-spread NLAMBDA a la rebreak for restoring readvise[x] 9-----------------------------------------------------------------------------Except i f a function also contains the property READVICE (see reactviso below).8 . ·Since the advice stored on the property list is the same structure as the advice inserted in the function. it is first unbroken.

advise. readvise retrieves For the each adviso information either from the property READVICE for that function. readvise[T) readvises just the first function on advinfolst. advisedump writes both a deflist and a readvise. A difference between advise. Note advise. once readvised. sequence permanent. information In on property READVICE if not already there. so that the advice readvise to become removes the 'intermediate advice' by restoring the function to its earlier state. is that if a function is not rebroken between successive unbreak[]'s.e. the function most recently unadvised. calls to unadvise update the property READVICE with the current value of the property ADVICE. t1 its break information is forgotten. value is (fn ·NO ADVICE SAVED). the or from advinfolst. unadvise. 1.flg] Used by prettydef when given a command of the form 1 (ADVISE --) or (ADVICE ·-). and t1 rebreak.e.a function to its advised state without having to specify all function the on ~· advise information. that the unadvise causes the augmented sequence readvise. In fact. and re advise versus break. readvise. f. corresponding addition advise stores it this and performs operation(s). readvise[] readvises everything on advinfolst. subsequent calls to unadvise will not remove it. However. tho If no information is found for a particular function. advisedump[x. unbreak.9=NIL corresponds to (ADVICE -- . i. 19.19=T corresponds to (ADVISE -·). a function's advice is permanently saved on its property list (under READVICE).9 f!..

10 making it . In either case. thereby 'permanent' as described above. Le. 19 . advisedump copies the advise information to the property READVICE.). only the deflist is written.

........ .7-9 19...7 19.......5.............7 19........•..........6 19.................. INDEX .....•...........................•.. .....................................7 19.....•.•.. .. ....... (fnl IN fn2) ...•....4-6 19......4 . .......... ...•..4.... ••• TOP (as argument to advise) ...... fn1-IN-fn2 ....2...........•........6 19.......................8·9 19..5... ........ AROUND (as argument to advise) ..4.................6...........•....8-9 19.... ADVICE ( prettydef command) ........ ADV-RETURf~ .4' 6 19....... ADVICE (property name) ...........8-10 19....................... ADVISEDUMP[X. ADVISE[FN..... ADVINFOLST (system variable/parameter) ..... BEFORE (as argument to advise) .......••.. ADVISEDFNS (system variable/parameter) ...Index for Section 19 Page Numbers advice ..4 19..... ADVISE ( prettydef command) .6.......7 19.. GEtJSYM[CHAR) .. ..•... "...2.................. ADV-SETQ ........... AFTER (as argument to advise) ........... .... ADVISED (property name) .........6 19. .............4-8 19.........6 19 ...........................WHEN..8 19..5.5 19......5...•..... FIRST (as argument to advise) .4. LAST (as argument to advise) .WHERE... PRETTYDEF ....... BOTTOM (as argument to advise) ... .........••..7 19............WHAT] .................5... UtJADVISE[ X] NL~• ••••••••••••••••••••••••••••••••• UNBROKEIJ (typed by advise) ... ..................1-10 19... !VALUE (with advising) ........4-6 19................2... ...19 ..... .... ..... .......... NOT A FUNCTION (error message) ...FLG] ... .•....... ••••••••••••••••••••••••••••• ...... ..6 19..........9 19... . advising ......1 19.9 19...........5 19......... " •••• READVICE (property name) READVISE[ X] l\JL>'l ............6 19.....................8-9 19 ....9 19......•. ADV-PROG .....9 19.......

.

20. Teitelman. To illustrate this in more detail. G. Tho current form of printstructure was written by W.SECTION 20 PRINTSTRUCTURE. AND HELPSYS 20. INTERSCOPE. the name of the top level function called in your system.1 . it is often convenient to have a map to show which functions are called by each of the functions in a system. If fn is then typing in printstructure[fn] will cause a tree printout of the function-call structure of fn.1 Printstructure 1 In trying to work with large programs. we itself as an us~ the printstructur·e program example~ 1-------------------------------------------------~-----------------·---------A preliminary version of printstructure was written by D. a user can lose track of the hierarchy which defines his program structure. Bobrow.

CALLSFLG.GENFLG.LSTEM.Z.O. VARSFLG] CALLEO BY: PROGSTRUC.PRGSTRC1. LIT.B.Z.DONELST] CALLED BY: PRINSTRUCTURE. ] CALLED BY: PRINTSTRUCTURE.VARSFLG.DEF. ] CALLED BY: CALLSl Figure 20·1 20.PROGSTRUC. VARS1. .O.N. A.QUOTEFNSJ CALLED BY: PROGSTRUC.CALLSZ PROGSTRUC [FN.X. N.N.V.FLG.FILEi DONELST.OPO.HEAD. L.V1. VARSFLG.NOFNS.PRINTSTRUCTURE PRGETO PROGSTRUC PRGETO PRGSTRC NOTFN PRGETO PROGSTRUC PRGSTRC1 PRNCONC PRGSTRC1 PRGSTRC PRNCONC PRGSTRC CALLSl MAKE LIST .ADR.LASTLOCJ CALLED BY: PRGSTRC.PRGSTRCl PRNCONC [X.Y.CALLSZ MAKELIST [N.CALLS1 PRGSTRC1 (L.VARSZ. DEF.TREE.0.PRGSTRC PRGSTRC [X. CALLSFLG] CALLEO BY: PRGSTRC1.FLG.2 .YESFNS.TREELST. . NOTFN CALLSZ CALLSl PRGETO TREEPRINT TREEPRINT1 TREE PRINT VARPRINT VARPRINT1 TREEPRINT1 VARPRINTZ ALLCALLS ALLCALLS1 ALLCALLS1 TREE PR IN Tl +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PRINTSTR0CTURE [X.VARSt. NOFNS.DONELST.LAST·PRINTSTRUCTURE] CALLED BY: PRGETD [X.V.X.V2.PRGSTRC CALLSl [ADR.VARS2.FN.PRGSTRC NOTFN [FN.FIRSTLOC.LEFT.FLG.CALLSFLG.HEAO. VARSl.VARSZ] CALLED BY: PRGSTRC. FN.NOTFN.X.VARS1.END. TREEFNS. N.X.NOTRACEFNS. Y.X.tREEFNS.TEM.PRDEPTH.

~ and file. nconc. notfn and calls2. these do not appear in the output is that they were "uninteresting" by the user for the purposes of his analysis. Note that a function whose substructure has already been shown is not expanded in its second occurrence in the tree. callsl. and varprint. and prgstrc. proostruc. progstruc. turn calls prgstrcl. prgstrc calls progstruc in notfn. The lower portion of the printout contains. yesfns and nofns are used for th is Any function that appears on the list nofns is not of interest. internally. uses no It binds . and itself.3 . As for functions appearing on neither nofns or yesfns. The reason in addition to the four functions appearing in the above output.The upper portion of this printout is the usual horizontal version of a troo. progstruc. prgstrcl calls prnconc.and is of the flg. binds called by printstructure. For free variables. no variables free n. and a list of the functions that call it. . . eleven variables internally: last-printstructure as functions in the tree. any function appearing on yesfns is of interest. This tree is straighforwardly derived from the definitions of the functions: printstructure calls prgetd. 20.ill:• list. £. and two variables. and lastfn. ill!• 2 and uses prdepth and It is not called prgetd is a function of two arguments. donelst. but only those compiled functions whose code lies in that portion of bpspaco j----------------------------------------------------·------------------------Variables are bound internally by either PROGs LAMBDA-expressions. for each function. example. printstructure calls many other low-level functions such as getd. all interpreted functions are deemed interesting. itself. printstructure is a function of two arguments. and by any ~. information about the variables it uses. yesfns=T effectively puts all functions on yesfns. defined Two functions. variables. etc. firstfn purpose. treeprint. prgstrc and prnconc. prgetd.

notracefns and prdepth. are all initialized in this fashion. information) for example. detects functions that are not defined.s evaluate ·and its ~ the form arguments For example. + The user can inform printstructure (and other system packages which require + this + putting on its property list the property INFO value EVAL.E. and NOW as an undefined function.. 20. i f the function (NLAMBDA (X) (MAPC X (FUNCTION PRIN1))). do not.between the two limits established by firstfn and lastfn. THE. and + TIME would not be reported as free variables.. Two other variables. It is initially set to 7. Note also that since printstructure (i. the firstfn[ PRINTSTRUCTURE] and lastfn[ALLCALLS1]. If printstructure encounters a form beginning with two left parentheses in tho course of analyzing an interpreted function (other than a COND clause or opon lambda expression) it notes the presence of a ~ossible Qarentheses ~rror by the· abbreviation P. ersetg. also affect the action of Functions that appear on the list notracefns will appear in the tree. atoms appearing as CAR of a form)..e. evaluate their arguments. IS.e. + printstructure assumes that all functions whose argtypes are 1 or 3. that an nlambda function ™• doe. but their definitions will not be analyzed. + were + (PRINO (NOW IS THE TIME)) appeared in a function being analyzed.4 . as in the example below. Qrintstructure. and the form itself. above analysis was performed following For example. prdepth is a cutoff depth for analysis. assuming they are "interesting" functions as defined above. defined as.in which the form appears. i. + functions and. printstructure is a useful tool for debugging. followed by the function .P. by the etc. all + NLAMBDAs.

and returns value. Note that file=NIL (not NIL:) means print the tree to primary output file. Thus if the user did not want to see any output. prints the result (in the format shown earlier) to file (which is opened if necessary and closed afterwards). EXPR properties on However. and file. .P. 3 and then process the result himself by using last-printstructure. P.5 .((CONS X (CAR X))) Figure 20·2 Other Options printstructure is a function of three arguments. the if exprflg=T. IN FOO . 20. printstructure analyzes 2S• sets the free variable last-printstructure to the results of its analysis. ] CALLED BY: F001 IS NOT DEFINED.o-PP FOO (FOO [LAMBDA (X) ccorm ((CAR X) (F001 X)) (T ((CONS X (CAR X]) FOO ~PRINTSTRUCTURE(FOO) FOO FOO FOOl [ X. he ~ as its could call printstructure with file=NIL:. property list of printstructuro will i----------------------~------------------------------------------------------NIL: is a TENEX output device that acts like a 'bottomless pit'. printstructure always checks· for functions that are not defined. ~· exprflg.E.

then the third.g. Thus printstructure[(FOO FIE (FUM))] will produce three trees. unless it was already analyzed.on call contains a compiled definition. producing however many trees required. but simply prints the result of the last analysis.e. and neither of the calls to FUM from FOO or FIE will be expanded in their respective trees. FUM will not be expanded in the tree for FIE. ~can be NIL. If x is NIL. or an atom that evaluates to a list. I f :::. a list.. and there is also an EXPR property. i. breakfns.e. subsequent functions are not separately analyzed i f they have been encountered in the analysis of a function appearing earlier on the list.prefer to analyze EXPR definitions whenever possible. printstructure will process that list as described above. H the user wishes to he can simply perform (PRINTSTRUCTURE BREAKFNS). the ordering of x and FIE call FUM. Thus. i.6 Of . a function.s. For example. printstructure[(FOO FIE FUM)). If x is a list. that stored on last-printstructure. Thus the user can effectively redirect the output that is going to the terminal to a disc file by aborting the printout. etc. can be important. then FIE will not have a tree either. and thon analyzes the second function.. if FOO also calls FIE.) The convention of listing FUM can be used to force printstructure to give FUM a tree of its own. Note that in the case that !5 is a list.file). will produce a tree for FOO containing emboddod in it the tree for FUM. the latter will be analyzed. (Of course. printstructure[x) is the same as printstructure[(x)).. is not a list. and then performing printstructufe[NIL. if both FOO Thus. printstructure analyzes the first function on . printstructure does not perform any analysis. or evaluates to a list. i f the function definit:l. analyze a collection of functions. 20. but is the name of a function. if the value of ~ is a list of functions. nor will it have a tree of its own. e. Finally.

. a list of the trees. and treelst. i l l of the variable list is a list of variables bound in the function. of the functions appearing in any 0 tree. been if achieved FOO. i.E. in this example. The result of the analysis of printstructure is in two parts: donelst.e. and a variable list for that function. by and FUM. in an odd position. FIE. 20..treelst].. in alternation. a list summarizing the argument/variable information for each function appearing in the tree(s).7 .course.. no ordering would suffice. donelst is a list consisting.e. a list of those variables Thus the form of donelst for the earlier example would be: (PRINTSTRUCTURE ((X FILE DONELST N TREELST TREEFNS L TEM XV Z FH TREE) PRDEPTH LAST~PRINTSTRUCTURE) PRGETD ((X FLG)) PROGSTRUC (( FN DEF NV Z CALLSFLG VARSFLG VARS1 VARS2 0 X) N DONELST) . occurred. i. ALLCALLS1 ((FN TR AB))) Possible parentheses errors are indicated on donelst by a non-atomic form appearing where a function would normally occur. Instead. the user would have to do printstructure[((FOO) (FIE) (FUM))]. printstructure[(FUM FOO FIE)]. and cdr is used freely in the function. last·printstructure is set to cons[donelst.P. have However. and yet the user wanted to see three sopara to trees. a 11 called each other. The non-atomic form is followed by the name of the function in which the P. the same effect could reordering.

. and returns ~ as its value.. i.8 . prints a tree in the horizontal fashion shown in the examples above.. outputs result trees·. all compiled functions defined later than fn are rejected.e.exprflg.treelst] prints the ·"lower half" of the pri~tstructure output. If exprflg=T. analyze expr's. 20. Otherwise fn is the name of a compiled function and the boundary is set at fn. bpspace.5.treelst] uses treelst to produce a list of the functions that call fn. firstfn[fn] If fn=T.e.• no compiled functions will pass this test. upper boundary set at end of bpspaco.n] printstructure will. printstructure performs (MAPC TREELST (FUNCTION TREEPRINT)).e.e . allcalls[fn. Otherwise boundary set at fn. and on· variable information to file. all compiled functions will pass this test. If fn=NIL.e. all compiled functions defined earlier than fn are rejected.Printstructure Functions printstructure[x. 1. prefer to See page 20. i.e. lower boundary set at end of i. all subrs and all compiled functions will pass this test. i. lower boundary is set to O. treeprint[x. lastfn[ fn] if fn=NIL.. i.. varprint[donelst.file] saves· analyzes 1ast·printstructure.

exprflg] cdr(calls[fn.exprflg)) 20. calls[progstruc] = ((PRGETD EXPRP PRGSTRC CCODEP CALLSl ATTACH) (FN DEF N Y Z CALLSFLG VARSFLG VARSl VARSZ 0 X) (N OONELST)) fn can be a function name.9 .exprflg. variables bound in !!!• and a list of a list of variables used freely in fn.Thus to accept all compiled functions.T]) freevars[fn. i. perform firstfn(T) and lastfn(NIL): to reject all compiled functions.exprflg] cadr[vars[fn. calls[fn.exprflg.e. it indicates what functions fn calls. but reports calls does not its findings by returning as its value a list of three elements: a list of all functions called by fn. but does not go further and analyze any of them. e. a definition. vars[fn. If varsflg is T.g.varsflg] is a fast 'one-level' printstructure. print a tree. Calls first does firstfn( T)... or a lastfn() so functions appear. form. that all subrs and compiled except those on nofns. perform firstfn(]. calls ignores functions and only looks at the variables (and therefore runs much faster).

such a procedure can be printstructure does not even compute certain certain important types of information. "WHAT FUNCTIONS CALL FIE? 11 • obtainable directly from the data base. FOO uses X freely. for example. although it extracts considerably more information and relationships than does printstructure.interscope knows about. Like printstructure.g.e. Other questions cause interscope to 20. contains a sample . and contain conjunctions. printstructure does not distinguish between functions that use a variable freely and those that set it (or smash it). session with interscope. disjunctions. quite tedious.20. Furthermore~ For large systems. These questions can be input in English. if Xis bound 1 above 1 FOO. 11 its Figure data 20~3 base. iO DOES FOO CALL FIE?".g. 11 WHAT VARIABLES DOES. FOO SET?" search "WHAT FUNCTIONS BIND VARIABLES THAT FOO SETS?". Interscope is an extension of printstructure designed resolve to these shortcomings. interscope allows the user to ask it questions about the '' programs it has analysed. and. look down at tile· lower portion of the printout and find whether the corresponding function binds X. instead of presenting the information it obtains in a predetermined format. e. open questions. interscope analyses programs (functions). i. and negations of the many relationships between functions and variables that . However.2 Interscope 4 While printstructure is a convenient tool for giving the user an overvtew of the structure of his programs~ it~is not well suited for determining the answor to particular questions the user may have about his programs. to interrogate its data base.g. or The answers to some questions are e. and the user wants to kno~where For example. at each point. he has to visually trace ·back Up the tree that ts output by printstructure. The questions can be closed questions. e.

11 . what would you like to know? &WHO CALLS RETDWIM? (WTFIX FIX89TYPEIN FIXAPPLY FIXATOM FIXCONTINUE CLISPATOM FIXT) &HOW IS CLISPATOM CALLED? I didn 1 t understand that. [3) &WHAT FUNCTIONS CALL CLISPATOM? [4] (WTFIX FIXAPPLY FIXATOM) &WHAT FREE VARIABLES DOES CLISPATOM USE? (ONLYSPELLFLG CLISPCHANGES CLISPFLG TYPE-IN? CLISPSTATS INFIXSTATS LST FAULTXX CHCONLST FAULTX DWIMIFYFLG 89CHANGE FAULTPOS) &WHO BINDS TAIL? • (WTFIX RETDWIMl RETDWIM2 RETDWIM3 CLISPFUNCTION? CLISPATOMO CLISPATOMl CLISPATOMlA CLISPATOM2A DWIMIFYlA OWIMIFY2 DWIMIFYZA CLISPRESPELL) &WHO BINDS TAIL AND CALLS CLISPATOM SOMEHOW? (WTFIX DWIMIFY2) &WHAT VARS DOES HELPFIX CHANGE? (FORM LASTPOS NOCHANGEFLG HELPFIXTAIL FN TEH BRKEXP) &WHAT FUNCTIONS CHANGE THE VARIABLE TENTATIVE? (CLISPATOMl CLISPATOM2 C~ISPATOM2C CLISPATOM2A CLISPATOHlA) &WHO CHANGES TAIL? (FIXATOM HELPFIXl CLISPATOMl CLISPATOM2 OWIMIFY2) &WHAT FNS USE TEM AS AN INTERANL VAR ANO . 10431 FREE WORDS Shall I analyze another system? &~NO [2] Ok. • CLISPATOM LISTP RETDWIM LISTP (6) . figure 20-3 20. Goodbye. shall I analyze a system? AND CLISPFNS. ARE CALLED BY CLISPATOM INDIRECTLY? INTERANL=INTERNAL ? Yes (RETDWIM RETDWIMl FIX89TYPEIN) &HOW DOES CLIAPTOM CALL LISTP? CLIAPTOM=CLISPATOM ? Yes ((CLISPATOM LISTP) (CLISPATOM ••• RETOWIM *** LISTP) (CLISPATOM (5) FIX89 FIX89A LISTP)) &SHOW ME THE PATHS FROM CLISPATOH TO LISTP ..• FIX89 FIX89A LISTP &DOES GETVARS SMASH ANY VARIABLES? (L) &SHOW ME HOW GETVARS SMASHES L.~INTERSCOPE] Hello. (NCONC L (AND (LISTP X) (MAPCAR & &))) &GOODBYE. This may take a few minutes. RETDWIMl LISTP FIX89TYPEIN RETDWIM •.. [1] &~WTFIXFNS GC: 8 1233.

o will respond "I didn't understand that". it will ask the usor functions he wahts analyzed. interscope treats forms as indicating a list of functions to be analysed. tho line will be given to lispx for evaluation and (probably) cause a U. Howev~r. declared to interscope goes interscope to "ANALYZE FOOFNS. what When interscope is first called. Interscope goes into question-answering mode when the user answers NO to the question "Shall I analyse a (another) system?" ([2] in Figure 20-3). i f the user types "HAS THOU SLAIN THE JABBERWOCK ?". if it is not able to make sense of the input. will be "uninteresting. For exar. and it has not previously analyzed any functions. the user those which are Note that after can instruct either in English input. interscope simply passes forms back to lispx for evaluation. HAS error. 6 interscope assumes that any input line terminated by a punctuation mark is intended for it to process. interscope must analyze them and build its data-base. i. 6 additional functions. interscope will assume that it w<1s intended to be handled by lispx.iple. as indicated by its greeting and prompt character (&~instead of&) (see [1] in Figure 20-3). an English preprocessor. All of the functions below each top levol except as described below.In order to answer questions about programs. and pass it back for evaluation. or run 5-----------------------------------------------------------------------------h!hen interscope is first called. e." analyzed. The structure of intersco12.2 may be divided into three major subsystems: a top-level monitor function.D. The monitor function is implemented via userexec (see Section 22).g.F. those not ending in punctuation. The user can respond to this question by giving interscope either: I) the name of the top level function called in his system. question-answering mode. interscope will also attempt to process othor input lines.16). it is in analysis mode. whereas in question-answering mode. the user can REDO or FIX interscope questions. but if the user omits the '?'.12 . or 2) the name of a variable that evaluates to a list of top level functions. 20. 6 For example. The only difference between analysis mode and question-answering mode is that in analysis mode. function or 3) the list itself. interrogate the history list for his session. intorscor." bo into analyze or by calling the function lookat directly (page 20. and the functions which build and search the data base.e. so that the features of the programmer's assistant are available from within interscope.

20 . interscope will try to inform the user what part of the sentence it did not understand. either by typing OK or GOODBYE. includes spelling correction). Both data basos are stored on the property lists of the functions and variables which are analyzed. and then reenter interscope at somo lator point and continue asking questions. 9 When this happens. depending on the questions asked by the user. 7-----------------------------------------------------------------------------Since the data base that interscope constructs is global (storod on property lists). 8 The translation of the most recent input is always stored in the function definition cell of the atom MEANING. and the second containing information derived from the first.g.ri to anything outside this subset ([3] in Figure 20-3). 8 searching preprocessor is statements. The first data base is created when interscope analyzes a system (via the function lookat). and replies "I didn't understand that.progra~s from within interscope.e. translates forms Although English appropriate this for questions. i. without having to reanalyze his functions. It should be noted that ihterscope actually creates two data bases. the user can also exit from interscope. the first containing information about the elementary relations between the functions and variables in the user's system. The second data base is developed incrementally (by the function paths). The interscope data-base can be accessed directly by the user via the functions described below. it translates only a limited subset of English sentences.13 . the paths by which one function calls another. 9 Where possible. or via control·D. usually a simple rephrasing of the question will suffice to allow interscope to handle it ([4] in Figure 20·3). and and building the fairly flexible and robust (e. 7 The English commands preprocessor into interscope INTERLISP data base.

calling· FIEl . by is at [5] in Figure 20·3. use. one of the paths which CLISPATOM calls LISTP is given as (CLISPATOM •** RETDWIM *** LISTP)..only] Value is a list of paths from ! to ~· each path is an ordered list of functions. etc. change. paths[FOO.rnust. and more than one path from RETDWIM to The conventions· used by LISTP~ interscbpe for recognizing functions that arc "uninteresting" are the same as those used by printstructure (page 20.14 then . e. which functions may ·cause a given fun ct ion to bo called. which means that there is more than one path from CLISPATOM to RETDWIM. nofns firstfn. either by a given function or by a group of functions. and FIE calls FUM directly as well as.y. Information about the function-call paths from one program to another "generalized" when it is stored.type. yesfns . 10 which variables are used as global or local free variables. test.Interscope "understands" a wide variety of the elementary relations that exist between functions and variables.3). which calls FUM. or smash a given variable.e.g. i.g.avoid. which functions bind. For example. if FOO calls FIE.FUM] returns ((FOO FIE*** FUM)). where *** is used to indicate multiple paths. e. Interscope Functions paths[x. either directly or indirectly. and lastfn all have the same effect as for pr in tstrucwre. 20 .

11 WHAT ARE THE PATHS FROM FOO TO FIE WHICH ONLY GO THROUGH FOOFNS AN°c) AVOID FIEFNS?" 12 treepaths is called for English inputs of the form "SHOW ME HOW x CALLS y". avoid.g.only) Like paths.must. paths[FUM. CALLS). must. except prints as shown at [6] paths as a in Figure 20·3.~. and/or onlv. 20 .y. "DISPLAY THE PATHS FROM x TO y 11 .type. no path can go through any function which is not a member of pat~ only. each can only go through functions on only.15 . o. 1. 12 ii·---------------------------------------------------------------------------paths is cailed for English inputs of the form: "WHAT ARE THE PATHS FROM x TO y?". and only have the same meaning as with paths. and only are optional. must. are used to select out Each can be specified by an atom which evaluates to a list of functions. avoid.e. 11 treepaths[x. avoid. !l. must. If (the each path is required to go through at least one of the members of must. and only certain types of paths.FUM). reverse order. etc. list. no path can go through any member of avoid.avoid.CALLEDBY] would return the same set of paths as paths[FOO. Such questions can be modified with subordinate clauses to indicate values (or must. ~. If avoid is non-NIL. tree structure. except each path would be in the.g. above the in example.!!Q cnn be either CALLS or CALLEDBV (NIL is equivalent to e.FOO. or a form which evaluates to such a value of) must is non-NIL. If only is non-NIL. avoid.

16 .1pget is given a value for relation that it does not: recognize. or the list of functions itself.plete list of tho possible values for relation is given below.g. 13 object can be a list of objects (or a variable which evaluates to a list of objects). Similarly. clumpget[X.g. functions that smash the variable X. it will type "I don't know anything about obJect.CALLERS] functions a list of that call FOO. universe can be a list of·objec~~ variable which evaluates to a list -0f (or a object~). and if that fails. shall I analyse a syste~?" and go into analysis mode. in which case the value returned by clumpget is the list or all objects which have the indicated relation to any of the members of object.relation:universe] variables) which have the indicated relation with respect to returns a object. A com. clumpget[FOO. etc. in which case the value returned by clumrget is tho list of all objects in uni verse which have tho indicated relation members to object of (or object). tho name of a variable which evaluates to a list of functions. any of the e. If given a value for object that it has not seen before. 20 . list of clumpget[X.lookat[x) Builds the initial data base describing the system !• where ! is either the name of a function. i t will attempt spelling correction.SMASHERS] e. ia----------------------------------------------------------------------------If clur.SMASHERS:FOOFNS]. generat~f an error. Value is a list of objects (functions or clumpget[object.

univorso] in place of object.Finally. Currently. the value returned is tho list of all objects which have the indicatod relation to any. WHO DOES SOMEHOW?" ABOVE union of object with CALLCAUSERS. the following relations are implemented: CALLERS list of functions that directly call qbject.17 object. i. universe can be a relation. is a list of functions that use freely any of the variables that are bound locally by FOO. BELOW union of object with CALLSCAUSED. CALLE OF NS list of functions directly called by object. which is equivalent to supplying clumpget(object.CALLERS.e.of the members of the {set of all objects which bear the relationship universe to object}.LOCALVARSJ FOO (CALLEDFNS). perhaps In English: "WHO CALLS FOO SOMEHOW?". CALLSCAUSED list of call In called English: 11 by object.FREEUSERS. CALLCAUSERS list of functions indirectly.. that perhaps FOO CALL . 20. functions indirectly. ARGS arguments of object.CALLEDFNS] is a list of all functions that call any of the functions (CALLERS) that are directly called by clumpget[FOO. clumpget(FOO. For example.

but are bound in object before they are used. 14----------------------------------------------------------------------------Note that if object is the name of a function and universe is NIL. e.ENTRYFNS]. e. It is only in connection with collections of functions that LOCALFREEVARS and GLOBALFREEVARS become interesting. e. FREEUSERS list of functions that use object freely. LOCALBINDERS list of functions that bind object as a local variable. LOCAL VARS list of variables that are locally bound in object. and GLOBALFREEVARS the same as FREEVARS. ENTRYFNS list of each function called by any function itself.ARGBrnDERS list of functions that have object as an argument. LOCALFREEVARS list of variables that are used freely in object. f REEVARS list of variables used freely by object.LOCALFllEEVARS. 14 In English: "WHAT ARE THE LOCAL FREE VARS (VARIABLES) BELOW FOO?" GLOBALFREEVARS list of variables used freely in object without previously being bound in object.g.g. clurnpget[FOO. PROG vars.18 .g. 20 . in object which in object is other not than clumpget[FOOFNS. but arc bound above the place that they are used . LOCALFREEVARS will always be NIL.BELOW] gives a list of those variables used freely below FOO.

etc.) 15 CHANGERS list of functions that change object. SETN. RPAQ. perhaps indirectly. via SETQ. 16 i5. CAUSESELFCALL list of functions in object which could call cause somo themselves.e. RPLACAVARS. and translates the same as 'change'. /RPLACA.~~. where i.E ~~£~$ ~ SETQQERS. SETQQ.-. RPLACDERS.. or even an expression of the form (RPLACA (QUOTE atom) value) (or FRPLACA. etc.·5Erov~~.19 .~ i ~~~. in case the user wants to distinguish tho different types of smashing. etc. SAVESET. 16 Initially (RPLACA RPLACD FRPLACA FRPLACD /RPLACA /RPLACO NCONC NCONCl /NCONC /NCONCl ATTACH /ATTACH RPLNODE /RPLNODE RPLNODE2 /RPLNODE2).-V~~s~ -·.~~~~~~--. CAUSERECURSION list of functions in object which function to call itself.R5: • 5[.iro.. perhaps indirectly.. 20 . As with assignments.:--. RPLACDVARS. CHANGEVARS list of variables that are changed by obj net... 1Vote: 'set' in English tnput means anv flavor of assignment. In English.o-n-. etc. "WHAT ARE THE SETQERS OF X?".~--r·e-ia-t-. in case the user wants to distinguish betwonn the various flavors of assignments. SMASHVARS list of variables whose value are smashed by object.SELFRECURSIVE list of functions in object which call themselves directly. SETQQVARS. where •smash 1 means the variable appears as the first argument to one of the list of functions on smasherslst.. 'changed' means any flavor of assignment. clumpget will accept as relations RPLACAERS..

or anywhere in an ·AND or OR. 20. it included in the value of USEVARS. or as the predicate in a CONO clause. TESTVARS USERS are subsets of USEVARS.20 wi 11 not bo CHANGEVARS and . initially (ATOM USTP NUMBERP NLISTP STRINGP EQ EQP EQUAL NULL). if a variable is simply bound. USE VARS list of variables that are· used in object. i. or as the first argument to SELECTQ. but not actually used any-Where. list of functions that use object. TESTERS list of functions that test object.SMASHERS list of functions that smash object. where 'used' means· actually appear in the body of tho function.e. etc. TESTVARS list of variables that are tested by object. whoro 'tested' means they appear as the first argument to one of the list of·functions on tosterslst.

WHILE as a CLISP iterative statement operator from section 23 WHILE pred provides a way of terminating the i. WHILE pred evaluates pred before each iteration. The user can then interrogate the value of the break which is bound on the variable !value. exits. wishes to be able to do something about it if it is wrong. + + + + + + + + + + + + + !TELL ME ABOUT UB~ UB as a break command from section 15 + UB + + unbreaks (FOO BROKEN) :UB brkfn. simple carriage-return.. + !TELL ME ABOUT EVAL) Do you want to see the function ? No Do you want to see the break command ? yes + EVAL Sane as GO or OK except that the break is maintained after the evaluation. and sentences.21 . Helpsys uses the INTERLISP Reference + Man~al by + presenting the appropriate passages from the manual. EVAL is a useful command when the user is not sure whether or not the break will produce the correct value and.Helpsys 17 ?0. base. + as of a data. namely in + the area of documentation of INTERLISP. about INTERLISP terminated User inputs are underlined. Inquiries are made in tho + form a + The following sample session illustrates the use of Helpsys.3 Helpsys provides yet another form of on-line assistance to the user.s. answers void simple questions of punctuation. with + ~HELPSYS] Type ??? <CR> for assistance !TELL ME ABOUT WHILE> . + + + FOO + + + and FOO is now unbroken !REDO EVAL) + + 20.g. and if the value is NIL. and continue with the break. More? Yes Typing GO or OK following EVAL will not cause reevaluation but another EVAL will.. e.

brktype is NIL for user breaks.. + + !USE 2ND FOR LAST( •.. and ERRORX for error breaks.. Footnote (7] now? yes eva 1 is a the stack.iply causes helpsys to skip over what it was currently typing.brktype] is an nlambda.e. ARG NOT ARRAY. if a INTERRUPT for is not an array. etc.? + NIL + + + + The value of x.brkwhen. + + + + + !WHAT IS THE VALUE OF MAPC( ••• MAPC as a function from section 11 + + ! OK.propl. control-H breaks. x. !TELL ME ABOUT THE LAST ARUGNEMT OF CHANGEPROP? =ARGUMErn ••• CHANGEPROP as a function from section 7 + changeprop[x. which 1 1 sir. paragraph. mapc is NIL.22 .prop2] Changes name of property prop1 to prop2 on property list of (but does not affect the value of the property). BREAKl as a function from section 15 + + breakl[brkexp. + + !WHAT ARE THE ARGS FOR BREAKl) Valid arguments for BREAKl are: [BRKEXP. and continue with the same subject further on. footnote.. so its argument {user aborts output by typing control-£) 18 is the first evaluated. (but does not affect the value of the property).brkcoms.brkfn.propl. eval provides a way of calling the interpreter. i8----------------------------------------------------------------------------The user could also interrupt the output by striking the del key.BRKFN..BRKWHEN.g. yes eval(x] eval evaluates the expression x and returns this value i. Value is x.prop2] Changes name of property propl to prop2 on property list of (but does not affect the value of the property).. CHANGE PROP as a function from section 7 + + changeprop[x. e. + + !TELL ME ABOUT ERROR IN ARRAYSIZE? ••• ARRAYSIZE as a function from section 10 + + + + + + Generates an error.+ + + + + Do you want to see the function 1 .BRKCOMS.. e. subr so that the 'name 1 x does not actua llY appear + { "'7"'} + on + + Note that eval is itself a lambda type function. 20.BRKTYPE] + + !TELL ME AOUT THE THIRD ARG FOR BREAK1l =ABOUT .g.

.16 20.....• NOTRACEFf... ............. name) ........4 20.........7 20.3 20.. PROEPTH (printstructure variable/parameter} PRINTSTRUCTURE[X....... .........P....... .... ........ CLUMPGET[OBJECT.4 20....•• x*~ (in interscope output) .4 20.VARSFLG] . ..4...• LAST-PRINTSTRUCTURE (printstructure variable/parameter) .........RELATION.................. .... ........4 20... TEf...................MUST......•.MUST..................9 20......AVOID...........TREELST] ... .12...........E. ... (typed by PRINTSTRUCTURE) ..FILE] .................8 20....... HELPSYS . ........• INTERSCOPE .1 20.... INDEX.8 20..21-22 20. .. VARS[FN...16 20.. TREELST (printstructure variable/parameter) TREEPATHS[X...9 20 .............EXPRFLG..• FREEVARS[ FN.........Y........8 20..... .. OONELST (printstructure variable/parameter) EXPR (property.5 20...•............ . IS NOT DEFINED (typed by PRINTSTRUCTURE) .... VARPRINT[OONELST.l IL : ..........20. ....Y....4.•....... ........... ............AVOID...7 20....5.... ..8 20......... .............. ........ONLY] .................3 20 ..... debugging ....• TREEPRIIJT[ X... ...... IrJFO (property name) ..4. TREELST] .... NOFNS (printstructure variable/parameter) .....14 .........lS (printstructure variable/parameter) PATHS[X..... YESFNS (printstructure variable/parameter) ..... ... f...............10-20 20.• LOOKAT[ FNL] ....4 20......... ..............R.. EXPRFLG] .........8 20...... LASTFf~[FIJ] ........ ..9 20..........5 20.....5....1-9 20. ..........lEX .........EXPRFLG...... N] .....EXPRFLG] ..7 20... .......ONLY] .6 20.................... 15 20.............. .....R.......•...UNIVERSE] .......... P..7-8 20.......8 20.............13-14 20................. CALLS[FN..Index for Section 20 Page Numbers ALLCALLS[ rn...... EXPRFLG (printstructure variable/parameter) FIRSTFf~[FN] ...

.

21. and prints out the number of conses and computation time. It executes the computation timex. Garbage collect ion time is subtracted out. 10291 FREE WORDS PRETTYFNS PRETTYVARS 3727 CONSES 10 .timetyp) is an nlambda function.SECTION 21 MISCELLANEOUS 1 21. time executes timex timen number of times and prints out number of conses/timen. and computation time/timen. e.1 + + .1 Measuring Functions time[tirnex. i---------------------------------------------------------------~-------------Some of the functions in this section are TENEX or implementation dependent. This is useful for more accurate measurement on small computations.g. They may not be provided in other implementations of INTERLISP. (QUOTE PRETTY) (QUOTE PROP) FILE CREATED 7·MAY·71 12:47:14 ~TIME((LOAD GC: 8 582.timen.655 SECONDS PRETTY If timen is greater than 1 ( timen=NIL equivalent to timen=l).

e. The value of time evaluation of timex.193 SECONDS 27. REAL TIME PRETTY If timetYE? :: 3. (QUOTE PRETTY) (QUOTE PROP)) 1 3) FILE CREATED 7-MAY-71 12:47:14 ~TIME((LOAD GC: 8 582. GARBAGE COLLECTION TIME PRETTY Another option is timetype::T.378 SECONDS.055/10 = . ~ measures and prints total real time as well as computation time.2 is the value of the last . time measures and prints garbage collection time as well as computation time. 1091 FREE WORDS PRETTYFNS PRETTYVARS 3727 CONSES 10.(QUOTE (ABC))) 10) 30/10 = 3 CONSES .487 SECONDS. e.597 SECONDS 1. 21.0055 SECONDS ~TIME((COPY (A B C) If timetype is O. ~TIME((LOAD (QUOTE PRETTY) (QUOTE PROP)) 1 OJ FILE CREATED 7-MAY-71 12:47:14 GC: 8 582. in which case t imo measures and prints the number of pagefaults. 10291 FREE WORDS PRETTYFNS PRETTYVARS 3727 CONSES 11.g.g.

ss seconds. for n.. number of milliseconds since last system start up.date[J 2 obtains date and time. this number is directly accessible via the COREVAL GCTIM. yy year. returning it as single string in format "dd-mm-yy hh:mm:ss".o. mm is clock[n] month..• as described in TENEX JSYS manual. dismisses program for n 2-----------------------------------------------------------------------------In INTERLISP·lO. 3 .e. current value of the time of day clock i. for !lc1 value or tho time of day clock when tho user started up this INTERLISP. In INTERLlSP· 10.3 + + + . date will accept a value for ac3 as an argument. day ofweek. for n. where dd is day. e.=3 number of milliseconds ·of compu ta time spent in garbage collections (all types) . i.. difference between clock[O] and clock[1] is number of milliseconds ( i-eal timo) since this INTERLISP was started. acJ can be used to specify other formats. time zone. !Ml e.=2 number of milliseconds of compute time since user started up this INTERLISP (garbage collection time is subtracted off)..g. etc .g. • for 11 n=O 14·MAV 71 14:26:08 11 0 minutes. 3 dismiss[n] In INTERLISP-10. hh hours. 21.

or control-B. during which time program is in a state similar to an I/O wait. resets conscount to !!· boxcount[type. returns number of floating boxes. resets the corresponding counter to !l · gctrp[] number of cons es to next GC: 8. GC of another type Note that an intervening could collect allocate additional list words. it uses no CPU time. number of list words not in use. see Section 10. type=FLOATING.milliseconds. i. gctrp[ n J can be used to cause an interrupt when value of gctrp[J=n. i. If returns number of large integer boxes. 21. Can be aborted by control·D. 13) since INTERLISP started up. number of boxing operations (soo Section ~=N1L. control-E. pagefaults[) In INTERLISP-10.4 .e. number of page faults since INTERLISP started up. as well as See Section 3... If n is not NIL.e. * 4-----------------------------------------------------------------------------In INTERLISP-10. these counters are directly accessible via the COREVALs IBOXCN and FBOXCN. conscount[n] conscount( J returns the number of' conses since INTERLISP started up.n] ln INTERLISP-10. 4 If n is not NIL.

e. logout[ J will not affect the state of any open files. a REENTER command following a logout will reentet INTERLISP-10 at the top level. if INTERLISP was started as a subsidiary page 21. a to operating system. return NIL as tho value of the call to logout. control is returned to ~he higher fork. and continue tho computation exactly as if nothing had happened. ~ . Breakdown is available to analyze the breakdown of computation time (or any other function. 6 breakdown was written by W. 21. The function results gives the analysis of the statistic requested as well as the number ~f calls to each function. These functions are modified so that they keep track of the "charge" assessed to them.. Sample output is shown below. As with control-C.2 Breakdown6 Time gives analyses by computation.19). measureabl~ quanti~y) function by The user calls breakdown giving it a list of functions of interest. 5 In subsequent CONTINUE command wi 11 ~ enter the INTERLISP-10 program. 21.logout[] returns control INTERLISP-10. i. Teitelman. ~------------------------------------------------------------------------------ In INTERLISP-10. logout is a programmable control-C.5 f~rk (see subsvs.

SUBPRINT COMMENTl)
(SUPERPRINT SUBPRlNT COMMENTl)
~PRETTYOEF((SUPERPRINTt FOO)
FOO. ;3
~BREAKDOWN(SUPERPRINT

~RESULTS()

FUNCTIONS
SUPERPRINT
SUBPRINT
COMMENTl
TOTAL
NIL

TIME
8.261
31.910
1.612
41.783

I

CALLS
365
141
·8
514

PER CALL
0.023
0,226
0.201
0.081

%
20
76
4

The procedure used fot measuring is such that if one function calls other and
both are 'broken down', then the time (or whatever quantity is being measured)
spent in the inner function is not char~ed to the outer function as well. 7

To remove functions from those being monitored, simply unbreak the functions,
thereby

restoring

them to

their original

breakdown on the new functions.
functions not on the new list.

state.

To add

functions;

call

This will not reset the counters for any

However breakdown[] can be used for zeroing the

counters of all functions being monitored.

To use breakdown for some other statistic, before calling breakdown, set the
variable brkdwnt¥pe to the quantity of interest, e.g ..
\.lhenever breakdown is called with

brkdwntyp~

TIME,

CONSES,

not NIL, breakdown performs tho

necessary changes to its internal state to conform to the new analys i~.
particular,

etc.

In

if this is the first time an analysis is being run with this

statistic, the compiler may be called t~ compile the measuring function. 8 When
breakdown is through initializing, it sets brkdwntype back to NIL. Subsequent

7· - - b~;~~~~~~ -~iii. ·;o·t· -~i ~;· ;~~~;;~; · ~-e~~-1~~·-;; ·; • f~~~~i~~. -b·e-;n·g- -~;;;~,:;~ - ~;
not returned from normally, e.g. a lower retfrom (or error) bypasses it.
In this case, all of the time (or whatever quantity '"TSbeing moasured)
between the time th~t function is entered and the time the next function
being measured is entered will be charged to the first functi~n.
8

The measuring functions for TIME and CONSES have already been compiled.

21.6

calls to breakdown will measure the new statistic until
and a new breakdown performed.

brkdwnt~pe

is again sot

Sample output is shown below:

... SET(BRKDWNTYPE CONSES)
COl~SES

... BREAKDOWN(MATCH CONSTRUCT)
(MATCH CONSTRUCT)
... FLIP ( (A B C D E F G H C Z) ( .. $1 • • #2 .. ) ( . • !Ii 3 •• ))

(A B D E F G H Z)
.. RESULTS()
FUNCTIONS
CONS ES
MATCH
32
47
CONSTRUCT
TOTAL
79
NIL

The

value

of brkdwntype

#

CALLS

PER CALL

1'

32.000

1

z

47.000
39.500

is used to search the

information necessary to analyze this statistic.
corresponding to brkdwntype should be

or

list

%

41
59

brkdwntypes

for

tho

The entry on brkclwntvpCls

the form (type form function), whore

form computes the statistic, and function (optional) converts the,value of form
to some more interesting quantity, e.g.
(TIME (CLOCK 2) (LAMBDA (X) (FQUOTIENT X 1000))) 9 measures computation time and
reports the result in seconds instead of milliseconds.

If brkdwntype

1s not

defined on brkd\'fntypes, an error is generated.

brkd\-intypes currently contains

entries for TIME, CONSES, PAGEFAULTS, BOXES, and

FBOXES~

More Accurate Measurement

Occasionally, a function being analysed is sufficiently fast that the overhead
involved in measuring it obscures the actual time spent in the function.

If

the user were using time, he would specify a value for timen greater than 1 to
give greater accuracy.

A similar option is available for breakdown.

-Tho user

~-----------------------------------------~------~--------------~~-------------

For more accurat'e measurement, the form for ·TIME in INTERLISP-10
(CLOCK 2) but (ASSEMBLE NIL (JSYS 206) (SUB 1 , GCJIMH.
. ,,

21.7

is not

*

can specify that a function(s) be executed a multiple number of times for each
measurement, and the average value reported, by including a number in tho list
of functions given to breakdown, e.g., BREAKOOWN(EDITCOM EDIT4F 10 EDIT4E EQP)
means normal breakdown for editcorn and edit4f but executes (the body of) odit4o
and

£gQ

10 times each time they are called.

measured must not cause any harmful side
than once for each call.

effec~s.

Of course,

the functions so

since they are executed more

The printout from results will look the same as

though each function were run only once, except that the measurement will be
more accurate.

21.3

Edita 10

Edita is an editor for arrays.

However, its most frequent application is in

editing compiled functions (which are also arrays in INTERLISP-10), and a great
deal of effort in implementing edita, and most of its special features, are in
this area.

For example,

~knows

the format and conventions of INTERLISP-10

compiled code, and so, in addition to decoding instructions a la DDT, 11 edita
can

fill

ref~rences

in the appropriate COREVALS,

symbolic names for ·index reg is tors,

to literals, linked function calls, etc.

The following output shows

a sequence of instructions in a compiled function first as they would be
printed by DDT, and second by edita.



1a·-------------------~-----------~-~--------------------·--------------------ed1 ta was written by \./, Teitelman, and modified by D. C. Lewis. That
portion of edita relating to compiled code may or may not be available in
implementations of INTERLISP other than INTERLISP-10 •
11

DDT is one of the oldest debugging systems still around.
For users
unfamiliar with it, let us simply say that !!!lli was patterned after i t
because so many people are familiar with it.

21.8

466716/
466717/
466 720 I
466721/
466722/
466723/
466724/
466725/
466726/
466727/
466730/
466731/
466732/
466733/
466734/
466735/
466736/
466737/
466740/
466741/
466742/
466743/

PUSH 16, LISP&KtHL
PUSH 16, LISP&KNIL
HRRZ 1,-12(16)
CAME 1, LISP&KNIL
JRST 466724
HRRZ 1,@467575
PUSH . 16, 1
LISP&IOFIL,,467576
-3 .. -3
HRRZ 1,-14(16)
CAMIJ 1,467601
JRST 466734
CAME 1,467602
JRST 466740
PUSH 16,467603
PUSH 16,467604
LISP&FILEN,,467605
JRST 467561
CAME 1,467606
JRST 466754
HRRZ 1,@-12(16)
PUSH 16,1

3/
4/
5/
6/
71
8/
9/

10/
11/

12/
13/
14/
15/

16/
17/
18/
19/

20/
21/
221
231

24/

PUSH PP,KNIL
PUSH PP,KNIL
HRRZ 1,·lO(PP)
CAME 1,KNIL
12
JRST 9
HRRZ 1.@ BRKF ILE
PUSH PP,1
PB IND I BRKZ
-524291
HRRZ 1,-12(PP)
CAMN 1, 'OK
JRST 17
CAME 1, I STOP
JRST 21
PUSH pp. I BREAK 1
PUSH PP, '(ERROR!)
CCALL 2,'RETEVAL
JRST 422
CAME 1, 'GO
JRST 33
HRRZ 1,@-10(PP)
PUSH PP,1
I

Therefore, rather than presenting edita as an array editor with some extensions

for editing compiled code, we prefer to consider it as a facility for editing
compiled code, and point out that it can also be used for editing arbitrary

arrays.

Overview

To the user, edit a looks very much like DDT with INTERLISP-10 ex tens ions.
is

a

function

of one argument,

the name of the function

It

to be edited . 13

Individual registers or cells in the function may be examined by typing their
address followed by a slash, 14 e.g.

12----------------------------------------------------------------------------Note that edi ta prints the addresses of cells contained in the function
relative to--ui"eorigin of the function.
13

An optional second argument can be a list of commands for cdita.
then executed exactly as though they had come from the teletype.

14

Underlined characters were typed by the user.
edit a uses its own read
program, so that it is unnecessary to type a space before the slash or to
type a carriage return after the slash.

21.9

These are

6/

HRRZ 1,-10(PP)

The slash is really a command to edita to open the indicated register . 15 Only
one register at a time can be open, and only open registers can be changed. To
change the contents of a register, the user first opens it, types the new
contents, and then closes the register with a carriage-return, 16 e.g,

CAME 1, It

CAMN 1,

't~

If the user closes a register without specifying the new contents, the contents
are left unchanged.

Similarly, if an error occurs or the user types control-E,

the open register, if any, is closed without being changed.

Input Protocol

Edita processes all inputs not recognized as commands in the same way.

If the

input is the name of an instruction (i.e. an atom with a numeric OPD property),
the corresponding number is added to the input value being assembled, 17 and a
flag is set which specifies that the input context is that of an instruction.

The general form of a machine instruction is (opcode ac , @ address (index)) ns
described in Section 18.

Therefore, in instruction context, edit a evaluates

all atoms (if the atom has a COREVAL property, the value of the COREVAL is

j5·---------------------------------------------------------------------------edi ta also converts absolute addresses of cells within the function to
relative address on input. Thus, if the definition of foo begins at 85660,
typing 6/ is exactly the same as typing 85666/.
-

16

Since carriage-return has a special meaning, !J!!!! indicates the balancing
of parentheses by typing a space.

17

The input value is initially 0.

21.10

used), and then if the atom corresponds to an !!£, 18 shifts it left 23 bits and
adds it to the input value, otherwise adds it directly to the input valuo, but
performs

the

arithmetic

in

the

low 18 bits. 19 Lists

interpre-ted

are

ns

specifying index registers, and the value of .£!!.!: of the list (again COREVALs
are permitted) is shifted left 18 bits.

PUSH
HRRZ
. CAME
JRST

Examples:

PP, KNIL
1,·10(PP)
1, 'GO
33 ORG

20

The user can also specify the address of a literal via the ' command, seo pago
For

21.14.

HRRZ 1,

Ill

example,

if

the

literal

" UNBROKEN"

is

in ·cell

85672,

UNBROKEN" is equivalent to HRRZ 1, 85672.

When the .input context is not that of an instruction, i.e. no OPD has be on
seen, all inputs are evaluated (the value of an atom with a COREVAL property is
the COREVAL.) Then numeric values are simply added to the previous input value:
~on-numeric values become the inp~t value. 21

The only exception to the entire procedure occurs when a register is open that
is in the pointer region of the function, .i.e. literal table.

In this case,

is----------------------------------------------------------------------------1. e. if a ',' has not been seen, and the value of the atom is less than
1~.

and

the low 18 bits of the input value are all zero.

19

If the absolute value of the atom is greater than 1000000Q. fi.J 11 word
arithmetic is used. For example, the indirect bit is handled by simply
binding @ to 20000000Q.

20

edita cannot in general know whether an address field in an instruction
that is typed in is relative or absolute. Therefore, the user must add
ORG, the origin of the function, to the address field himself. Note that
edita would prtnt this instruction, JRST 53 ORG, as JRST 53.

21

Presumably there .is only one input in this case.

21.11

atomic inputs are not evaluated.

For example, the user can change the literal

FOO to FIE by simply opening that register and then typing FIE followed by
carriage~return,

e.g.

FOO
Note that this is equivalent to 'FOO/

FOO

(QUOTE FIE))

Edita Commands and Variables
) (carriage-return)

If a register is open · and an input was t~_QOd,
store the input in the register and ~lose it.
If a .register is open and nothing was typed, close
the register without changing it.
If.' a register is not open and input was typed,
type its value.

the value of the address of the first
instruction in the function. i.e .. loc of gctd of
the function.

ORG

Has

I

Opens the register specified by the low 18 bits of
the quantity to the left of the /, and types its
contents. If nothing has been typed, it uses the
li;lst thing typed by edita, e.g.
~

JRST 53

L

CAME 1,'RETURN

If. a register was open,
changing its contents.

I

!..
closes

RETURN
it

without

After a I command, edita returns to that state of
no input having been typed.
tab (control-I)

Same as carriage-return, followe·d by the address
of the quantity to the left of the tab, e.g.
35/

JRST 53

tab

22----------------------------------------------------------------------------If the register is in the uhboxed region of the function, the unboxed value
is stored in the register.

Zt.12

53/

CAME 1, 1 RETURN

Note that if a register was open and input was typed, tab will change tho open
register before closing it, e.g.

35/
54/
35/

JRST 53
JRST 70
JRST 54

JRST 54 tab
~

. (period)

has the value of the address of the current (last)
register examined.

line-feed

same as carriage-return followed by (ADOl .)/i.e.
closes any open register and opens the next
register.

f

same as carriage-return followed by

SQ (alt-modeQ)

has as its value the last quantity typed by ectita

~SUBl

.)/

e.g.

35/

./

JRST 53
JRST 54

~

LITS

has as value the (relative) address of the first
literal.

BOXED

same as LITS

$

(dollar)

has as value the relative address
literal in the function.

=

of

the

last

Sets radix to -a and types the qunn ti ty to the
left of the = sign, i.e. if anything has boon
typed, types the input value, otherwise, types SQ,
e.g.
35/

JRST 54

=254000241541Q JRST 54=254000000066Q

Following =, radix is restored and edi ta returns
to the no inpu""'tS'iate.
OK

leave edita

?

return to •no input• state.
? is a
•weak'
control-E, i.e. it negates any input typed, but
does not close any registers.

21.13

addressl, address2/

prints 23 the contents of registers
Mldross 1
through address2. . is set to adclress2 aftertii-o
completion.

'x

corresponds to the ' in LAP. The noxt oxprossion
is read, and i f it is a small number, the
appropriate offset is added to it. Otherwise, tho
literal table is searched for x, and the value of
•x is the (absolute) address -of that coll.
An
error is generated i f the 11 tertil is not found,
i.e. 'cannot be used to create literals.

:atom

defines atom to an address
(1) the value of SQ if a register is opon,
( 2) the
input if any input was typed,
otherwise
(3) the value of 1 ' 24
For example:

35/
:FIE.?

FIE/

Edita

keeps

Users;:cms

its symbol

JRST 54

:FOO,?

JRST FOO ..:...:,35

tables on two free variables,

usersyms

and

is a list of elements of the form (name . value) and is used for

encoding

input,

i.e.,

all

variables

on

usersyrns

are

bound

to

corresponding values during evaluation of any expression inside edita.
is a

symlst.

list of elements of the form (value

tho i r
Sym1st

name) and is used for decoding

addresses.

Usersyms is initially NIL, while symlst is set to a list of all the

corevals.

Since the : command adds the appropriate information to both these

two lists, new definitions will remain in effect even if the user exits from
edita and then reenters it later.

Note that the user can effectively define symbols without using the

conunand

23----------------------------------------------------------------------------output goes to file, initially set to T. The user can also set file (while
in edita) to the name of a disc file to redirect the output. (The user is
responsible for opening and closing file.) Note that file only affects
output for the addressl, address2/ command.
-24

Only the low 18 bits are used and converted to a relative address whenever
possible.

21.14

by appropriately binding user.syms and/or

SYJ:llSt

before calling edita.

Also, ho

can thus use different symbol tablas for different applications.

$W (alt-modeW)

search command.

Searching consists of comparing the object of the search with the contents of
each register, and printing those that match, e.g.
HRRZ @ $~/,)
8/
HRRZ 1,@'BRKF!LE
23/ HRRZ 1,@-lO(PP)
28/ HRRZ 1,@-12(PP)
The $W corrunand can be used to search either the unboxed portion of a . function.
i.e. instructions, or the pointer region, 1.e. literals, depending on whether
or not the object of the search ls a number.

If any input was typed before the

$W, it will be the object of the search, otherwise the next expression is road
and used as the obje~t. 26 The user can specify a starting point for the ~earch
by typing an address followed by a

1 , 1

before calling

$\:/,

e.g. 1, JRST $W. If

no starting point is specified, the search will begin at 0 if the object is a
number, otherwise at LITS, the address of the first literai. 26 After the search
is completed,

I

.

I

is set to the address of the last register that matched.

If the search is operating in the unboxed portion of the function, only those
fields (i.e. instruction, ac, indirect, index, and address) of the
contain one bits are compared. 27 For example, HRRZ

@

obje~t

that

$W will find all instances

25----------------------------------------------------------------------------Note that inputs typed before the $W will have been processed according to
the input protocol, i.e. evaluated; inputs typed after the $W wi 11 not.
Therefore, the latter form is usually used to specify searching the
literals, e.g. SW FOO is equivalent to (QUOTE FOO) SW.

26

27

Thus the only way the user can
specify the starting point via

se~rch

the pointer region for a number is to

·~·

Alternately, the user can ,specify his own mask by setting the variable mask
(while in edita), to the appropriate bit pattern.

21.15

of HRRZ indirect,

regardless of ac,

index, and address fields.

Similarly,

''PRINT SW will find all instructions that reference the literal PRINT. 28

I f the search is operating in the pointer region,

the editor.

For example, SW

consisting of a

sin~le

a 'match' is as defined in

will find all registers that contain a list

(&)

expression.

SC (alt-modeC)

like SW except only prints the first match, thon
prints the number of matches when the search
finishes.

Editing Arrays
Edi ta is called to edit a function by giving it the name of the function.
Edita can also be called to edit an array by giving it the array as its first
argument, 29 in which case the following differences are to be noted:

1.

decoding - The contents of registers in the unboxed region are boxed
and

printed

as

numbers,

i.e.

they

are

never

interpreted

ns

instructions, as when editing a function.

2.

addressing convention -

~hereas

0 corresponds to the first instruction

of a function, the first element of an array by convention is element
number 1.

28----------------------------------------------------------------------------The user may need to establish instruction context for input without giving
a specific instruction.

For example, suppose the user wants to find all
instructions with ac=l and index=PP. In this case, the user can give & as
a pseudo-instruction, e.g. type & 1, (PP).
29

the array itself, not a variable whose value is an array, e.g. (EDITA FOO),
not ED IT A( F00) .

21 .16

3.

input protocols - If a register is open, lists are evaluated, atoms
are not evaluated (except for $Q which is always evaluated).

If no

register is open, all inputs are evaluated, and if the value is a
number, it is added to the 'input value'.

4.

left half - If the left half of an element in the pointer region of an
array is not all O's or NIL, it is printed followed by a ;, e.g.
10/

(A B) ; T

Similarly, if a register is closed, either its left half, right half,
or both halves can be changed, depending on the presence or absence,
and position of the ; e.g.
(A B) ;

If

:

,.

!1.i.1. changes left

B

T

NIL)

B

NIL

A

A

c

changes right

c,?

changes both

is used in the unboxed portion of an array, an error will bo

generated.

The SW command will look at both halves of elements in the pointer region, and
match if either half matches.

This ends the section on

Note that SW A ; B is not allowed.

!911!·

21.17

""

21.4

The

Interfork Colllr.lunication in INTERLISP•tO

functions

INTERLISP-10)

described

below

permit

two

forks

(one

or

both

of

thom

to have a corrunon area' of address space for corrununication by

providing a means of assigning a block of storage guaranteed not to move during
garbage collections.

getblk[n]

-

Creates a block n pages in size (512 words por
page).

'

Value is the address of the first word in

the block, which is a multiple of 512 since the
block will , always begin at a page boundary.
not enough

pages are

available,

generates

If

the

error ILLEGAL OR IHPO~SIBLE BLOCK.
1tlote: the block. can be used for s tori.no unboxed numbers £.!!lll.

To store a number in the block, the following function could be used:

(SETBLOCK (LAMBDA (START N X) (CLOSER (IPLUS (LOC START) N) X]
Some boxing and unboxing can be avoided by making this function compile opon
via a substitution macro.

Note: aetblk should be used sparingly since several un~ovable regions of memoru
can make it difficult or impossible for the garbage collector to find a
contiguous region large enough for expanding array space.

relblk(address;n]

releases a block of storage beginning at address
and

extending

for

n

pages.

Causes

an

error

ILLEGAL OR IMPOSSIBLE BLOCK if any of the range is
not a block.

21.18

Value is address.

Subsys 30

21.5

Th is sect ion describes a function,

sub sys, which permits the user to. run a

TENEX subsystem, such as SNDMSG, SRCCOM, TECO, .or even another INTERLISP, from
inside

of

an

INTERLISP. without

destroying

the

latter.

In

porticulor.

SUBSYS( EXEC) will start up a lower exec, which will print the TENEX herald,
followed by @.

The user can then do anything at this.exec level that;he can at

the top level, without affecting his superior INTERLISP.

For example, he can

start another INTERLISP, perform a sysin, run for a while, type a control·C
returning him to the lower exec, RESET, do a SNDMSG, etc.

The user exits from

the lower exec via the conunand QUIT, which will return control to suhsys in the
higher INTERLISP.

Thus with subsys, the user need not perform a sysout to savo

the state of his INTERLISP in order to use a TENEX capability which would
otherwise clobber the core image.

Similarly, subsys provides a way of chocking

out a sysout file in a fresh INTERLISP with out having to commandeer another
teletype or detach a job.

While subsys can be used to run any. TENEX. subsystem directly, without going
through an intervening exec, this procedure. is no,t recommended.
that control-C always returns control to the next highest exec.

The problem is
Thus if the

user is running an INTERLISP in which he performs SUBSYS(LISP), and then typos
control-C to the lower INTERLISP, control will be returned to the exec abovo
the first

INTERLISP.

INTERLISP, 31
@RESET).

The natural REENTER C()nunand would then clear the lowor

but any files opened by. it. would remain open (until

the noxt

If the user elects to call a subsystem directly. he must therefore

ao·--·------------------~---------------------·-·-----------------------------subsys was written by J. \./. Goodwin. It is TENEX dependent and may not be
available in implementations of INTERLISP other than INTERLISP·l~.
31

A CONTINUE command however will return to the . subordinate progr:am,
control-C followed by CONTINUE is safe at any level~

21.19

i.e.

111

ft

know how it is normally exited and always exit from it that way. 32
Starting a lower exec does not have this· disadvantage, since it can onl v ho
exited via QUIT,
again~t

i.e.,

the lower exec is effectively 'errorset protected'

control-C.

subsys[file/fork;incomfile;outcomfile;entrypointflgJ
If

file/fork=EXEC,

otherwise

starts

up

subsys[SNDMSG),subsys[TECOJ etc.

can

exoc,
e.g.

subsys[) is sarno

Control-C always returns control

to next higher exec.
INTERLISP

lower

<SUBSYS>'system,

runs

as subsys[EXECJ.

a

be

Note that more than one

stacked,

but

there

is

no

backtrace to help you figure out where you are.

incomfile

and

outeomf ile

provide

specifying files for input and output.

a

way

of

incomfi lo

can also be a string, in which case a temporary
file is

created; and the string printed on it.

entrypointflg may be START, REENTER, or CONTINUE.
NIL is equivalent to START, except when .. fi lo/fork
is a handle (see below)

in which case

NIL

is

equivalent to CONTINUE.

The value of subsys is a large integer which is a handle to the lower fork.
The lower fork is not reset unless the user specifically does so using kfork,

ii---------------------------------------------------------------~------------INTERLISP is exited via the function logout, TECO via the command ;H,

SNDMSG via control·Z, and EXEC via QUIT.

21.20

e. subsys. 34 Must be the exact same large number. ~· Note that i f the usor neglects to set a variable to the value of a call to subs~s. also that calls to subsys can be stacked. 33 If subsys is given.e. i. and within that INTERLISP. Note that i f the user starts a lower EXEC.described below. calls and to EXEC. will not work). 21. corresponding TECO. whon nothing in the INTERLISP system points to it.H. LISP. subsys[T] continues the last subsystem run. i f he subsequently continues this EXEC with subsys. are all CONTIN LISPXHACROS is a which LISPXMACRO perform which the performs subsys[TJ. Note that the fork is accessible while the handle remains on the history list. that subsys[ TJ .. for convenience. control-C's from the INTERLISP. it continues the subsystem run by that call. described in Section 22. the user can run a lower INTERLISP. he can still continue this subsystem by obtaining the value of the call to ~·-L~ for the history list using the function valueof. For example. i. as its first argument the value of a previous call to sub sys. the user can do (SETO SOURCES (SUBSYS TECO)). (and has performed an intervening call so . etc. yet another. and ascend the chain of INTERL ISPs using logout. in which· he runs an INTERLISP. For example. load up the TECO with a big source file. ~5------------------------------------~---------------------------------------- The fork is also reset when the handle is no longer accessible. where he will find his file loaded and even the TECO pointor position preserved. thereby continuing the last subsys. massage the file. SNDMSG. Note. run INTERLISP for nwhilo (possibly including other calls to subsys) and then perform (SUBSYS SOURCES) to return to TECO. then QUIT from the EXEC. and then descend back down again using subsys. leave TECO with .. 34 . 21 . he can reenter or continue the INTERLISP. using subsys.

were written by J.COM:O)). Value of If ~ fil. (FILDIR (QUOTE *. illll returns a string loads (unboxed) values of acl.kfork[ fork] accepts a value from subsys and kills it (RESET in TENEX terminology). an error is is generated. 21.g. + jsys(n. 0 is is the (boxed) contents of ~~----------------------------------------------------------------------------All of the functions in section 21. ac2. 21 . list of a la the TENEX DIRECTORY command.. ac2.6 Niscellaneous Tenex Functions in INTERLISP·t0 36 fildir[filegroup] filegroup is a TENEX file group it can contain stars. and executes TENEX + JSYS number N.MNEMONICS). fil=NIL means most recent the error. e. + used. or ac3=NIL.acl:ac2. Goodwin.5. subsequently subsys[ fork] If performed.e. fildir returns a the files which match filegroup. loadav[ ) returns TENEX current load average as a floating point number (this number is the first of tho three printed by the TENEX SYSTAT command). except for tenex. i. kfork[T] kills all outstanding forks (from this INTERLISP).\J. and ac3 TENEX error diagnostic as (from <SYSTEM>ERROR. descrip~or.22 .ac3. erstr[ern] l l i is an error number from a JS\'S fail return.resultac] + into appropriate accumulaters.

e. and firstnarne to the name used in the greeting. if ~=T. the value is a string. Note: greeting (see Section 22) sets the variable username to the login user name.the accumulator specified by resultac. usernumber[a] If !=NIL. means acl. number.· usernumber returns the number of the corresponding user. and then unreads ill• followed by "QUIT" (using bksysbuf. if ! is a literal atom or string. 1 + with NIL + equivalent to 1. returns login user number.g) structure. For example. the LISPXMACRO SY which does a SYSTAT is implemented simply as TENEX["SY1 11 ] . if ! user ~=T. returns connected user number. i f returns connected directory name. is a name In all cases.7 Printing Reentrant and Circular List Structures A reentrant list structure is one that contains more than one occurrence of the same (!!. 2 means ~.23 . username[a] + If !=NIL. or NIL if no such user exists. and 3 moans ac3. tenex[str] Starts up a lower EXEC (without a message) using subsys.ill (Section 6) makes uses of reentrant list structure so that it does not have to search for the end of the list each 21. described in Section 14). 21. i. username returns the corresponding to that user number. !£. For example. returns login directory name.

and if applied to: 21. Note that print would produce the same output for the non-reentrant structure: c A c B FIGURE 21-2 In other words. list structure (a Similarly. (ABC). the reentrant list structure used by 1£.time it is called. being constructed by lli!l£.24 . print does not indicate the fact that portions of the structure in Figure 21·1 are identical. if ~ is a list of 3 elements. Thus. if print is applied to a circular special type of reentrant structure) it will never terminate. if print is called on the structure: FIGURE it \vill prtnt an 21-~ endless sequence of loft parentheses.Q. For example.!1£ for this riurposo is: A B FIGURE 21-1 This structure would be printed by print as ((ABC) C).

Below are of the expressions that circlprint would produce This a few to describe the structures discussed above. {1}) (A • {1}) 1 36----------------------------------------------------------------------------Circlprint and circlmaker were written by P. 21. expression in Figur~ 21-1: single-line: ((A B *11'1 C) {1}) double . Jackson. The function circlprint described below produces output that will exactly describe the structure of any circular or reentrant list structure..FIGURE 21-4 will print a left parenthesis followed by an endless sequence of A's. c. line: ((ABC) • {1}). 1 expression in Figure 21-3: single-line: double-line: (*1* {1}) ({1}) 1 expression in Figure 21·4: single-line: double-line: (*1* A •.25 . 36 output may be examples in either single or double-line formats •.

Finally. first and then calls either rlprinl[ list J or rlprin2[ list]. (3}) .26 . {3}) . is circlprint If used. An occurrence of a reentrant node that has already been identified is indicated by printing its label in brackets. calls circlmark[li~t:rlknt]. the label is printed between asterisks at the beginning of the node (list or tail) that it identifies.The more complex structure: A FIGURE 21-5 is printed as follows: single-line: double-line: (*2* (*1* {1} *3* {2} A *4* B .!. list. In the double-lino format. {4}) ( ({1} z 1 In both formats. numbers. (4)) 4 the reentrant nodes in the list structure are labeled by reentrant node is one that has two or more pointers coming into In the single•line format.rlknt] prints an expression describing printflg=NIL. respectively). depending on tho value of printflg (Tor NIL. the label is printed below the beginning of the node it identifies. 21. Value is list. which restores .printflg. format double-line otherwise single-line format.) (A {i} A 3 B . rlrestore[listJ is called.!! to its unmarked state.!. circlprint[list. it.

rlprin2[ list] same as rlprin1. (•t• . necessary rplaca•s and rplacd 1 s to make list. circlmaker performs the e. tho In addition. by making several calls to circlmark. describing list is except that printed in expression the the double-lino format. e. unmarked state.rlknt] marks each reentrant node in 1 ist with a uni quo number. list always be restored by specifically calling rlrestore. circlmaker[ list] list may contain labels and references following the convention used by circlprint for printing reentrant structures in single line format.g. marking is performed undoably. rlrestore[ list) physically restores list to its original. followed by calls to rlprinl or rlprin2. NIL).27 Value is (altered) list. describing list in tho Does not restore list to its !ill must previously havo been circlmarked or an error is generated. uncirclmarked state. rlprin1[ list] prints an expression single-line format.g. several property lists. correspond to the indicated structure. Note that the user can mark and print several structures which together share common substructures. can rlknt · 1s if However. Marking 1 ist physically alters it. Value is (new) rlknt. .circl~ark[list. starting at rlknt+1 (or 1. and finally to rlrestoro. {1}). 21.

chasing all pointers down to the level of atoms.. for dtsplautng complex list printing them so that the user can look at them (al though Hprint 37 is a package for printing and rending (possibly re-entrant or circular). or arb 1 trary unboxed numbers. ~L Nasinter. hash tables. compiled code arrays. When it + --~-----------------~~--~-~----~-----~-~--~--~-~~~----------------------------37 for !:!orrible PRINT. labelst and circlmakerl. or - list an array Hprint currently cannot handle . + circlmaker can be used in conjunction with read for dumping and reloading + re-entrant list structures).. + 38 circlprint e. The user can .e.s and corresponding nodes. stack positions.g. and then calling It generates an error i f reflst is not NIL when circlmaker1 returns. The hprint package was written by L.circlmaker1[1ist] Does the work for circlmaker.s·or strings. + operates by simulating the INTERLISP print .. several property lists. + correctly print and read back in any structure containing any or all of the + above. + back in more general data structures that cannot normally be dumped and loadod + easily.28 . labelst and reflst. 1. + Hprin t + structures.structures containing user arrays. e. number. Circlmaker operates by initializing reflst to NIL. as well as Ust structures. call circlmakeri directly to "connect up" several structures that share common substructures. + Dumping Unusual Data Structures + The + structures. Uses free variablos labelst is a list of dottod pairs of label.· 21.g. package is designed primarily. ref ls t is a list of nodes containing references to labels not yet seen. + datatypes. routine for encounter~ normal a user datatype (see section 23). 38 Hprint will '.

since tho algorithm depends on being able to reset the file pointer.values of var i + . HORRIBLEVARS is a prettydef macro for saving and loading the ·value of 'horrible' variables. file] prints ~ on file. + is occurrences inserted before are printed as the first a back occurrence. + 39----------------------------------------------------------------------------by resetting the file pointer using sfptr. 40 Note: hprint is intended primarily for output to disk files. surroullded by spec i«l While chasing + the pointers of a list structure. • var 11 when the file is loaded. 40 hread[file] reads an hprint-ed expression from file. ! is printed on it. a temporary file is opened. A + prettydef command of the form ( HORRIBLEVARS var 1 . hread merely calls the INTERLISP road + routine with the appropriate readtable. . so + that they may contain cross references to· common + structures. 39 reference using and an all subsequent appropriate + macro + character. If f!le is not a disk file. 21.or hash array. it also keeps a hash table of those items it + encounters. . var 11 ) + will cause appropriate expressions to be written + which will restore the . and then that file is copied to the final output file. and if any item is encountered a second time. + hprint[x. characters it prints the data contained therein. Thus the inverse function. so that reading time is only a function + of the complexity of the structure. The values of var i var 0 are all printed by the same operation.29 + + + + + . . another read-macro + character defined as read-macro characters (see section 14).

42 dribble also takes an extra argument.e.appendflgJ41 file is a 1 transcript 1 of all·· of the input and output on a Opens filename and begins recording tho + typescript. 42 dribble[] + closes the typescript file. the typescript wi 11 + be appended to the end of· filename. i. (Thus the first time it is called. 43 + dribble operates by redefining all of the various input and output functions. + dribble[filename. C. there will bo + a noticable delay before· it returns. + + generated by TELNET because it does not show characters that i.e.30 If thawedflg=T. can be active at any one point. will be opened in "thawed" mode. Lewis.8 Typescript Files + A typescript + terminal. + + + t~at The typescript produced is somewhat 21.) + neater than + were erased via control-A or control-Q. 48 Only one typescript file . + actually returned by the various input functions. the only input shown is that 4i--------·------~------------------------------M·------------------------------ dribble was written by D.+ 21. + and then relinking the world. dribble[ file1 J followed by dribble[ file2J will cause filel to be closed. thawedflg. · 1f appendflg=T. The following function enables transcript files for INTERLISP. the file .

....•...•••••• machine instructions ..13 21....... carriage-return (edita command/parameter) ...... 21 21....8-17 21....•.••....4 21.••..••••............4 21...18 21.......3 21..•......10-11 21. I •••••••••••• I • I •.••...18 21...••••••..••• FIRSTNAME (system variable/parameter) ...•.19 21...•..............•.••. 21 21..•.....10 21. BOXCOUNT[TYPE..•••••...12 21..• •. fork handle .• JS YS . ~ ••.13 21.•...... e e • • e • ..28 21.•..6-7 21......AC3.••••..•.•....•••••••••• JSYS[N.•.28 21...3 21..4..••• LISPXMACROS ........•. 7 21................•.•.10-11 21.• BRKDWNTYPE (system variabl~/parameter) .. • .N] SUBR •••••••••••••••••••••••• .......•....8-17 21. cornrn ( prog..... .•••....•.21 21.ERRFLGJ EXEC ••......•..........•••.... LISP (prog....29 21..•.. 19-20 21. •• BOXED (edita corrunand/parameter) . • • • • • • I • • e I • • I • e e • 1 e I I I I •......... ... ............•....•••••••••••..•...•.. DRIBBLE[ FILE..• CIRCLPRINT[L.... • • • • • • • • ••••••••• ILLEGAL OR IMPOSSIBLE BLOCK (error message) interfork communication ...••.......• ••• I I ••••••••••• line-feed (edita command/parameter) ..... ORG (edita command/parameter) •••••.. FILE ( edi ta command/parameter) •••..•... dumping unusual data structures .... command) .......•• I •••••••••••••••• I ••••• I •••• EXEC (prog..23 21.12 .. BREAKDOWtJ[ HIS] NL"' ......•. BRKDWNTYPES (system variable/parameter) ..•.•••.•• 01sr11ss[t~J ........RLKNT] ..........•.... command) ...14 21..21..•............•..•.....•...••.8-17 21.22 21.21 '21.....••....••. .18 21.......13 21.... F I LE J • ...••.••• control-B control-C control-D control-E ...•.... editing arrays ..21..•••.....••.••..••.•............••••.......FORMATFLG] ..... asst........••• OPD (property name) .......•...20 21....•• OK (edita command/parameter) ••. ..•...27 21... .•. COIHIIWE ( tenex command) ......•. command) ......•.•••••••.•..........5.....••....•.. ...................COMS] .•.23 21...•..••••••••• INDEX.•...•..10.....•.... forks ..•.•.••.•.....RESULTAC) SUBR• KF........••••••••••••....•.....•.13 21.••.....8 21......••• ..•...•....•.••. • • • • • • ..10 21.••••.. l 21..........5-8 21....•.•..•...•..••.............•.•... MASK ( edi ta command/parameter) •..21 21.....•.•.•• LOADAV[ ] .•. editing compiled code eq e • • e • e • • • • • • e e • ERSTR[ERN.. GETBLK[l1] SLIBR •••••••••••••••••••••••••••••••••• HORRIBLEVARS prettydef macro ... ...22 21. LITS ( edi ta command/parameter) ..•..••..••••...••....••.. Hp Rnn [ Exp R ..••.••.••.15 21.••••••.•.....••....... ... .AC2..... .••••••••.• DDT[] SUBR .•....••.4 21.•. EOITA[EDITARRY.. ..•.•.......•. .•.•. ..25-26 21.••...•••••.18 21............... • • • ........Index for Section 21 Page Numbers BKS YSBUF [ X] SUBR .....•...4 21......... THAWEDFLG) ...... asst.......•... DATE[] SUBR ...3 21.............. .PRINTFLG......•.•......... •...•...AC1.••..• CIRCLMAKER[ L] .••.•....•....••........•••.......22 21..22 21...4 21...23 21... asst...... ..•....... COREVAL (property name) .... ..•....•.•.5..4 21...•.23 21....••..•. CLOCK[ NJ SUBR ••••••••••••••••••••••••••••••••••• COl~SCOUIH[ I~] SUBR .............30 21.•..3-4.ORK[ FORK] ....••.20..22 21..•...22 21........... LOGOUT[ ] SUBR I • I ••••••••••••••••••••••••••• •......•..••... FILDIR[FILEGROUP.5.•.....GCTRP[N) SUBR ••••••••••••••••••••••••••••••••••• GC: 8 (typed by system) ..... .....••••••.. APPENDFLG.

..14 21.....•••.N] SUBR ••..••••••• .23 21.••......5..•••••••••••. asst....••.13 21.•.....••.. asst.•• ••••...•••.•..••• TIME[TIMEX.....28 21..17 21...•..••.••.. .TIMEN.19 21.. ..•••••...•.• SYS TAT •.•••.5...23 21.10 21.. $Q (alt-modeQ) (edita command/parameter) •......•.21 ························•········· S (dollar) (edita command/parameter) ..•••. 21..•. (edita command/parameter) .••..•.•.•.•..16 21...18 RESULTS[ ] .•••..•.... ..17 21.••• SUBSYS[FILE/FORK.....•••••••••••.•.••••••••• tab (edita command/parameter) .TIMETYP] NL .30 21..19·21 REENTER ( tenex command) •.22 21..••..13 21....... (edita comr:1and/parameter) ••. ? { edita corrunand/parameter) @ (edita corrunand/parameter) •••••.•••• ~ ·21.•....OUTCOMFILE..•.••....•.... • ••..••••••• t (edita conunand/parameter) INDEX. ..••..•••••• .••..••....10 21.• .23-29 QUIT (ten ex command) •.....••••••• I ......••.•••••••.23 21....INCOMFILE. ..•.30 21.19. .••••• SNDMSG ( prog....•..Page Numbers PAGEFAUL TS[] ..••••••••..... •• SYMLST (edita command/parameter) .•. command) ...2 21.......••.... ..•.•..••••• USERNUMBER[ A] .••••••••••••••••••••••••••• 21..••.••••.••••....•...8 21...•..•...••.• •......• I ( edita command/parameter)· ..23 21..••••••••... 1-2 21..•••.4 printing circular lists ••..•• ...21 21....•.• . (edita command/parameter) .15.• running other subsystems from within INTERLISP saving unusual data structures ......•.. •• ~ ••...••...•••••....•..•.•••..•...••••••....••••• 21.•••••..•••••••....••••••.••.••..12 21..........••••.•..•....••...12 21....• • .•.13 21.•..•...•••...•.••••..•••..14 21..•.14-15 21..• ..•..23 21.•••••••........•••••.•••.••• .•...•....•... TENEX[STR] ..•. ( edi ta cor.. .... •'• .....•.14-15 VALUEOF[X] NL* 21.• = (edita command/parameter) ........••.•........ TECO (prog.•••••.13 .•.•.•••••••••• 21.••.11...•• SC (a 1t-modeC) ( edi ta command/parameter) ..•..•......•..••.•..u:iand/parameter) ..•.6 USERNAME (system variable/parameter) ••.•....•. typescript files UNBREAK[X] NLR USERNAME[ A J ..••••.•.•.. ENTRYPOINTFLG] .•...•• SW (alt-modeW) (edita command/parameter) •.....13 21......•..21 21.••.••••• TELNET TEf~EX .•..10..... ' ( edi ta command/parameter) .•...•. •• 21....••.•.21..•.•••...19 RELBLK[ADDRESS...13 21.••....19·22 21.•• 21. command) .•..•••••••••• USERSYMS (edita command/parameter) ..••... .•.•...

However. and simply carries out the user's requests. the file package. but is instead dispersed throughout much of INTERLISP . e. the user can instruct him to repeat a particular operation or sequence of operations. rather than talking to a passive sxstem which merely responds to ench input and waits for the next. etc. Normally. or to undo the effect of certain specified operations./. one of the newer addit1ons to INTERLISP: tho The central idea of the programmer's assistant is that the user.g. 2 Some of the features of the programmer's assistant have been described elsewhere. the assistant is invisible to the user.SECTION 22 THE PROGRAMMER'S ASSISTANT AND LISPX 1 22. with possible modifications. namely his assistant.1 .IIM. Tei telman. like D\. and free him to concentrate more fully on the conceptual difficulties and creative aspects of the problem he is trying to solve. since the assistant remembers what the user has told him. It is discussed in (Tei4]. the programmor 1 s assistant is not implemented as a single function or group of functions. 22. the prograrruner Is assistant embodies a philosophy and approach to system design whose ultimate goal is to construct a programming environment which would "cooperate" with tho user in the development of his programs. is instead addressing an active intermediary.2 Like owrn. 1 Introduction This chapter describes programmer's assistant. the UNDO command in the editor. 1----------------------------------------------------------------~------------1 The programmer s assistant was designed and implemented by \.

The user plans to replace eath of these by equivalent MOVD expressions. .5 J JI( . .le prefer to consider the programmer's assistant as the moving force behind this type of spelling correction (even though the program that docs the work is part of the DWIM package). and ascends one level [4] to print and result. . which contains several constructs of the form (PUTD FN2 (GETD FNl)).. He then ~hifts context to the third subexpression. . or XTRR to XTR does not require any information about what this user is doing. . Tho user now switches the second and thiid subexpression [5]. the user begins to edit ~.Example The following dialogue. zz. extracts its second subexpressiori. [3).MOVD) *3 ( XTRR 2) [2] [3) lltQP [4] =XTR =O p (MOVD (QUOTE READSAVE) (QUOTE READ)) *(SW 2 3) . gives tho flavor of the progranuner's assistant facility in INTERLISP. EDITF( LOAOFF] =LOADF EDIT •PP [LAMBDA (X Y) [1] [COIW ((NULL (GETD (QUOTE READSAVE))) (PUTD (QUOTE READSAVE) (GETD (QUOTE READ] (PUTD (QUOTE READ) (GETD (QUOTE REED))) (NLSETQ (SETQ X (LOAD X Y))) (@UTD (QUOTE READ) (GETD (QUOTE READSAVE))) X] *F PUTD ( 1 . .. taken from an actual session at the console. At (1). correcting LOAOFF to LOADF clearly required noticing when this user dofinod loadf. thereby completing i------------~-----~--~~------------------------------------------------------\. 3 At [Z) the user finds PUTD and replaces it by MOVD. to edit a The user is about function loadf. Whereas correcting @PRINT to PRINT. [.z . .

[6]. and observes that the second PUTD has now been successfully transformed. *?? FROM -3 19. REDO 22. the user can instruct the assistant to carry out the same operation again by simply saying REDO.the operation for this PUTD. the user hils not directly addressed the assis. [8]. The user now requests that the ass i stiln t print out the operations that the user has performed. Note that up to this point. Note that the entire REDO FROM F operation is now gro~ped together as a single unit. 20. "'(XTR 2) 19. "'?? FROM F [6] 15. (9). This time a problem is encountered [10). l>l(S\. Therefore.3 . 11 20. >llf PUTD 16 .I 2 3) REDO FROM F [9] "'F PUTD •(1 MOVD) n3 •(XTR 2) "'0 it(SW 2 3) nREDO PUTD 1 [ 10] It?? -1 [ 11] 22. The user then prints the current expression.I 2 3) 0 "'REDO FROM F [7) lolp (MOVD (QUOTE RE~D) (QUOTE READ)) "' The user now asks the assistant to replay the last three steps to him. and the user thon instructs the assistant to REDO FROM F. meaning repeat tho entire sequence of operations 15 through 20. 17.tant. 21. so the user asks tho assistant what it was trying to do [11]. "' ( 1 MOVD) "'3 18. since it corresponded to a single user request. [8] l!l:Q • ( S\. [7].

4 . and the operation now concludes successfully. (12). as occurs when the operation wa$ incorrect.2).LOADF An important point to n·ote here is that while the user could have defined n macro to execute this operation. trying It is far more natural to decide after a series of operations whether or not one wants them repeated or forgotten. he would already have executed the operation once. At this point. at which point the operation would only be repeated once more before failing. frequently the user will think that the operation(s) in question will never need be repeated. Then the user would have to repair the macro. Thon he would have to type in the steps again to define them as a macro. In addition. and only discover afterwards that he is mistaken.·the operation is sufficiently complicated that he would want to try out the individual steps before attempting to combino them."F PUTD * (1 MOVD) *3 * ( XTR 2) 1110 The user then realizes the problem is that the third PUTO is misspelled in the definition of LOADF (see page 22. [ 12 J *USE @UTD FOR PUTO "p (MOVD (QUOTE READSAVE) (QUOTE READ)) pp ilq [LAMBDA [corm (X V) ((NULL (GETD (QUOTE REAOSAVE))) (MOVD (QUOTE READ) (QUOTE READSAVE] (MOVD (QUOTE REED) (QUOTE READ)) (NLSETO (SETO X (LOAD X V))) (MOVD (QUOTE REAOSAVE) (QUOTE READ)) X] StQK . He therefore instructs the assistant to USE @UTO FOR PUTD. but salvageabl~: 22. or else change @UTD to PUTO by hand so that his macro would work correctly.

(2). of his If anything went wrong. i.not performed that frequently.·and of course there is always the case when diaster strikes as a result of a 'debugged' or at least innocuous operation."'P (LAMBDA (STR FLGCQ VRB) ~~coMMENT"R (PROG & & LPl & LP2 & &)) "'-1 -1 p (RETURN (COND &)) "'(-2 ((EQ BB (QUOTE OUT)) BB] [1] (RE TURN ( ZJ l.u:ier's assistant: of the its UNDO capability.. and are therefore. The user types an expression which removes the property MORPH fro~ every member of the list ELTS [1].5 . This example also illustrates one prograr.'IP (& BB) ( CONO & )) "'UIJDO (-2 --) UNDONE •2 p (COND (EXPANS & & T)) *REDO EQ lllP (COND (& BB) (EXPANS & & T) '/( Here the operation was correct.g. but the context in which it was executed. he would However.ion. --USE ELEMENTS FOR ELTS [3) IHL . ahd then realizes that he meant to remove that property 22. was wrong.f of tho a user suspected that a disaster might result from a particular operat. especially compared to a Short computation. e. he would prepare for this contingency by saving the state of part or all environment before attempting the operation. «n untested program running wild and chewing up a complex data structure. [1). then back up and start over. as shown in the following example: ~(MAPC ELTS (FUNCTION (LAMBDA (X) (REMPROP X (QUOTE MQRPH) [1] fl IL [ 2J --urrno MAPC UNDONE. saving/dumping operations are usually expensive and time consuming.. most useful functio~s In most systems.

i. and thon does what he intended via the USE command [3]. he has deleted a lot of information that he actually wants savod. whore each event corresponds to one user input.e. a much shorter list. plus other optional information such as side-effects. although the user's actual input. REDO FROM f.only from those members of the list ELEMENTS.g. although the latter includes executing the operation (XTR 2).' The history list is a list of the information associatod with each of the individual 'events' that have occurred in the system.3). 22. If the event corresponds to a history command. 22. see page 22 . it will have moro than one value: ~-------------------~-------·----------------~--------------------------------- For various reasons. the history command. is Noto that if a history command event combines several events. and one for liSI??<• which processes inputs to evalgt and break.44.2) is a single event. ( XTR 2) ( [ 3] on pa go 22. saved in order to clarify the printout of that event ((9) on page 22. corresponds to what the user would have had to type to execute the input the samo operation(s). In other words. e.6 .3) is also a singlo event. while REDO FROM F ([7) on page 22. formatting information. there are two history lists: one for the editor.2 Overview The programmer's assistant facility is built around a memory structure callocl the 'history list. Ho therefore simply reverses the effect of the MAPC by typing UNDO (2). 4 For example. otc. as well as· several others. Associated with each event on the history list is its input and its value.

~(LOG (ANTILOG 4)) 4.00007 19.0 4.00007)) -4. 0 2. and the oldest event is 'forgotten.0 ~(ANTILOG 4.0 -4.0 ~CANTILOG 40. 22.0 ~usE 4.0 -4.0 ~USE 4.0 ~(ANTILOG 40.0)) ~(LOG -. -19.o ~usE -4.0 ~CANTILOG 400.0 (LOG (ANTILOG 40.0 (ANTILOG 4)) new events occur.00007 -19. so tho history list is actually a ring buffer.0 40. J 9.0 ARG NOT IN RANGE 400 -4o.0 400. the storage used to represent the forgotten event is cannibalized and reused in the representation of the new event.0)) ~CANTILOG 4. 1.0 ~?? 4.0)) ~(LOG -40.0 ~CLOG (ANTILOG 400)) ~CLOG 4. USE -40. As USE 4.0 (ANTILOG •4. USE LOG ANTILOG FOR ANTILOG LOG IN ·Z ·1 (LOG 4.00007 ~(ANTILOG (LOG 40)) (LOG 400)) (LOG -40.7 The siie of this ring buffer is a .0 LOG ANTILOG FOR ANTILOG LOG IN -z AND ·1 40.0 40 400 FOR 4 4.00007 ~(LOG (ANTILOG -19.0 40 400 FOR 4 ~(LOG (ANTILOG 4.0)) (LOG ·4.0) 40.0)) 19.0 (ANTILOG ~40.00007 •19.00001 -40.00007)) (LOG -19. existing events are aged.' For efficiency.0 3.0)) 4.

The More recent the most:' recent ·event is event number 52. 6 . 16. the 'roll-over' occurs· at the ne~t ·highest' hundred. .54. the user seldom needs really 'ancient history.' and a NAME and Sinco RETRIEVE facility is provided for saving and remembering selected events. on The output page 22. . to an for example. When the event number o'f ·the 'curren't event 15· 100. or (&(EDIT)). descriptor references may require more precision to refer older event. '~ 51.g. or by a 'description' of its input.slice 'can be changed with the function changes lice. For example. RECOMPilE(EDIJ).' but tie up correspondingly greater amounts of storage. page 2?. although their relative positions change. 9 shows a printout of a history list with time-slice numbers printed at the left of the page are the event numbers.' J• Events on the history list can be referenced in a number of ways. As new events occur.a·· . also containing a RECOMPILE. existing events retain their absolute event numbers. its event number. ~.. 6 At this point. in timo. (RECOMPILE (EDIT)). tho oldest and about-to-be-forgotten event is number 37. so that at 'no ·time will two events ever have the same event number. the description RECOMPILE would have sufficed to refer to event 51 had event 52. if the time slice is 150. although some users prefer to set the time slice as large as 100 events. . by . ~----------------·-------~~--------------·------------------------------------Initially 30 events. not intervened. The time':. the Oser can reference event number 51. or even just EDIT. Similarly. a relatively small time slice such as 30 events is more than adequate.iber 1 follows event number 200. event nur. e. •6 Larger time-slices enable lotlgor .) 22.system parameter called the 'time-slice.00. Event specification will be ~escribed in detail later. . its relative position. (If the time slice is greater than 1. ·2 (because it occurred two events back from tho current time). tti"e next event wi 11 bo given number 1. events have higher numbers.'memory spans.

COM . HIST UNDO . o-DEFINEQ((FIE (LAMBDA (X) (MAPC X (F/L (P~INT X)))))) (FIE) 42.before attempting to evaluate an input. GETD(FIE) (LAMBDA (X) (MAPC X (FUNCTION (LAHBOA (X) (PRINT X))))) 44 .COM 51. the assistant first stores it in a new entry on the history list. EDITF(UNDOLISPX) UIWOLISPX 4 7._LOGOUT] 49 . <>-UIJDO MOVD 40..9 . o-DEFINEQ((FOO (LAMBDA (X) X))) (FOO) 37.. The assistant also notes now functions and variables to be added to its spelling lists to enable future corrections. and sees the values printed out.. . the assistant acts much like a standard LISP evalgt. FIE] NIL 43.COM 50 . REDO GETD o-GETO(FIE) ..· where the evaluation. . GETD(FIE) (LAMBDA (X) (MAPC X (F/L (PRINT X)))) 46.. ~RECOMPILE(EDIT) EDIT . . RECOMPILE( UNDO) UNDO. user types in expressions for In this mode.<-?? 52 . REDO GETD +-GETD(FIE) (LAMBDA (Y) Y) 41. +-UIWO FIE 45 .. o-MOVD(FOO FIE) FIE 38. --GETD(FIE) (LAMBDA (Y) Y) The most common interaction with the progranuner's assistant occurs at the top level evalgt. MAKEFILES) (EDIT UNDO HIST) 48 .. .. or in a break.. evaluates the ZZ.. Thus if the operation is aborted