Lynn H, STANFORD ARTIFICIAL INTELLIGENCE LABORATORY OPERATING NOTE 28,6. Quam and Whftflsld Dlffle



Similar documents
1.- L a m e j o r o p c ió n e s c l o na r e l d i s co ( s e e x p li c a r á d es p u é s ).

Chapter 15 Functional Programming Languages

Basic Lisp Operations

Universitetet i Linköping Institutionen för datavetenskap Anders Haraldsson

SCO TT G LEA SO N D EM O Z G EB R E-


How To Program In Scheme (Prolog)

Robot Programming with Lisp

Informatica e Sistemi in Tempo Reale

Campus Sustainability Assessment and Related Literature

H ig h L e v e l O v e r v iew. S te p h a n M a rt in. S e n io r S y s te m A rc h i te ct

Victims Compensation Claim Status of All Pending Claims and Claims Decided Within the Last Three Years

I n la n d N a v ig a t io n a co n t r ib u t io n t o eco n o m y su st a i n a b i l i t y

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

HD44780-Based LCD Modules. Introduction to the LM018L

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Moving from CS 61A Scheme to CS 61B Java

Programming Languages in Artificial Intelligence

Introduction to Python

Programming Languages CIS 443

PROBLEMS (Cap. 4 - Istruzioni macchina)

Microsoft Access 3: Understanding and Creating Queries

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

URL encoding uses hex code prefixed by %. Quoted Printable encoding uses hex code prefixed by =.

Programming languages C

So far we have considered only numeric processing, i.e. processing of numeric data represented

ASCII CODES WITH GREEK CHARACTERS


Introduction to MIPS Assembly Programming

MULTIPLE COMPUTER NETWORKS AND INTERCOMPUTER COMMUNICATION. Lawrence G. Roberts Advanced Research Projects Agency Washington, D. C.

How To Write Portable Programs In C

Utility Software II lab 1 Jacek Wiślicki, jacenty@kis.p.lodz.pl original material by Hubert Kołodziejski

2) Write in detail the issues in the design of code generator.

i n g S e c u r it y 3 1B# ; u r w e b a p p li c a tio n s f r o m ha c ke r s w ith t his å ] í d : L : g u id e Scanned by CamScanner

Solution for Homework 2

Data Integrator. Pervasive Software, Inc B Riata Trace Parkway Austin, Texas USA

Introduction. What is an Operating System?

1. Oblast rozvoj spolků a SU UK 1.1. Zvyšování kvalifikace Školení Zapojení do projektů Poradenství 1.2. Financování

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

C Compiler Targeting the Java Virtual Machine

Lecture 22: C Programming 4 Embedded Systems

Specifications of Paradox for Windows

Typy danych. Data types: Literals:

Semantic Analysis: Types and Type Checking

QUERYING THE COMPONENT DATA OF A GRAPHICAL CADASTRAL DATABASE USING VISUAL LISP PROGRAM

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Mark Scheme (Results) January GCE Decision D1 (6689) Paper 1


COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing

Memory is implemented as an array of electronic switches

Chapter 7D The Java Virtual Machine

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

Advanced Bash Scripting. Joshua Malone

The Cool Reference Manual

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

LABORATORY 117. Intorduction to VoiceXML (2)

Compiler Construction

Lecture 9. Semantic Analysis Scoping and Symbol Table

This chapter describes the specifications of the embedded Ethernet function for Series 16i/18i/21i/160i/180i/210i/160is/180is/210is B.

Solutions to Homework 6

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

The programming language C. sws1 1

This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

Tutorial on C Language Programming

Exercise 4 Learning Python language fundamentals

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.


Example of a Java program

Flash Microcontroller. Memory Organization. Memory Organization

Data Storage: Each time you create a variable in memory, a certain amount of memory is allocated for that variable based on its data type (or class).


6.170 Tutorial 3 - Ruby Basics

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Introduction to Java

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

MACHINE INSTRUCTIONS AND PROGRAMS

Put the human back in Human Resources.

BCD (ASCII) Arithmetic. Where and Why is BCD used? Packed BCD, ASCII, Unpacked BCD. BCD Adjustment Instructions AAA. Example

d e f i n i c j i p o s t a w y, z w i z a n e j e s t t o m. i n. z t y m, i p o jі c i e t o

T c k D E GR EN S. R a p p o r t M o d u le Aa n g e m a a k t o p 19 /09 /2007 o m 09 :29 u u r BJB M /V. ja a r.

13-1. This chapter explains how to use different objects.


Access Queries (Office 2003)

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00


The C Programming Language course syllabus associate level

General Introduction

Portal Connector Fields and Widgets Technical Documentation

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

ACE-1/onearm #show service-policy client-vips

Transcription:

I i STANFORD ARTIFICIAL INTELLIGENCE LABORATORY OPERATING NOTE 28,6 STANFORD LISP 1,4 MANUAL by Lynn H, Quam and Whftflsld Dlffle C ABSTRACTl Thls manual des~rlbes the PDP-10 LISP 1,6 system drvelo~rd by the Stanford ArtIficlaI Intel ligenoe ProJeot, Thr manual Is not a tutorlal on LISP but 18 intended to rup~lement rwirtlng LISP tutor!als In order to Prapare one to undsrstand and use thls LISP system, ~ h f work s was sup~orted by the Advanced Research ProJeots Agency of the Department of Defense under Contract SD483, C The vfehe and conclusions oontalned In thls documant are those of the authors and should not be Interpreted as ne~essarll~ representhe the official pollcles, either erprersed or \mol/ed, of the AdVlnoed Researoh ProJects Agency or the U,S, Government,

PREFACE Thls manual is the result of 8rvrrrl relatlvrl~ mhor ohangrs and a d d l t l ~ n to ~ SAILON 28,41 It SUPer~rdrS and rgpi.~~s SAlLONS ir 4, 2882m4, and 41, The changes refl@ot change8 in LISP and may br oumrnari~rd as fol lowst The rllocrtlon prooedure, and LISP lnltlallzrtfon have been ohangedl S.ctlonr 2,1 and 2,2. There are some new drbugglng fa61 l ltlrs in A P P I ~ ~ N ~ X rnd the fo~umantrtlon for some old ones has been out Into thr manual, The expandsd Appandlx F, cornpi ler has been revlsrd, and Is dasorlbed in r greatly

SAZLON 28,6 LISP 11 Tho STANFORD A,I, Ll8p 1,6 Syttem war orlu~rp(ly an rdrptet Ion of one drva lo~ad by the ~ r1 f t t6hl Int@ l I I~@nar.,ProJ@ot, at M I Slnor 1966, that syrtrfn hrr bran Irr9olv rrwrlttrn by John Allrn and Lynn Quam, John R, A l 1 en Imp l amentad tho storago rrr l looatlon rvrtam whfoh makas f t ~oss\blr for tha u8rr to ahrnma the rlzar of the vat lour momory 8DatQS, He also derlgnrd and oodrd the rd I tor ALVINE, wrotr thr f Irst loadof Intarfaaa, and Qrnaral ly ma ntrlned and drbuflgod thr ryrtam, John Al lrn oontrfbutrd the ALVINE dooumrnt~tlon in ~ ~ ~ e n A, d l x ~ a rlyn l Mul llnt ha8 arrlrtrd In the ~ro~at8tlon of the' arerant adttlan,

TABLE OF CONTENTS CHAPTER 1.1 GuI~Q to the N ~ ~ I o @ e e e e! e o e e o o a e p o v,. o e o o e, o, o lil 1.2 Guldr to the U~or Ex~rrl@nced wlth Another LISP S ~ l f Q ~ e e e e ~ e ~ e e e o e a a o o ~ e e,, o, ~ *, ~ fa2 o o o lei Culdr to Umful ~unotion* and F@aturr*,,,..,,, 113 1.4 Dooumont Conv@ntlon~e~~,,e~~,.~eo~e~e,~~,e~,,e 1.4 ' <.... 20 INTERACftVE USE OF THE SYSTEM e o, r e * e o o o e o o, e e o,,, 2 m i 2,1 ~ r ~ nthr o Systar,, e ~ O, ~, O ~ e ~ e ~ e., e.. O ;., e.. : e O 2-1 2.2 ~pnolal T~lotyne Control Chrracter~o,,.,,,.,c, 2.1 6, LAMBDA E X P R E S S I O N S, e, e e e e, e e e, e e a o e a,, u, * e, u * e e 611 6,1 EXPRs and S U B R 8 ~ e ~ e e e e e. o. e q ~ e ~ e e ~ e a 6m2, ~, ~ o e, e ~ o 6,2 FEXPRa AND F S U B A s e e, m e e, o o e. e,,, ~ e e *, e, e o e e e,,, 6m2 6e3 LEXPR8 AN0 L S U B R ~ e, e,, e o e, o e a, o e e o, e *,, m,, e 6.4 M A C R O ~ e ~,, e o o, a o e e e o,,. o e e e e,, o e e e e o v e o e e o 6 ~ 2 613 7, EVALUATION OF S * E X P R E S S I O N S m, o, e, o v e e f i a e, e o e o o o e e e, 7-1

10, FUNCTIONS ON S-EXPRESSIONSe,e,~eeeve,e,eeeeeoee,,@eiO~l 10,i S-Exor@ssfon 6ulldln0 F~not~onr,,,~,~,,,,~,~,~10~1. l0,2 S-Ex~ress'fon ~rr~rnrnf in0 Funat )0n8*,,,,*,,,,,A@-2 10,s S-Ex~rrsrfon Hodlf~ino F~notlonr,,,,~,.,,,.,,,,10.12 l0,4 S-Ex~rerslon Transformlna ~unotlone,,,,,,,,,,,.,10a4 10.5 S-Ex~rrssfon Ma~plng F~natIon8~~.,~.,,~,,,~.,~,,l0-4 10,6 SmEx~rrsa'fon $@archlng F~notlona,,~,,,,,.,..,~,..10~6 10,7 Character List Transformlno ~un~tlonr,,,,,,.,~lb17 11, FUNCTIONS ON I D E N T I F f E R S,,, e e, e e e,, e e e ~ e v e e e ~ e ( i e,,, l l ~ l llel Pro~ert~ ~ 1 9 t 11,2 OBLIST 11.3 ~drntlflsr Creatln~ F~net~onr,~,~,~.,..,~~,~,,11-3 12e FUNCTIONS ON N U M B E R S ~ e, r e e, e,, e e e, e e e e,, * e,,, e e e, m e l 2 ~ 1 l4,l F ile Nam@s.,eeeeeeeee,ee,eee,.e,eeeee,e,ee,,I,A4-l 14,2 Channel Nan0s,,,,,,~,,,~,~,,,~~,,,~,,,,~,,~,14~1 14.3 I n ~ ~ t,. ~,,. ~, ~ ~, ~ ~ ~ ~ ~ ~ ~ ~, ~ ~., ~ 14e4 0 ~ t ~ ~ t e r c e e e e e 8 ~ e e e e e e, e ~ e e. e e @ e e e * e a, e ~ ~., e @ e 1 4 ~ 4 15,1 Exainlnr and De~o~ltt,~e~t~~~~~e~,,~,,,.,,.,,~,l5-2 APPENDIX A, APPENDIX 0, APPENDIX C, APPLNOIX D, APPENDIX Et APPENDIX F t APPENDIX G, APPENDIX H, APPENDIX I t ALVIN by John A l l e n c, e, c, e,, e e, e e, r,,, c, Am1 ERROR MESSAGESeee,e,,@,,e,,eeee,,,,,,,eee~, Bm1 MEMORY ALLOCATIONe,,,,,eee,e,,,,c,,c,,q,,,ta Cal GARBAGE COLLCCTION,,~~,~~,,~,,,,,,~,~,,I, Dm1 COMPILED FUNCTION LINKAGE AND ACCUMULATOR U S A C ~,, e,,,,, e,,, e,, e ~ @, e e e e e, e, ~,,, e,,,, Em1 THE LISP C O H P I L E R,, e,, q e e, e e e t, e q e a l,, ~ e e e @, F-1 THE LISP ASSEMBLER LAP,,,,,,,e,,qa,,ee.t, G-1 THE LOADER,,t,ee,..ee,,eeo,v.e,*ee,eteeee~, BIGNUHS - ARBITRARY PRECISION INTEGERS,,,,, Hm1 frl

APPENDIX J, A USER MODIFIABLE LISP SCANNER,v,,evfip,eeI, ~.1 APPENDIX K, S O S m L I N K, o, v v v e v. v, v v,,,, w,,,,. e e e, e Urn1 APPENDIX L, SOME DIFFERENCES BETWEEN THIS AND OTHER L I Q P S,, o e *, ~. * e, e e @, e ~ ~, e e ~ e * *. e e e *. *.,. ~ l.11 APPENDIX Hc LISP DISPLAY PRlMITlVESvovee,env,,,vfiv.e*e, MI$ APPENDIX Nt T R A C E, e v e,. e e e v v. v e v e n v v e e, e,, w e e N-i bppen0ix 0, SMILE,~,~.~.,~..~.~.~,~~,~e.,e~e.ee,e,~,,~ 0.1 APPEND I X P CONSTRUCT I ON OF A LISP Dl SK-DECTAPE SYSTEM,, Pmp

CHAPTER 1 CHAPTER 1 INTRODUCTION Thlr manual 19 intended to rwolaln the lntrrrctlvr LlSP 1,6 system whloh has born d ~ v r l o ~ for ~ d the PDP-10 at the stanford un!vrtrity ~rtlflolal Into l l torno. ProJeot, It /r arrumrd t h ~ t the trader lr frmillar with either romr other LISP rystom or the LISP 1.5 PRIMER by Clark WofssmanC2Jm Thr LISP 1,6 rvrt8m drser (bad ha8 rr a rubsrt moat bf the 9ratur.r and funotlonr of other LISP 185 syrfrn8. in addition, thrrr are 8@Voral naw ferturar such as an rrbltrrrv ~rrolr/~n Intr~er paoka~e, an Srner~rrtrlon rdltor, up to 14 actlvr 1n~ut.outdut ohannrlr, thr ablllty to oontrol thr rlze of mrmory,spapro 8 rtand8rd rr l ooat lng 1ord.r to l o&d arrrnb ly langurgr or comd led otograma~ @to, Thlr ryrtem use8 an lntrr~ratarl howrvrr, thaw 18 rlro a compl lar whlch Produoas machlnr coda. ~ b n led ~ l funotlona are appro~~mrtal~ 20 tlmrs as fast and trkm Ira8 nrmorv rpr~r, Thlr manual ir oroanlzrd In a functional manner, ~lrat the baslo data rfructurer are dract!brd! then the tunotlonr foi o~rrrtlnp on them, Tho a~prndicer rer rant more dotal led tnformrtlbn on the ayrtern, ltr lntorna l rtrueturr, thr comd ler, and rrvrrai auxf l hry ba@klg@b e

SAILON 28,6 CHAPTER 1 1-2 3 The us@r who (s not ewpsr lenord wlth any LISP SYBCI~ 18 rdvlsrd to fol low the (nstructlons brlowt I) Become famlllrr wlth Welssmrn's LISP 1,6 PrlmerC23 or rbme eaulvoi@nt Introductory LISP Manual. 2) Learn the dooument oonventtons (1,4), 3) Baoomr su~arflc~all~ famlllrr wlth LISP 1.6 idrntlflrir, 3 numbers and S-rxprrsslonr (Chapters 3,4, and 9); 4) Understand the moat uleful functlonrl Those ~ieoedrd by ewclrmat~on marks "!" In chrotrra 6 through 14, 5) Lawn how to drtlnr tunot~ons (6,1), 4) Learn how to lntsraot wtth LISP (Cha~tor 2), 7) Try some rxamplrr, WelsrmrnC13 has somr good drobl@rns, 8) Laarn what other useful funutlans and fertuta8 ate 3 avallnbls t1,3), $,2 Gulde to the User Experlenord wlth Another LISP S~strm Thr user who has used another vlisp ry8tem 1s rdvlrrd to follow these Instruatlonat 3 3 2) Learn top l e v ~ l of LISP 1,6 is EVAL, not EVALQUOTE, 3) U I ~ DE, DF and DEFPROP for drflnlng funotlon8, ( ~ r ~ t l ol1,l)j n 4) Many tunctlonr dllfrr from those In other syatgrna, ~brt of these are noted In the Index, 9) The syntax of atoms IS dlfferrnt from other ry~trrns (cha~ters 3 and 4). 3 6) Learn how to lntrract with LISP (Chaotrr 21, 7) Try some exarn~lea. 8) Learn what other useful tunotlonr and?rrturrr are 3 available (i,s),

G SAILON 28.6 CHAPTER 1 1,3 Guldr to Umful Funatlons and Features C The tollowlng 1s n partfrl list of usatul traturer and tunotibnr 1,n LlSP 1,6 and what thry mhht be useful form 1) ALVINE (~~prnd!x A) I@ u8rtul for odltlng tunctlon8 and manl~ulatln~ I/O flies, 2) READ ha8 romr very useful oontrol ohrrrotorr Mrttlon 14,s); 3) In~ut/Output (Chapter 14) I8 very fleilblr. 4) One orn oontro) error mrs8aga8 (Chr~tor 161, 5) Thrra Ir a LISP com~iler (Ap~lndlx F) whlah ornrrrter oodr that rung ~ D D ~ O N ~ twenty ~ ~ ~ Qtimer I Y r8 frat ru lntrrdrrtrd funottons, 6) Thrrr err aux)llrry t)ler on the dirk whloh are often uretulr I CJ t l lenamr, U ~ Q dooumant I SYS I TRACE trrolno tunofl~na ~ppandlx N and 8@tq8 rrptd turn-around b@tw@@n SOS and LISP ~odrndlx K I LISP,CORCS~DOCJ oorrrotlonr to thlr nanua l 7) One aan load and Ilnk LISP to amernbly and Fortpan eompllrd proqfam8. See Appondlr H, 0) One oan have f 1 1 as automat 1 or 1 l y 1 oaded by urr Q( the fii@ lorded INIT,LSP whlch is rutomrt~orlly on entry,

In the degcrlptlon of datr atructurrs, tho fol notatlonrl oonvrntlon8 wlll be urad, raprrsrnts a 3 6 m b l t word in FREE STORAGE wl th 2 18lbl t polntorr, - m O l W ~ w w W w ~ ~ m W ~ r l I I I I 1 NIL I * rr~rorrntr the lrrt word in r Ilst, w r ~ m a ~ m v ~ v w ~ ~ ~ r - ~ rr~r@rrnts r 36-blt word In I I VULL WORD SPACE. I I A r 1 lghtly modlf led form of BNF ir uard to drflnr r~ntar oqurtlonr, O~tlonal trrmti ara rurraundrd by ourl~ brrokrfs ( and 1, 1 4 Calllno Saaurnor Conventions C.1 l lna srpurnors to LISP funotlona are progentrd In S.rr~rrsslan form, with thr CAR of tha ~-er~re@s/on bdng the name of the tunotlon, An argument to a funotlon 18 rvnluated unlar~ that argunent I8 surrounded by quotes (n) In the arl llng rrquenoa dailnltlono Quotes morn that the function t m ~ l t o l t l QUOTE8 ~ that argument, 1,4,4 Other Convrntlonr (QUOTE " V V V 1s not rvaluatrd; ID la not rvrlurtrd, but V 1s 3 evaluatedo The blank oharaot0t' (ASCII 40) Ir lndlcatrd by "," whcln appro~rlate for ~ l a r h ~, A spe~ia1 drgrre of utlltt~ or dlffleult~ notatlor! in the left rnrroln 18 u8rd to lnd1eatr the of each 8rotlon of thlr manuall 3 3

CHAPTER 2 CHAPTER 2 INTERACTIVE USE OF THE SYSTEM 2,l U11ng tha System Tho followlno dlalog shows how to lo9 into tho the-8harlng ry8tam, atart the LISP r~strm, and Interact wlth the top lrvrl at ISP, ~ l n r ~ brglnnlno with ~orlod arr ty~ad by the user to the t 'f mrrn8hrr1no rystrmt rnd the llnrs boglnnlno with artrrtsk rrr ty~od to LISP, Thr rymbol <or) r~aoltlrr ~arrlfage-raturn, and mrrnr altmodr,,r LISP FREE STORAGE 10008 a 20000 <or> Thls giv@s 20K of Fro@ S ~ O ~ ~ Q O Inatead of tho ururl %@Kc FULL WORDS + 4000 8 <or> Thls glvas tho dofault value. Cj of 5K, BIN, PROC, SP, 8 2800 120005 Thlg glvrs 12K of ~lnrry ~iogram sirarc and ends tho rlloortlon, For a full dlrcu~don of rl locrtfon aae Ap~andlx C, A t thls ~olnt, after allooatlon and brforr anything rlar, the (110 LISP,LSP is raad from the 8ystom, Thfr define8 varlou8 maoror, G rrcrnt rddltlona to the syltrm, bootstta~ drflnltlona tor the?unctlonr in thr verlous aalf lordln~ utllltv Cllrr, Traoe, SOSLNK, LAP ate, In rddltlon, If there Is r fil@ by the name INIT',LSP In the user's dlrrctorl, it w l I I be loadrd too, Thlr rnrbl@r the urrr to hava lnythln9 he laadod autom8tl@al IY, T<altmad@> T T and NIL alwa~s evaluate to thomrrlvor,.(quote ta B C)) <cprrlag~ return) (A c) Value of QUOTE G (CONS i (QUOTE A)) <crtrlr~@ return) Numbars always evaluata to thomsolvoa and thus need not bo quoted, b ' <a long sequanoa of outout) Thls output urn be ruo~rrr~od with *O,

SAILON 28,6 CHAPTER 2 2bQ *!DEFPROP CDRQ (LAMBDA (L? (CDAR L) ) FEXPR) <car f fago r@tu{n>' CORQ e(cdrq CAR) <o&rrtagr roturn) (SUBR #addrrrs PNAHE (#fullword?) *(OE TWICE (NUMI (TIMES 2 NUM)) Coarrlr~a return) TWICE 2.2 S~aclal T ~ l r t ~ pcontrol r Chrtrotrrr Tho tlmr-shrrlng r~rten treat8 many eonsrol oharrotert In r~~olal ways. For r comolrtr d1rcusrlon of 00ntt~l ohrrrotrrr r@e the PDPmle TIME SHARlNG MONITOR MANUAL. Brlrtly, the following rpuotal oontiol aharactrrs avo usod in LISP, Tr I c rt~~a III Dlu~lrv Wean I na CALL Control 2 I lnrtrrd Control i I lnrfrad Stop the Job and talk to tlmrm8harino ryrbrm, Supproas oonro la pilntout unti I rn Input ir ieauertod, DO I ote the rnt I to lndut I 1 na now be In9 Wmdr (Only vlth (DDTlN NIL)). stop the LISP t ntoi~totar rnd return oonfrol to hhe too I eve I of LISP, on I'Y offrctlva whrn LISP 18 asklng for conrolr input, Sae INITFN (161,

CHAPTER 3 IDENTIFIERS Identtflers are strings of characters ~ h l c h taken togsther rrprrsent a single atode auantlty, I i <comments> ::s<ascii 32) <any aeauence of chapactera not lncludlne line-feed> CIIna teed> <dellmlter> :r= 0) I ti3 1 3 l@l/lwl <blank> I <altmode> I aarriaer-return I <Ilne-fwd> I <trb> I <formfeed> <tha,a~t@~>;:: <any extended ASCII ~ha,aet@~ otha, than null and ASCII 176) <dlglt>l:= 0(11213(41516)7(8)9 <letter>::= <any character net a dlglt and not a drl!rnlter> <tdsntlfter>::= <letter> :t=<ldentlfler> <dlglt> 1;s / Ccharaoter> ::a <Identlfler>/<character> Identlflers are normally strings of characters brglnning wlth letter and followed by letters and dlglts, It is sowrtlrnes convsnlent to create identifiers whloh contaln dellmltrrs or brdn with dlglts, The use of the dellmltrr ''I" (sllrh) causq8 the to1 lowlna eharactey be taken 1 lteral IY, and tha slash itself 18 nqt part of the Identifier, Thus, /AB is the some PS AB i$ the same as /A/B, Comments are useful for allowlno destrlptlve text in ti lea which w l l l be completely Ignored when read, Comments also make it posslblr to extend atoms (Identltlrrs, strlngs and number$) aoross nine boundaries without any of the characters in the comment brooming part of the atom, ASCII 32 cannot be tyaed directl~ into LISP, In STOPGAP, 33 deslenatrs ASCII 32, on the llne ~rlnter and 111 displays, ASCII 32 prtnts as tl lde "'", ASCII 32 does not ~ r h on t telrty~rs, (See CHRCT In 14,1,4,) Exarr,~ 10s t A a FOObaz TIME-OF-DAY A102

SAILON 28,6 CHAPTER 3 3-2 An idrntlfler 13 lnternall,~ rs~rrarnted a8 a dotted pair of the following formt wklch ir called an atom herder, Thus CDR of rn identlflrr 9lvea the pro~erty llat of the Idsntiflrr, but CAR of an ldrntlfler glvrs the ~olntrr 777777, which if used PS ~n address w I I I oauae tan lllbqal memory refrrrncr, and an error messagq, An Identlfler I8 referred to in symbol l c eorn~utrt1on by the addreas of Its atom header, The property list of an ldentlflrr la a Ilat of ~riirt name, property value) rssoclated with that ident"filrr, The (pro~ert~ nornal klnde of propertbs whleh are found in ~ r o ~ e r t y 11stg are ~r lnt names, values, and funotlon def hi tions correspondtna tb Identif'lrrs, Every ldentltlrr has a ~ r l n t name (PNAME) on its property nlst, The ~rlnt name of an idrntlflrr is r list of full wordr, each oontatnlng five ASCII oharaotsrs, Examplea The Idrntltlrr TIME-OF-DAY would be lnltlrlly irpre8rntrd i s followsj 11w1w.10.Lw111 ---*--ww- mowv-1)1-1), atom * I - 1 1 1. 1 I I ' I INILl headrr I,,,,I-,,I l*--l"--l l.,--l*--l what@ means null or ASCII 0,

SAILON 28,6 CHAPTER 3 3-3 When a value is rsslgned an idrntlfler, the ~rodrity name VA\UE Is put on the Identlflerts ~ r o ~ e r tlfrt y with props ty Value be ng a pointer vo a s~rtlal cell. The CDR of the s~sc f a1 cell (soretlmes 6.1 led VALUE oel I) holds the value of the idrntjfirr4 af~d the eddrrss of 4 s~eolal cell rernalns oonstont for that jdenttct~r unless REMPROPed 1 1 2 to enable complied function, to dlrrotly reference the vdues of s~eclal varlablos, Global varlablrs and all varlrblrs bound In interpreted functlona atore thrlr values in speclal eel Is, Exam~l@t The atom NIL has the f0l lowing form1 atom header ~ r o ~ e r tl13t y 3,2 The OBLIST In order that occurrences of ldentlfiers with the same ~ r l n t names have the same Internal address (and hen06 value), a a~aclal nlst whhh Is the VALUE of a global varlablr oalled OBLIST is used to rerne~ber all ldrntlflrrr whleh READ and some other function8 have seen. For the sake of searehlng efflelrnoy, thld list has two nevrlsr the first level contains sequentlally stored ~buokrts" vhloh are "hashedft into as a functlon of the ~ r l n t name of thr (dentltlrr. Each buokrt Is a llst of all dlrtln~t idrntiflera whloh have hrshrd into that buokrt, Thus, (CAR OBLIST) 1s the flrst buokrt, and (CAAR OBLIST) Is the Clrst fdentlifer of the flrst bucket. Syntax t rtr lngj t = "<any sequenae ot characters not containing ">"

SAILON 28.6 CHAPTER 3 3-4 A strlng Is an arbltrary sequence of oharrctrrs rurroundod by double quotes and not contalnlno double ~uotes, ~trlngs are rrpr~srnted ldentlc~lly to ldrntlfbrs except that gtrfngg rrs not sutomatloall~ INTERNed on tho OBLIST. The doublr quotes qurroundjng strlnq8 actuall~ beeome part of the PRINT NAME of the atring unlike slashes In slarhfflsd tdenttflrr#,

CHAPTER 4 CHAPTER 4 NUMBERS There are two syntactic types of numbers: lntegrr and real, <number> 1:s (integer) 1 <real> 4,1 Integers Synttaxr < I ntegar) $ 1 (<8lan>l ~ <dlaita> (*) The global variable IBASE s~ecfftes the Inout radix tot fnteeers whlth are not fo(lowed by tt," Integers followed by are declral Integers, IBASE is Inlttallv = 8, Slmtlarlv, the globrl varlable BASE controls out~ut radix for Integers, If BASE 3 10 then Integers will Print with a foll~wlng ",", Unless the global va?lable &NOPOINT = T, Examalas wlth IBASE = 8 i' i There are three representatlon~ for inteeers depending on the numer lcal magnitude of the integer: INUh FIXNUM, and BIGNuM, ~ h d r ranges are as follows: INUF1 Inl <K K Is usually 2'16 F I XNUM c- INUMa are small Integers re~resented by ~olnters outsldr of the normal LISP addressing sdaoe, INUMs are addressrs in tha range 2918-2K to 2918-2, The lnum r~~resentstion for zero la a 8 2t18-K-1.

I NUM Reoresentatton FIXNUMs are reproranted by llrt structure of the tollowlna form: 2 Atom header where value Is the 2's com~lemrnt re~resentrtlon of tho fixed point numb@ r, BIGNUM~ are represented by l 1st struoturr of the fol lowln~ forms;

SAILON 28.6 CHAPTER 4 443 S here NdI are ~osttfve 36 blt Integers ordered from least tb most slgniflc~nt, The value of a BICNUM 1s Note: BIGNUMs are not norm all^ a part of the interpreter, Apnsndlx H drscrlbes the pro~edures for lopdlng the BIGNUM Packagel Restrlctfonsr The radlx for real numbers I S always decimal, A real numbei x must be In the (ap~roxfmate) range: A real number has apdroxlmatsl~ eight signlflcant digits o) taccuracy. atom header.cz~i-m-cc- -wrrrrr-r-r-r-r -~"IcI-*.I)cI I -1 I I + IFLONUMI I * I value I 1 ---r 1 --- I 1 ------ 1 *----- I 1 -*----- I where value 1s in PDP-C/Ig 2's complernrnt fl~atlng ~olnt representatlono

CHAPTER 5 CHAPTER 5 S-EXPRESSIONS Syntax! the ldentlffer NIL is the ldrntlllrr whlch represrnts the e r n ~ t ~ list, I,@,, 0,

CHAPTER 6 CHAPTER 6 LAMBDA CXPRESSIONS LAMBDA expressions provide the moans of conatruot/ng oornp~tatl,nal procedure^ (often called funotionsc subro~tin@s, or proceduros),hlch compute answers,hen values are asdgned to their paraseters, A LAMBDA expression can be bound to an ldentlllrr so that any referenee to that identlfter in functional context refers to the LAMBDA srpresslon, In LISP 1,6 there are several ty~er of tunctlon deflnltion whlch determine how arguments are bound to the LAMBDA exprersfon, The following Is a LAMBDA rx~resslont 1 (LAMBDA "ARGUMENT~LI ST" "B.OOYf0 LAMBDA defines D functlon by s~eclfy~no an ARGUMENT-LIST, which Is a Ilst.of identlflers (exce~t tor LEXPRg, see 6,3) and a BODY, khkh Is an S-expression, LAMBDA expressions may hnva no more than flvs arguments If they are to be aomplled. 'Examp l ear (LAMBDA NIL 1) thls LAMBDA expressian of no arguments alwa~s evaluates to one, (LABEL (LAMBDA ( X I (TIMES X XI) This LAMBDA e%dr~sslon Gom~UteS th@ squat. of Its argument, If x is a number, Otherw18e an error will result, "LAMBDA-EXPR") LABEL orrates a temporary name ID for its LAMBDA axprrssibn, This makes It ~osslble to aonstruct reourslve functions wlth temporary names, e ; (DE REVERSE (L) ((LABEL REVEVSEI (LAMBDA (L M I (CON0 ((ATOM L) M) (7 (REVERSE1 (C6R L) (CONS (CAR L) MI))))) L NIL)) LAMBDA expressions are evaluated by nblndlngfl aotual argurents to dummy varfables of the LAMBDA expression, (see Chapter 14) then evaluatlng the body lnslde the LAMBDA expressron with the current dummy vartable blndlngs, However, actual arguments to LAMBDA expresslens are handled In a varlet^ of ways, Normal(Y, there Is a one-to-one correspondsnce between dummy variables and actual argufleflts, and the actual arguments are evaluated before they are

SAILON 2816 CHAPTER 6 6-2 bo nd, However, there are three s~eolal forms QC f'unotlon daflnhlon wh 1 oh dltfrr In thrfr hsndllng of aotual argurnrnfs, I 6,i EXPRs and SUBR~ An EXPR 1s an ldsntlflrr whlch has a LAMBDA sxprrsrion on its ~roprrty ll8t with ~ r o ~ e rname t ~ EXPR, EXPRs are evaluated by blndlng th5r vrlurs of the actual ircluments to their ~oi~rlrpondfng dumry variables. DE (see 11,l) I8 useful for drtlnlng EXPRI, The oompllod form of an EXPR Is a SUBR, I (DE SQUARE (X) (TIMES X XI) (DE *MAX (X Y) (COND ((GREATERP X V) X) (T Y))? 6,2 FEXPRs and FSUBRs A FCXPR 1s an Identifier which has a LAMBDA ex~rrr8ion of an0 dummy variable on its ~roperty list with p r o ~ e r t name ~ CEXPR. FEXPRs are evaluated by bfndlng the aotual aroument llrt to the dummy varlablr wlthout evaluating any arguments, OF (see 11,1) Tr ~86ful for def Inlng FEXPRs, Thr aompl lrd form of an FEXPR is an FSUBR, (DF LISTQ (L) L) (LISTQ A (B) C) = (A (0) C) (LISTQ) NIL (OF DEFINE (L) (MAW (FUNCTION (LAMBDA (XI (PUTPROP (CAR X) (CAQR X) (QUOTE EXPR)))) L) (DEFINE (LEO (LAMBDA (X yl (OR (LESSP x y) (EQUAL X Y ) ) ) ) (GEQ (LAMBDA (X Y) (OR [CREATERP X Y) (EQUAL X Y))))) # 6,3 LEXPR~ and LSUBRs An LEXPR is an EXPR who80 LAMBDA e~~rerrlon ha, an atomic arguwent "Ilstw of the form: LEXPRs may take an arbltrar~ number of actual aroumentr whloh are evaluated and referred to by the s~eolrl funotlon ARG, ID /r bound vo the number of arguments whlch are passed, thr oom~llrd form of an LEXPR Is an LSUBR,

SAILQN 28,6 CHAPTER 6 6-3 ARC returns the value of the Nth argument to an LEXPR. (DE MAX N (PRO6 (M) (SETQ M L (SETQ N (COND (GO L))) (MAX 1 1,2 4 3-50) = 4 (ARG N)) (SUB1 N)) ((ZEROP N) (RETURN MI) ((GREATERP (ARG N) M) (SETQ M (ARG N)))? SETARC sets the value of the Nth argument to V and returns V, A MACRO Is an Id~ntlfier whlch has a LAMBDA ex~ression of one dumry varlable on Its property llst Nth ~ r ~ P e name r t ~ MACRO, MACROS are evaluated by blndtng the list containing th@ maero nrma and the actual argument list to the dummy varlrble, The body in the LAMBDA exoresston 18 evaluated and should result In another wexdandedav form, In the intrr~rrter, the expandad form is evaluatrd, In the eompller, the rx~anded form is c~rnplled, DM( ser 11,l) 1s useful tor detfnlng MACROS, 1) We could define CONS of an arbitrary number of arguments by! (DM CONSCONS (L) (COND ((NULL (CDDR L)) (CAOR L)) (T (LIST (QUOTE CONS) (CADR L) (CONS (QUOTE CONSCONS) (CDDR I.)))))) (CONSCONS A 8 C) would call CONSCONS with L a (CONSCONS A B C) CONSCONS then forms the llst (CONS A(C0NSCONS B C)), ~valuatlng this wlll again call CONSCONS wlth L = (CONSCONS C), CDNSCONS will tlnall~ return C, The effect of (CONSCQNS A E3 C) 1s then (CONS A (CONS B C)), 2) re aould deflne a tunctlon EXPAND which 1s more generally usqful for MACRO expansfon: (DE EXPAND (L FN) (COND ((NULL (CDR L)) (CAR L)) (T (LIST FN (CAR L) (EXPAND (CDR L) FN))))))

Then we oou(d define CONSCONSt (DM CONSCONS (L) (EXPAND (CDR L) (QUOTE CONS))) It should be noted that MACROs are more general than FEXPRs and LEXPRs, In fact the D ~ ~ V ~ Qdsfinltions U S can be re~laoed by the ~ollowlna MACROs: (DM LISTQ (L) (LIST (QUOTE QUOTE) (CDR L)))) (DM MAX (L) (EXPAND (COR L) (QUOTE #MAX))) (MAX A 0 C would exnand to! (*MAX A (*MAX B (+MAX C D))) #EXPAND and &EXPAND1 are MACRO rxpandlng Cunctlon8 usrd by PLUS, TIMES, etc, They are equivalent tot (DE *EXPAND (L FN) (*EXPAND1 (REVERSE (CDR L)) FN)) (DE *EXpANDi (L FN) (COND ((NULL (CDR L)) (CAR L)) tt (LIST FN (*EXPAND1 (CDR L) FN) (CAR L))))) Wlth PLUS defined as (DM PLUS (L) (*EXPAND LtQUOTE 4PLUS))) (PLUS A 0 C 0) ~xpands to: (+PLUS (*PLUS (*PLUS A 0) C) D)

SAILON 28,6 CHAPTER 7 7-1 EVALUATION OF S-EXPRESSIONS Thls chapter desorlbes the heart of the LISP inter~retrr, the meohanfsm for svaluattng S-expressions, t (*EVAL E) (EVAL E) *EVAL and VAL (see 7,2) evaluate the value of th; S-ex~resslon E, Examp l as: (EVAL (LIST (QUOTE ADD11 3)) 8 4 The top level of LISP 1st (PROG NIL L (PRINT (EVAL (READ))) (TERPRI) (GO I.)) APPLY evaluates and binds eaoh S-expression In ARCS to the oorres~ondlng arguments of the functl~n FN, and returns the value of FN, See 7.2, 8~ r! (QUOTE "EW) (APPLY (FUNCTION APPEND) (QUOTE ((A B) (C Dl))) m (A 8 C D) QUOTE?@turns the S-ex~resslon E without evaluatlnp it, (FUNCTION "FNV FUNCTION is the same as QUOTE fn the Inter~r6tar, In the eompller, FUNCTION causes the S-ex~resrlon FN to be eomdiled, but QUOTE generates an S-expreaslon aonstant, See *FUNCTION in 7,2 tor the specfal FUNIRG feature, The folnowing function def)nltlons lack some details but explain the essence of EVAL and APPLY, The A-LIST feature of these functions Is not shown, (DE FVAL (X) 'i (PROG (Y) (RETURN < * (CON0 ((NUMBERP X) X I but will be ex~lalned in 7,2, c ((ATOM X) (CON0 ((SETQ Y (GET X (QUOTE VALUE))) (CDR Y)) (T (ERR (QUOTE (UNBOUND VARIABLE)))))

SAILON 28,6 CHAPTER 7 7.112 ((ATOM (CAR XI) (COND ((SETQ Y (GETL (CAR X) (QUOTE EXPR FEXPR MACRO)))) (COND UEQ (CAR Y) (QUOTE EXPR)) (APPLY (CADR Y) (MAPCAR (FUNCTION EVIL) (CDR X ((EQ (CAR Y) (QUOTE FEXPR) (APPLY (CADR Y) (LIST (CDR XI))) (T (EVAL (APPLY (CADR Y ) (LIST XI))))) ((SETQ Y (GET (CAR X) (QUOTE VALUE))) (EVAL (CONS (CDR Y) (CDR X)))) (7 (ERR (QUOTE (UNDEFINED FUNCTION)))))).3 (T (APPLY (CAR lo (MAPCAR (FUNCTION EVIL) (CDR %)))I (DE APPLY (FN ARGS) (COND ((ATOM FN) (COND ((GET FN (QUOTE EXPR)) (APPLY (GET FN (QUOTE EXPR)) ARCS)) (T (APPLY (EVAL FN) ARGS)))) ((EQ (CAR FN) (QUOTE LAMBDA)) (PROG (Z) (BIND (CADR FN) ARGS) (SETQ i! ( VAL (CADDR FN))) (UNBIND (CADR FN)) (RETURN Z))) (T (APPLY (EVAL FN) ARGS)?)) The functions BIND and UNBIND implement varlablr byndin98 described In the next sectlon, ar Thls seotton attempts to rxplaln the different ty~er of varlrblr blndln9s and the dlffrrrnos batween lntrr~rrter end oom~ let blndlnor, 7,1ri Bound and Free Ocaurrenoes An occurrence of a vrrlablr is r.bound ~~c~rrrnoe" if the varlrblr is tit variable In rny LAMBDA or PROG contalnfnu the ocourranor so lonp as thr ooourrenoe 19 not eontalnrd In a FUNCTIONAL ~rgusent whloh Is oontalnrd in the drflnfng LAMBDA or PROG, the deflnlng LAMBDA or PROC I8 the lnnrrmo8t LAMBDA or PRO6 whlch oontainr the varlablr in fts parrmstrr list, (LAMBDA (lo (TIMES X Y)) X has a bound ocqurrencee y hae r f ee opo~r engi, (LAMBDA (Y 2) (MA~CAR ~FUNETION (LAMBDA(%) (CONS x y ) ) ) ~ ) X and 2 hav only bound occutrena re Y 1, bound 8y the,uter LAMBDA an! tree in thr lnnrr, 3

j SAILON 28,6 CHAPTER 7 7.3 * 7,1,2 Scope of Blndlng~ C vat l6b l e bound 1 n a LAHBDA or PROC i r d8f inad dur lng the dynarlc exroutlon of the LAMBDA or PROG, Frre oocurrenc@s of, - vrrlrbler are deffned if and only If rlthrr the varlrblr fa globally detlned or the varlable Is bound in any LAMBOA or PROG which dynamical ly eontrtns the?re@ ooourrrnoe, A variable /r global ly d~flned If and only if it has r value at thr top iavpl of LISP, ~arlabir8 aan be global IY defined by SEtQ at the too I@v@~, In oom~llod functions, any varlable which 1s bound in a LAMBDA Or PRO6 and ha$ a free Ocourr~nor elsewhere must be d@~laied SPECIAL (APPENDIX E), (LAMBDA (A B) (MApCAR (FUNCTION (LAMBDA (X) (CONS A XI)) 8)) The varlitble A whloh has a tree ocourrrnor muat be drolaied SPECIAL If the outer LAMBDA rx~rasrton 1s to be oompfled, * 7,1,4 Blndtno Mechanisms A l l varlrblrs In lntrr~teted functions, and SPECIAL varlrblrs In com~lled funotlons store their values in SPECIAL (or VALUE) o@llr. L. Thrsr var lab les are bound at the entry to a LAMBDA or?roc8 by rrvlna thrlr prrvlous values on the SPECIAL pushdown llat and rtarlng their new values in the SPECIAL oells, A l l referenere to there var(ablrr are dlreotly to their SPECIAL cells, When the LAMBDA,or PROG. 1s rxltrd, the old values are restored from the SPECIAL purhdown 1 Irt, (_ In oom~lled funotlons~ all variables not dsalared SPECIAL rrs stored on the REGULAR ~ushdown list, and the SPECIAL ce l lr (If they exist) are not teferanced, # 7,2 The AmLIST and FUNARG Features.L The A-LIST which is usad in some LISP systems to Tmd~rmant rraurslvr varlablr blndlng!s dose not @XIS? here, but its aftrota are 8lWulated through a special A-LIST feature, The functions EvAL rnd APPLY al low an extra last argument to bb D I S S ~ ~ ~hloh 1s rlthrr it nlst of ~alrod Identif!etS and value@ (Ilke an A-LIST) or nblndtna oontext PO 1 nter!', L In the case of an A-LIST second argument, EVAL and APPLY w! l I blnd the s~rolal cells of the variables in the A-LIST to their spec l f led va l uas,, raving the1 r ptevlous bindings on tha a~ea1al aurhdown I lat, When EVAL and APPLY rrturn, the vartablr btndlng~ are restored to thelr prevlous values,

SAILON 28,6 CHAPTER 7 7.114 A "blndlng context polntrrff (BCP) is o potntar Into the SPECIAL PUSHDOWN LIST deglgnat In!J a l @ v 1 ~ in re~uralv@ var lab lr binding, When EVAL and APPLY reaelvr a BCP as thelr second aroumrnt, all SPECIAL (VALUE) CELLS are restored to the values t h y had ot the vlme th@ BCP wa8 generatad, Th 1 r then oaures EVAL, and APPLY to pafetenor thrse var jab les In the bl ndlno context whleh oxi8ted,at the vlma of BCP genrratlon, Thls feature ~ r f m r r l Itti l ~ useful to Qrrvrnt varleble name confl lcts wh~n uslne EVAL, APPLY, and funot/onrl rrgurenta, A@ wlth the A-LIST, when EVAL and APPLY rxk, the previous blndings arr reator~d, There are two ways to generate a BCPt It an FEXPR 1s defined wfth two rrgumrnts, than the srcbnd argument w l l l be bound to the SPECIAL PUSHDOWN LIST level at the tima the FEXPR Is called, The srcond way to genetote a BCP Is wlth *FUNCTION; #FUNCTION returns a Ilat of the following Form; (FUNARC FN + <BCP>) whrrr BCP Is tho SPECIAL PUSHDOWN LIST level at the t lmr *FUNCTION 1s 6.1 led, Whenever auah r funotlonal form 18 used in funotional qontaxt, all SPECIAL blndln08 rrr restored to the values they had at the tine *FUNCTION wag evaluatrd, When the functional argumrnt ha8 been AppLYed, the prsvtour blndln~s at@ restored re with the A~.IsT, The use of FUNARGS Example using the BCP featurot Is dlsousrrd further by Robert SaundrrrCII, (OF EXCHANGE (L SPECPOL) (PROG(2) (SETQ t(eval (CAR L) SPECPDL)) (APPLY (FUNCTION SET) (LIST (CAR L) ( VAL (CADR L) SPECPDL) SPECPDL (APPLY (FUNCTION SET) (LIST (CADR L) t SPECPDL))) In thls rxrmplr, the uar of the extra argument SPECPDL has only one rffectr to wold confllcts between internal and external vrrlrbl'ea wlth names L and SPECPDL, (EXCHANGE L M) wlll eaus* the value8 of L and M to,br exahangod, he variable L In EXCHANGE ir not rrfaranord by the calls an SET*

CHAPTER 8 CHAPTER 8 CONDITIONAL EXPRESSIONS A oondltlonal expresston has the following form; where the ert8j8s are any S-ex~resslons, The rhl,lks are consldrrrd to be ~redlcrte~t I,o,, evaluate I vo a truth value, he ehl,l'a are rvalurted starting wlth rhl,i, 94281, eta,, until the firat rbkt1 1s found whoa@ value (8 not NJL. Than the oarrrs~ondlng rdkd r W 3 ee,r&k,nhk are #VR~UIC@~ perpactlvely and the value of erk,nhk 1s returned as the valur of COND, It la plrm~sslble for nhk 31, In whloh case the value of Wk,i 1g thr valur or COND, 1f all eh~,~. rvaluatr to NIL, then NIL 18 the t- valur of COND, (DE NOT (XI (CON0 (X NIL) (T))? (DE AND (X y ) (COND tx (CoND (Y T))))) tde OR (X y) (CON0 (X T) Cy T))) (DE IMPLIES (X Y) (CQND (X (CON0 (Y T))I (7)))

CHAPTER 9 CHAPTER 9 PREDICATES lr '.- Predtcates test S-exuresslons for ~artlcular values, for^^^, or ranees of values, A l l predicates described in this chapter retur, either NIL or T corresponding to the truth values false and t r ~ z, unless otherwfse noted, Some predicates cause error rnsssagss or undefined results when a ~ ~ l i eto d S-ex~ressrons of thr Wrong tyac, suoh as (MINUSP (QUOTE FOQ)), 1 (ATOM X) The value of ATOM is T It X is either an Identifier or 2 number1 NIL otherwlss, C The value of EQ Is T 19 X and Y are the same pointer, I,P.* the same Internal address, Idantiflers on the OBLlST have unia~p addresses and therefore EO w l ll be T If X and Y are the saqe ldentlfler, EQ will also return T far eaulvalent INUMs, gjncr they are represented as addresses, However, EQ w i l l not compare eaulval ent c numbrrs at any other klnd, For non-atomic S - ~ X P ~ ~ S S ~ EQ O fs ~ S T, if x and Y are the same pointer, Exarm 10s t (EQ T 1) = T (EQ I' NIL) = NIL (EQUAL X Y) (EQ (QUOTE A ) (QUOTE 0)) 3 NIL (EQ 1 1,0) = NIL (EQ 1 1) T (EQ l,[zi 1.n) = NIL L. The value of EQUAL is T 11 x and Y are identicei S-ex~resslons, EQUAL can also test for eaualftv of numbers of mixed vypes, EQUAL Is equfvalent to: (LAMBDA(X Y) (COND ((EO X Y) T) ( (AND NUMBER^ X NUMBER^ Y 1) (tcrop (*DIF X y))) ((OF? (ATOM X)(ATOM Y)) NIL) ((EQUAL (CAR X) (CAR Y)) (EQUAL (CDH X) (CDR Y)))))

Exrmp 108 (EQUAL T T) T (EQUAL 1 1) a T (EQUAL 1 'I' (EQUAL (QUOTE (A B)) (QUOTE (A 8))) 8 T (EQUAL (QUOTE (7)) T) + NIL (NULL L) 3 T If and only t Q L Is NIL, (MEMBER Ll L2) = T 11 and only I f LI Is EQUAL to r top level rlemrnt bt L23 MEMBER la equivalent tot (LAMBDA(l.1 (2) (COND ((ATOM L2) NIL) ((EQUAL L1 (CAR L2))T) (T(MEM0ER L1 (CDR L2))))) Examp la8 I (MEMBER (QUOTE (C D)1 (QUOTE ((A B)(C DIE))) r T (MEMBER (QUOTE C)(QUoTE (C)))) a NIL (MEMQ Ll L2) 8 T lit Li Is EQ to r toi level element of L2* MEMQ Is eeulval@nt to; (LAMBDA(L1 LZ)(COND ((ATOM L2) NIL) ((EQ l.1 (CAR L2)) T) (T(MCMQ L1 (COR l.2))))) Examp I @ at (MEMO (QUOTE (C D))(QUQTE ((A B U C Dl E))) 1 NIL (MEMQ (QUOTE A) (QUOTE (Q A 0))) o T (NUMBERP X I = 7 If X Is n number of any type r NfI othrrwlse (ierop lo T I f x is zero of any numrrloal type = error If x Is a non-nurnrrloal aurntlty NIL othrrwlse (MINUSP X) IB T If x ta a negatlve number of any type = error If X Is a on-numsriaal auantlt~ P NJL otherwise (*GREAT X Y) = T 1f X and Y are numbers of any type and X > Y, = error It elthrr X or Y Is not r number = NIL otherwlse

SAILON 28.6 CHAPTER 9 9-3 t error It any XJI is a non-numerical qua l i ty = NIL atherwlse Other numerical predlcates may be defined as Qollow~~ toe FLOATP (X) tcqnd ((EQ X (PLUS X @))NIL) ((EQ (CADI? XI (QUOTE FLONuM)) TI (7 NIL))) (DE FIXP (X) (NOT(FL0ATP XI)) (DE ONEP (X) (ZERQP (DIFFERENCE X 1))) tde EVENP (XI(ZERQP (REMAINDER X 2)))! 9.3 Boolean Predicates The Boolean predlcates perform logical operations on the truth values NIL and T, A non-nil value Is considered equal to T. (NOT X) 8 f 1 f X Is NIL = NIL otherwise (AND X b l XA2,,,Xln) = T If all XJI are non-nil = NIL otherwlae Note: (AND) = T, AND evaluates Its arguments from left to right unttl either NIL 1s found in which case the rernalnha arguments are not evaluated, or until the last argument I S evaluated, (OR X l i X42,., X J ~ ) = T If any X d I Is non-nil = NIL, otherwise Note: (OR) = NIL, OR evaluates Its arguments from left to right until either non-nil 1s found In which case the remaining arguments are not evaluated, or untl l the last argument 1s evaluated,

CHAPTER 10 CHAPTER 10 FUNCTIONS ON S-EXPRESSIONS Thls chapter desorlbes funttlons tor bulldin%, fragmenting, oodifylng, transforming, mapping, and searching S-ex~resslons, as we1 1 as some non-standard functions on S-expresstons,! 10,1 S-Expression But [ding Functlons (CONS X Y) The value of CONS of two S-expressions Is the dotted palr of those S-express!ons, Examp 10 (CONS (QUOTE A) (QUOTE 3)) = (A,B) Note: See Appendix D for lnformatlon on fun~tlons assocjat~d with CONSlng, such as SPEAK, GCGAG, and GC, (LIST X J,,, ~ X J ~ ) = (CONS X 4 1 (CONS X42,,,(CONS Xcn NIL),,,)) Llst evaluates all of Its arguments and returns a lfst of the I r va l UeS fi Exarrp 10s t (LIST) = NIL (LIST (QUQTE A ) ) = A (LIST (QUOTE A ) (QUOTE 0)) a (A 3) tde +APPEND (X Y) (CON0 ((NULL X I Y) (T (CONS (CAR X I (*APPEND (CDR X) Y ) ) ) ) ) Example1 (APPEND) + NIL (APPEND (QUOTE (A B)) (QUOTE (C Dl) (QUOTE (E)?) = ( A R 2 : 1@,2 S-Expression Fragmenting Functlons (CAR L) The CAR of a non-atomic S-expressfon Is the first element of that dotted oalr, CAR of an atom 1s undefined and ~ l l usual l ly cause an I (legal memory reference,

SAILON 28,6 CHAPTER 10 104 3 The CDR of a non-atomlo S-ex~rrselon is the recond (and lart) drnrnt of that dotted ~alr, The CDR of an idantltlrr la its pro pert^ I lat, The COR of rn INUM causes an 1 l legal mrmbrv referrnor, The CDR of any other number la the l frt gtruoturr reprrsrntatlon of that number, Exrrr;~ I eg t (CAR (QUOTE (A B C))) A (CAR (QUOTE A)) Is Illegal (CDR (QUOTE (A B C))) 8 (B C) (CDR (QUOTE A)) Is the ~roperty 118t of A (CDR (QUOTE (A))) 3 NIL CAAR, CADR,,aq, CDDDDR A l l of the oom~oslte CAR-CDR funotlona wlth ud to tour AIS and D's are avaflablr, Examp 1.8 l (CADR X) 3 (CAR (CDR XI) (CAADDR X I (CAR (CAR (CDR (CDR XI))) LAST returns the last oart of a list r~cb~djngto the following doflnltfonr (DE LAST (L) (COND ((ATOM (CDR C)) L) (7 (LAST (CDR I.))))) Exsm~ last (LAST (QUOTE (A 0 C))) 3 (C) (C,NIL) (LAST (QUOTE (A B, C))) 8 (0,C) 10.3 S-Ex~ressIon Modtfylne Funotlons The tollowlng funotlonr for manl~ulatlng S-rx~rr8s~ons differ from al l others in that they aotual ly modlf~ exlstlng l irt gttuoturr rather than canstruot lng new l 1 st structure. These funotlons shou Id be used wrth cputlon dnee it 18 e.sy to create 8ttuctur~s whlah w11 l eonfuse or destroy the lntrrarrtrr, RIP lacs8 the CAR of X by Y, The value of RPLACA thr modfifrd S-exoresalon X, Examp let (RPLACA (QUOTE (A 6 C)) (QUOTE (C D))) 8 ((C 0) 0 C) 3

C x 4 f"a9t'"'t + TVBvT'"-- T * TwCgTNTCT I BEFORE 1 -_- 1 -_- I I "_- 1 _-* I "-- 1 "-- I.L.--W-W--- rr---rre-rr I C I I I I3 INILl (RPLACD X Y) c RPLACD replaces tha CDR of X by Y. The value of RPLACD Is the rodlfled S-expresston X, (NCONC X b 1 X & 2,,, Xln) NCONC 1s siml [at in effeot to APPEND, but NCONC does not CODY nlst structures. NCONC modlfles list structures by reolaclna the nast element of X & 1 by a polntar to X42, the last element of Xb2 by a < ~otnter to X43, etc, The value of VCONC is the rnodlfled liat XbI, which Is the concatenatton of Xd1, X42,,,,, X4n, Exarm 1 es t (NCONC) = NIL (NCONC (QUOTE (A 0)) (QUOTE (C D))) a (A B C 0) --------- -----I...-.* 1 --.. I X d l I A I I * l a INILl BEFORE 1,,, 1,,, I 1 _-- AFTER

SAILQN 28.6 CHAPTER 10 18-4 10,4 S-Expre8slon Transtormlng Funatlons another. (LENGTH L) The tollowlng funotlons transform S-exprrssl~ns from one fbrm to LENGTH returns the number of to~wlevrl elementr of the llst L, LENGTH Is eaulvalant tot (REVERSE I.) (DE LENGTH (L) (COND ((ATOM L) 0) (T (ADD1 (LENGTH (CQR L)))))) REVERSE returns the reverse of the top l e ~ of ~ l list L. REVERSE Is eaufvalent tor (DE REVERSE (I.) (REVERSE1 L NIL)) (DE REVERSE 1 (L MI (COND ((ATOM L) M' (7' (REVERSE1 (CDR L) (CONS (CAR L) MI)))) SUBST substltutrs S-ex~rrsslon X for a1 I EQUAL oocurrrncer of S-expresalon Y In S-ex~resslon S, SUBST IS eaulvalent tot (DE SUBST (X Y S) (CON0 ((EQUAL Y SI X) ((ATOM S) S) (T (CONS (SUBST X Y (CAR S)) (SUBST X Y (CDR S)))))) Notrr (SUBST 0 0 X) (s useful for orrating a ~opy of the lirt X, Examp I@ t (SUBST 5 (QUOTE FIVE) (QUOTE (FIVE PLUS FIVE IS TEN))) 8 (5 PLUS 5 IS TEN) The folnowlng funotlonr perform rnop~!ngs of l k t 6 acoordlng vo the tunotlonal arguments auoplled. (MAP FFJ L) MAP a ~ ~ I l @ the s Cun~tlon FN of one argument to llrt L and to ruccrsrlve CDR8 of L untll L 18 reduced to NIL, the value of HAP \a NIL, MAP 19 raulvrlrnt to!

8 L. ~ SAILON 28,6 CHAPTER 10 (DE MAP (FN L) (PROG NIL L1 (COND ((NULL L)(RETUWN NIL))) (FN L) (SETQ L (CDR L)) (GO Ll)?) Exam I 0 I (MAP (FUNCTION PRINT) (QUOTE (X Y t))) r PRINT: (X Y 2) PRINT: (Y 2) PRINT: (Z) PRINT: NIL C MAPC 1s Identlcal to MAP except that MAPC appl fes function FN vo the CAR of the remalnlng list at each stet?, MAPC is eauivalrnt to: tde MAPC (FN L) (PRoG NIL L1 (COND ((NULL LHRETURN NIL))) (FN (CAR L)) (SETQ L (CDR L)) (GO L1))) Exarrp I e r (MAPC (FUNCTION PRINT) (QUOTE (X Y 2))) 8 c PRINT1 PRINT$ PRINT: PRINT# - (MAPLIST FNL) X Y if NIL MAPLIST applies the functlon FN of one argument to!!st L and vo successive CURS of L until L Is reduced to NIL, The value of MAPLIST is the list of values returned by FN. MAPLIST 1s eaulvllrnt vo: (OE MAPLIST (FN L) (COND ((NULL L) NIL) (7 (CONS (FN L) (MAPLIST FN (CDR L)))))) Exarp 10s: (MAPLIST (FUNCTION CAR) (QUOTE (A B C Dl)) r (A 0 C Dl <- (YAPLIST (FUNCTION REVERSE) (QUOTE ( A B C D))) a '((D C R A) (0 C 0) (D C? (0))

SAILON 28.6 CHAPTER 10 10-6 MAPCAR (a Id~ntloal to MAPLIST except that MAPCAR rppl ler vo the CAR of the rema!n!n~ list at each gtep, MAPCAR l8 eoulval,nt VO t (DE MAPCAR (FN L) 3 (COND ((NULL L) NIL) (T (CONS (FN (CAR L)) (MAPCAR FN (CDR L)))))). (MAPCAR (FUNCTION ATOM) (QUOTE (O() Y (2)))) (NIL T NIL) Examp 10s 2 (MAPCAR (FUNCTION NCONS) (QUOTE (A B C 0))) w ((A) (8) {C) ( I 10,6 S-Ex~r@~~lon ~earohlng Funotlons (ASSOC X L) ASSOC rearches the llst of dotted palrs L tor a palr whber CAR Is EQ to X, If such a palr is found it 1s raturnrd as the value of ASSOC, bthsrwlse NIL 18 returned, ASSOC 1s rqulvrlent tot (DE ASSOC (X L) (COND ((NULL Ll NIL) ((EQ x (CAAR L)) (CAR L)) (T (ASSOC X (CDR L))))) Exam I@ a (ASSOC 1 (QUOTE ((1,ONE) (2,TWO)))) 8 (%,ONE) FN SASSOC soarches the llst of dotted palrr L for a palr whore CAR Is EQ to X, If such a pair 18 found it I8 returned aa tho value of ASSOC, othrrwlse the value of FN, r funotlon of no argurntnfa8 1s returnad, (DE SASSOC (X L FN) (COND ((NULL L) (FN)) (( 0 X (CAAR L)) (CAR L)) (T (SASSOC X (CDR L) FN)))) Examp l e 8 (SASSOC 0 (QUOTE ((1,ONE) (2,TWO))) (FUNCTION (LAMBDA NIL (QUOTE LOSE)))) 8 LOSE 10,7 Character ~ f s Tran8formlng t Funotlons (EXPLODE L) EXPLODE transforms an S-rx~rrsslon Into a llst ol rln~le character identfflets ldentfcal to the seouenc@ of charroterr whlck would be produced by PRINC, Examp le 8 (EXPLODEC (QUOTE (OX,/-,DY))) (/(D x / - I - - D Y l l )

C SAILON 28,6 CHAPTER AO (FLATSIZE L) (LENGTH (EXPLODE L)) (MAKNUM L) i MAKNUM transforms a list of slngle aharacter identifiers (aotually takes the ftrst character of each identifier) into an S-ex~restlon identical to that which would bo ~roduoed by R E A O T ~ ~ those charaoters, MAKNAM however does not INTERN any ot the identifiers In the S-expression It produces, i Examp les t (MAKNUM (QUOTE (A P P L El)) = APPLE (MAKNAM (QUOTE (//,/I))) = /) READLIST is identical to MAKNAM except that READLIST INTERNS C- all identlfters in the S-expressfon It produoes, READLIST 1s the noglcal Inverse of EXPLODE, I, @,, (READLIST (EXPLODE L)) = L (EXPLODE (READLIST L)) L

CHAPTER 11 CHAPTER 11 There are three bash types of functlons on ident?flersr those whlch manipulate therr property lists, those which creatr new Identifiers, and those which control theh membershl~ in the ORLIST. NOTE: A l l functions descrlbrd in this chapter whlch expect an I d e n t ~ f ~ r r 8s one (or more) of Its arouments will give either erroneous results, or an error oondltfan If any S-ex~r@ssjon other than an identifier fs su~plfed, 11,l Property List Functions 1 (GET I P) GET is a functlon whlch searches the property list of the ldentlfler I looking for the property name whloh is EQ to P. If suoh a ~roperty name is found, the value associated with it 1s returnrd the value of GET, otherwlso NIL is returned. Note that confusion exists If the property is found, but its value I S NIL. GET Is equivalent to: (GETL I L) (DE GET (I PI (CON0 ((NULL (CDR 1)) NIL) ((EQ (CADR I) P) (CADOR 1)) (T (GET (CDDR I) PI))) GETL is another functlon ~hlch searches property ~lsts, GETL searches the property list of the ldentlfler I looklng for the first property which Is a merr~ber (MEMQ) of the llst L, GETL returns the remalnln~ ~ r o ~ e r tilst, y lncludlng the Property name If any such property wag found, NIL otherwise, GETL is equivalent to: (PUTPROP I V P) (RE GETL ( I L) (COND ((NULL (CDR I)) NIL) ((MEMO (CADR I) L) (CDR I)) (T (GETL (CDOR I) L)))) PUTPROP 1s a tunctlon whlch enters the aro~erty name P wlth property value V Into the ~ r o ~ e r tlist v of ldent\fler I, If the ~roperty name P fs already In the property llstr the old property value is replaced by the new one; otherwise the new ~topsrty name p and it$ value V are laced on the beelnnlng of the property I h t. PUTPROP returns V,

SAILON 28,6 CHAPTER 11 11-2 REMPROP removes the property P from the property llrt of Identlfler I, REMPROP rrturns T If thrro wes suah a proderty8 NIL athetwlsr, SET and SETQ ate used to change the values of var)rbles whloh are bound by rlthrr LAMBDA or PROG, or vrrlrbler are bound globaiiyo (See 7,1), e (SET E V) SET changes the value of tha tdentl tier spec 1 f led by the exprrsslon E ta V and returns to V, Both argumrntr are ev~luated, Notrr In oompllrd tunotfonrt SET can be used only on oloball~ bound and IP~cI~I varfables, SETQ changes the value of ID to V and returns V, SET0 evaluate8 V, but does not evaluate ID, (DEFPROP "1" "V"?'PW) r (PROG2 (PUTPROP (QUOTE I) (QUOTE V) (QUOTE P))(QUOTE 1)) DEFPROP 13 the same as PUTPROP rxorpt that It doeg not evaluate its argum@nts, and DEFPROP returns I, exam^ I@: (DEFPROP POSP (LAMBDA (XI (GREATERP X 0)) ExPR) (DE ttiqw "ARGSW "BQDYIf) DE plaoea the form (LAMBDA ARCS BODY) on the propeity llrt of ID under pro~ertv ExPR, It ID ~revfausly had any of the oropertle8 EXPR, FEXPR8 SUBR, FSUBR, LSUBR, or MACRO, than DE will return the nlst (10 REDEFINED), Othrrwlse, DE rqturns ID, Sam8 ar DE except drftnrr a functlon w'fth FEXPR prop~rt~, (DM "ID,' "ARGSW "BODYIf) Same as DC except deftnes a MACRO, (INTERN I) 3 INTERN puts the idrntlflrr I In tha p ~ ~ r ~ ~ bupket t l a t ot r OBLIST, if the ldrntlffrr lr prerdy a member Of the 6BLIST4 than INTERN return8 a polntrr to the ldentlflrr already there, Othrrwlsr, INTERN rrturns 1. 3 T

C SAILON 28,6 CHAPTER 11 11-3 I Noter INTERN Is only neoessary when an Ident~fter whlgh was orsated by GENSYMB MAKNAM, or ASCII needs to be unlouely stored, C3 (REMOB "X11" "X12,,, ")(inq1) REMOB removes 811 of the ldentffters X l l B X42, the OBLIST and returns NIL, None of the Xdl's are evaluated,,,,, X hn from C C 11,3 Identlfler Creating Functions The followlne funotlons create new ldentlflers but do not INTERN them onto the OBLIST, (GEhSYM) GENSYM Increments the generated symbol counter and returns a new ldentlfler 3pec:fled by the counter, The GENSYM counter is initialized to the Identlfler G0000, Success(vb execution@ of (GEhSYM) w l l l return, lnl tial lzes generated ~~rnbo l counter to th@ ident i f let CSYM 1, and returns 1, CSYM does not evaluate its argument8 C (ASCII N) ASCII creates a slnsle character identlf ier whose ASCII d n t C ~xarr,~ le 8 (ASCII 101) Is an Identifier with print name "A",

C SAILON 28,6 CHAPTER 12 12.111 CHAPTER 12 FUNCTIONS ON NUMBERS C There are two types of functions which operate on number8 to areate new numbers! arlthmetlc and log!cal, C Unless otherwise noted, the to1 lowing ar lthmetlo functibns are deflned for both Integer, real and mlxed comblnatians of arguventsr and evaluate all thelr arguments, The result fs real if,ny argum~nt 1s real, and Integer if all arfthmetic functfons may oause overflow which are fnteger, Most Produces an error message, (PLUS X 1 X2,,, Xn) X 1 + X2 +,,, + Xn (DIFFERENCE X 1 X2,,,Xn) a X1 - X2 -,,, -Xn T L (TIMES X 1 X2,,@ Xn) a X i * X2 *,,, * Xn (QUOTIENT X1 X2,,,Xn) = X I / X2 e m, Xn C For Integer arguments, *QUO and QUOTIENT glve the integer Part of the teal quotient of the arguments, IL (REMAINDER X Y),,, X a (X / Y) * Y Noter Ramalnder Is not defined for real arguments, (DIVIDE X Y) = (CONS (QUOTIENT X Y) (REMAINDER X Y)) C (GCD X Y) GCD returns the greatest oommon dlvl~or of the lntrgers x and Y,

SAILON 28.6 CHAPTER 12 (FIX X) returns the largest lntrasr not greater than XI ex em^ 19s t (FIX 1) 8 1 (FIX 1 6 1 ) * 1 (FIX -1,l) = -2 not' -1 Other arlthmetlc funotlons not drflned in the LISP intrr~r~t~r can be drflnad a8 followst (FLOAT lo (*PLUS X 0,0) (RECIP X) 8 (QUOTIENT 1 X) 3 (ROUND X I = (TIMES (SIGN X). (FIX (PLUS (ABS XI 0,S))I Exam le8t (ROUND (5) 1 (ROUND,491 = 0 (ROUND -@49) t 0 (ROUND -35a1) -35 (MIN X Y) + (COND ((LESSP X Y) X) (Y)) (MAX X Y) s (COND ((LESSP X Y) Y) (XI) Examp l @st (MINUS 1) (MINUS -1,2) (PLUS 1 2 3m1 (PLUS 6 3-2) (DIFFERENCE 6 3 1) (TIMES -2 2,0) (QUOTIENT 5 2) (QUOTIENT 5a0 2) (QUOTIENT -5 2) 2 (REMAINDER 5 2) (REMAINDER -5 2) (REMAINDER 5,0 2) (ABS *32aS) (FIX 32*5) (FIX -32@5) a 1 = -1 undaf Inad 32m5 32a a -33, The following functions are Intended to o~erate on INUM rnd FIXNUM arguments, but thrlr result8 are not drflnrd for BIGNUM or ~~o~um.(rerl) ~rgumrnts,

C SAILON 28,6 CHAPTER 12 1213 BOOLE causes a 36 blt Boolean operation to be ~erformrd on Its arguments, The value of N s~ec~fles which of 16 Boolean operations to p@rforrn, For n n 2, each bithi In ( BOOLE N A B) 1s deflnsdr For n > 2, BOOLE Is deftned: (BOOLE N,,, (BOOLE N (BOOLE N X i X2) X3),,, Xn) LSH ~erforms a logical left shlft of N laces on X, I? n 1s negative, X wl l l be shifted right, In both cases, vacated bits are fllled wlth zero$, C Exam~les wlth IBASE = 8 (BOOLE 1 76 133) = 32 (BoQLE 1 76 133 70) = 30 (BOOLE 12 13 0) 777777777764 (BOOLE 7 7 12) = 17 (LSH 15 2) 3 64 (LSH 15 ~ 2 ) 3 (LSH -1-2) 0 177777777777

CHAPTER 13 CHAPTER 13 PROGRAMS The l'program feature" al low3 one to wr lte ALGOL-IT~~ sequencer O f Statements with Program variable3 and label$. (PROC "VARLIST" "BODY") PROG is a functtan which takes as arguments VARLISt, a list of program variables whlch are lnltlalized to NIL when the PROG is entered (see 7811, and a BODY which 1s a list of iabels (which are identifiers) and statements which arr nonmatornlc S-ex~re8sfons, PROG evaluatrg Its statements In sequence until either a RETURN or GO ls evaluated, or the i! st of staternrnts is rxhausted, of PROG I S NIL, In whloh the val ur value X, RETURN causes the PRQG contalnlns It to be exttsd wlth the (GO "ID") GO oauses the seouenoe of control wlthin a PROG to be transferred to the next statement following the label 1, In Interpreted PROGs, (1 ID Is non-atomlc, It is repratedly rvrluated until an atomlo value is found. Howev@rt in G O ~ led R ~ PROG9, 10 (3 evaluated only once, GO oannot transfer Into or out of a PROG, ~ote: Both RETURN and GO should only occur efther at the top level of e PROG, or in com~os/tlons of COND, AND, OR, and NOT whhh are at the top level of a PROG, ExatrpI~: The function LENGTH may be defined as followst (DE LENGTH (L) (PROG (N) (SETQ tj 0) L1 (COND ((ATOM L). (RETURN N))) (SETQ N (ADD1 N)) (SETQ L (CDR L)) (GO l.1))) PROGZ evaluates all expressions X l i X42,,. Xln, and returns the value of ~ 4 2,

SAILON 28.6 CHAPTER 14 CHAPTER 14 Semantlog: A device-name Is elther an ldentlfler endlng with colon ( 8 ) which is the name of some Input or output devloe, or r lht aontalning P ~rojeot-programmer number which lrnplloltl~ sprclfl98 the disk, fllsnarne is either an ldentlfler which specif:rs a fllrname A with a blank extensfon, or a dotted pair of f'llenamr and e%t@n~ion. In both cases the f'llenane appllrs to the most reoentl~ (to the left) speclfled devfce-name, 14.2 Channel Names Channel names can a~tlonally be asslgned to files aeleotsd by the functions INPUT and OUTPUT, A channel name Is any identiflet whlch Is not folnowed by 4 colon, If no channel name is saeolflrd to INPUT or OUTPUT then the ~hannel name 1 is assumed, The ohannel name NIL speoifle$ the telety~~ in thr funttlons INC and OUTC, Up to 14 ahannels may be aotfve at any the, 14,3 Input 14,3,1 Ssleotton and Control (INPUT "CHANNELw, "FILENAME-LIST") INPUT releases any file previously lnltial\zrd on the channel, and initializes for ln~ut the flrst fjlo specified by the fi lename-llst, INPUT returns the channel If one was soeoiflad, T otherwise, INPUT does not evaluate Its arguments, (INC CHANNEL ACTION) INC selects the 8~eclfled channel for in~ut, The channel NIL selects the tolety~e, It ACTION NIL then the ~r~vlously srlroted Input file is not released, but only desele~tedn If ACTION T then that fl!e 13 released, maklno the ~ r e v l o u s l sel@~t@d ~ channel

SAILON 28.6 CHAPTER 14 14m2 available, At the top Irvrl, ACTION need not be spoolfled, The Input functtonr in 14.3.3 tr081ve Input from the 8@l@~t1d input ahannr I, When r f I le on the selected channr l 1s exhrurtrd, then the nrxt flle in the fllenamr-l?$t for the channel 1s fnitlallzrd and in~ut, untl l the f! lenamr-list is exhrutted, Then the telety~e 18 rutomatleall~ selectad for Input and (ERR (QUOTE SEOFS)) Is oal led, The use of ERRSET around any funct 1 ns whloh rcee~t input therefore rn~ker it ~osslblr to detect end ot f! la, If no ERRSET Is U~edr control return8 to the too level of LISP, fnc rvaiuateu It8 arguments, and returns the orevlously rrlroted ~hrnnrl name. In ordrr to READ from rnultl~lr Input 8ourOes8 saprrats ehannelr should br lnftlallzed by INPUT8 and INC orn then selrot the appro~rlate ohannel to READ from, Exrm~lea The folnowfng show r falrily t~~ic.1 sort of manlpulrt\on of two f f Ies at once, (LAMBDA (FILE) (PROG KHAN1 CHAN2 WPRi EXPR2) (SETQ CHANI (INPUT DSKt Fool)) t l n j t l a l l ~ FOO ~ with ohrnn61 name ~3 (SETQ CHAN2 (EVAL (LIST PINPUT (GENSYM) WSKI FILE))) rthls fl la Is given @ CENSYH channel "arn@ to pprva,t with any rxirtlng channels LOOP (INC CHIN1 NIL) ;srlrct first chrnnrl (SETQ EXPR1 (READ)) ;read an expretsfon from FOO (CON0 (teq EXPRl (QUOTE *EOF*)) (GO EXIT%))) ;end'of ftr8t t 1 1 @? (SETQ EXPRI (CAR EXPRI)) ;undo effect of ERRSET (INC CHAN2 NIL) lopen seoond channel (SETQ EXPR2 (ERRSET READ)) ;road an rxprsss!on (COND ((EQ EXPR2 (QUOTE + OF*)) (GO EXIT2)) lend of thlr f/l@? ((ATOM CXPR2) (GO ERROR))) rrerd error? (SETQ EXPR2 (CAR EXPR2)) ;undo effeet of errsrt 3 3 ERROR EXIT1 EXIT2 ) @ @ ) @ O # ) @ ~ O @ # # @ * @ ~ # * ~ ~ ~ * * V (GO LOOP) )error routhe ;e%ft when flrrt tile ends flrgt ;extt when srnoond fl lr ends flrrt eto, (DSKIN, "FILENAME-LIST") 3 In loading a fllr Into a LISP oregram, it is not nbrmai~y ne~essary to make use ot the full senrrallt~ available in 1NC and INPUT, The tunet!on DSKIN is suopllrd for thh PU~DO~I, 1t ha$ the ram8 rffrot rr doing INC and INPUT on its ar9ument8, except thrc no ohannrl name is adrnlarlblr, rod no device nrme 18 roqujrrd, The 3

channel name w i l l always be T, and 'DSK' w l l l be sup~lird as a devloe name, If none Is glven. Exarrp I e I (DSKfN F00 DTAS: BAR (1,JMC) (SIMUaMAN)) w l l ( READ the files FOQ from DSK:, BAR from RTA3r and SIMU,MAN from the disk area CI,JMCI, When reading an h u t filer it is eometlmes desirable to know the page and lfne being read from. PGLINE returns thr dotted oatr (wee number, llne number) for the selected Input file. The page number is applfcable only to STOPGAP ffle3. If the file hag no lrne numbers, PGLINE will always return (1, 01, 14.3.2 Teletype Iwut Control When Input is from the teletype, READ 1s terminated by either an entlre S-expresston or by an tncomolete S-~x~resslon tollowad by altrode, Altmode has the effect of t y ~ f ~ a g spa00 fol (owed by the ap~ro~rlate number of rtaht Parens to complete the S-sxpresslon. ~ h l s feature Is ~artlcularly useful when an unknown number of rlght parens are ngeded or when In (DDTIN NIL) mode, DDTIN Is a functlon whloh selects teletype Input mode, With (DDTIN NIL), and typing to READ, READCH, or TYI, a rubout wjll delete the last character typed, and eontrol U (tu) wll l delete the entlre last ilne typed, Inout Is not seen by LISP unttl elther altrnoda or ~arrla~e return 1s typed, Wlth (DDT~N T) and t ~ ~ l nto s READ, a rubout w i l l delete the entlre S-expresston being read and start reading again, Note: (DDTIN T) Is not recommended when the the-sharing system 1s swapping, sfnce the Program 1s reactivated (and hence awrpped Into oote) after every character typed, 14,3,3 Input Transfer! (READ) READ causes the next S-expression to be read tram the selected Input device, and returns the Internal re~ressntathm of the S-ex~resslon, READ uses INTERN to guarantee that references to the same ldentlfler are EQ, READ wlll acae~t any S-expression whl~h conforms to the following syntax:

SAILON 28,6 CHAPTER 14 (readable S-sxpr> :;= <atom> I;= @(readable S-expp) 1:s :. (<readable S-exprllst) {,treadablss-expr))) 1 Ctunba lanced S-exprrsr~on I lrt>j tt= ( o NIL The del lml ter drslgnrtes that the fol lowfng roadable S-expresston la to be auoted, Exam0 last @A mean8 (QUOTE A l @(@A B) means (QUOTE ((QUOTE A) 3)) @@A meant (QUOTE (QUOTE A))) The de l lml tern and "J' operate as "ru~rr-~arenthrirr", A right bracket "Jvt wtll close all open left ~arrnthrrrs "1s ud to the matching left brrckst wcn, If there 1s no macehlng left brrokrt, it wl l l c lore the rnt l re Swrx~ressl on as does a I tmodr, No syntax 1 s glven for unbalanoed-s-expresslonl(lat, but It 1s Intended to maan an ~~expresrlon-l!st which Is Ir~ktng one or more rlght parrnthrsrs, (READCH) READCH Causes the next character to be t@ad from the a~lmatrd fnput devloo and return8 the cortes~ondtn~ atnslo character!dsntlfier, READCH also uses INTERN, TY! causes the next charaater to be read from the s@leoted input devlce and returns the ASCII cad0 for that ohatattar, A functlon TEREAD rhleh Ignores all oharsttrtr until a nlne-feed Is seen can be detlnedr tde TEREAD NIL (PROG NIL L (COND ((EQ (TYI) 12) (RETURN NIL))) (GO L)))

CHAPTER 14 14,4,1 SelectIan and Control (OUTPUT "CHANNEL", "FILENAME-LIST") OUTPUT initial f2.s for output on the specifled channel the sing l e f 1 lo specl f l ed by the f 1 l @name- l l st, OUTPUT does not eva l "ate Its arguments, and returns the channel name if aaet~fird, f otherwise, (QUTC CHANNEL ACTION) OUTC selects the s ~ e ~ i f i echannel d for output, yhe channel NIL selects the teletype* The outp~t functlont in 14,4,3 transfer output to the selected output channel, If ACTION = NIL, then the prevlousl~ is not closed, but only deselected, If ACTION T then that file 1s closed, I e m, an end of f i lr is witten. QUTC evaluates its argurrents and returns the prevloualy selected channel name, A t the vop level, ACTION need not be sprclfled, Exam~lcst ( A t the top level) (OUTC (OUTPUT LPTI) T) (OUTC NIL TI (OUTPUT FOO DSK: BAz) (OUTC (QUOTE FOO) NIL) selected outout f'i lr LINELENGTH 1s used to examine or change the maxlmum outaut nlnelength on the selected output channel, If N NIL then the current llnrlength fa returned unchanged, otherwlss the 1 lnelength 1s changed to the v ~ l u e of N which Is returned and must be rn ~ntrger, (CHRCT) CHRCT returns the number of character positions rrrnalnlng the output line of the selected output channel, When characters are output, if CHRCT is made nsgatlvrr an ASCII 176 followed by a carriage-return and a Ifnewfeed are out~ut, These characters are com~jetel~ Ignored on fnput, (See Chapter 3). 14,4,2 Output Transfer on PRINi oauses the S-expression S to be prlnted on the ~elecfed outcut devlce wtth no ~rsoedlne or following snacrr, PUN1 also inserts slasher (**/r) before any characters in 1dentifTers whlch

CHAPTER 14 would be #yntaotlca(ly Inaorrgot othrrwtse (80s Chapter 31, Double quotat around rtr are pr 1 nt@dr (PRINC S) PRINC Is the same as PRIN1 except that no slaahes are inserted and double auotrs around strings are not prlntrd, TERPRI prlnts a carr lago-raturn and I In@-feed and return8 Chr value of X, X may be omltted if tbe value of TERPRI 1s not ured, Is the same as I (PRINT S) (PROC2 (TFRPRIl(PR1NC X I ) N, TyO pr Int8 the oh8raetrr whose ASCII value 1s N, rnd tetuin8

ARRAYS (ARRAY "ID" TYPE 041 842 @,, B&n) ns 5, ARRAY is a functlon which declares an array with namr ID, and places an array referencing function on the Property list ID, TYPE determines the type of an array as follows: TYPE INITIAL VALUE ARRAY ELEMENT T NIL LISP S-ex~ress[ons stored as aolntersc 2 per word, NIL 0,0 REAL numbers stored one per word In pop-6/10 f loat lnp polnt reprasrntatlon. 1 36 blt 21s eomplernent integers stored 1 1 per word, I n blt posltivr lntrgers ~lckrd C36,Inl per word, 011 842,,, Bbn are array subsorlpt bounds which should evaluate to either ~osltlvr lntegrts s'i, or to dotted pairs of lnte~ers. Ubl) where LbIsUWt whlch s~oolfy lower and Upprr 8ubscrlpt bounds as to1 10wsr 04 1 LOWER BOUND UPPER BOUND LENGTH I I I 1 I The elements of an array are referenced by! (<array name> 141 142 9,. ten) where L4.J < i4.i < UhJ. - The ARRAY sub~crl~ts PJ must be fntegers, Reference8 to mrmorv nocations outslde of the area reserved for the array are ~rohtblted and kill cause an I 1 legal memory?efqt@nce message, Atray elements are atored In BINARY PROGRAM SPACE, 1) To declare a 1 dtmonslonal array CHARS of 7 blt eharactars and with subscripts 1 t o 501 (ARRAY CHARS 7 (QUOTE (1 50))) The first element of CHARS 1s referenced:

SAILON 28,6 CHAPTER 15 15-2 2) To declare a 2-dfmrndonol array A of REAL numbers and wlth aubsorlpts 0 5 1 < N, 0 I J < MI (ARRAY A NIL N MI 3) To deolrre a 1-dimenslon8l ortry FOO of S-expressfons and with subscripts mk S f 5 Kt (ARRAY F00 T (CONS (MINUS K) K)) +(EXARRAY "ID" TYPE 041 842 o e e Bdn) N 5 5, EXARRAY 1s fdrntlorl to ARRAY rxoopt that array elrmrnts are stared in the body of a subroutlnr lorded by tho LOADER (srr ADPO~$\X HI, and exarray elements are not initial!zed, The array iefrren~1n~ aubrout lne la stored in BINARY PROGRAM SPACE a8 with ARRAY, EXARRAY searches s~mbol tables as dorg CETSYM (see ~ ~ p e n d ( H), x Notrl Both ARRAY and EXARRAY eonsum@ BINARY PROGRAM SPICE, If there Is Insutflolant room there (sea A~~endlx C) the rrrbr mrrsrgr "BINARY PROGRAM SPACE EXCEEDED" wlll r@sult, (STORE VfID" Irl 142,,, lrn) value) STORE changes the valur of the spealflrd array rlrmrnt to value, and roturns value, Note! STORE evaluates Its 8eoond argument ffrst, Examplesr Wlth the arrays daolared ~revloualyr 15,1 Examlne and Depoglt (STORE (FOO B) (QUOTE (A 0))) (STORE (FOO (BAZ L)) $1 (STORE (A I J) (A J 1)) (STORE (CHARS 1) 17) c EXAMINE rrturne rs an Integer the content8 of mrmopy [DEPOSIT N V) DEPOSIT stores the Integer V V, location In Vemory loeatlon N and ;@turns

CHAPTER 16 CHAPTER 16 OTHER FUNCTIONS (TIME) TIME returns the number of mllllseconds your Job has camouted slnce You logged Into the system, (ERRSET E "Fn) ERRSET evaluates the S-expression E and If no error oocurs durlng Its evaluatfon, ERRSFT returns (LIST El. If an error occurs, then the error message wlll be sup~r@ssed if and only if F # NIL, and NIL is returned as the value of ERRSET, If the function ERR 1s called during evaluation, then no message Is printed and ERRSET returns the value returned by ERR, The folnowing example shows the use of ERRSET to kerp trvlno vo l~ttlnllze the line prlnter until it Is availabl@! (DE LPTGRAB NIL (PROG NIL L (COND ((ATOM(ERRSET (OUTPUT LPTI) T)) (WAIT) (GO L))))) where WAIT is some tunatlon (such as the time-sharing sleep UUO) which causes a drlay, (ERR E) ERR returns the value of E to the most recent ERRSET, or to the top level of LISP If there Is no ERRSET, (*RSET X I flag NIL Inltlally *MET sets a special flag In the Inter~reter to the value of X, and returns the revl lo us value of the flag, Norrnall~, wlth (*RSET NIL), whec an error occurs, sprclal varlsbles are restored to thrlr top nevel values from the s~eclal ~ushdown list, and Chs top level READ-EVAL-PRINT loop Is entered, Wth (arset T), specials are not restored~ ndthar pushdown nist Is changed, and the READ-EVAL-PRINT loop 1s entered. Thir makes t t ~ossible to examlne the variable blndfngs fmmadlntely attar an error message has been prlnted, To restore special bindings to their vop level values and return to the top level, t y ~ e a be1 1 (u), or evaluate (ERR),

SAILON 2896 CHAPTER 16 $6'2 BAKGAG art8 a rprolal flag in the ~ntrr~rrtrr to the vrlu, of x and return8 the ~revloua srttlno of the flag, Only If the flag # NIL when an error occur88 then a broktrace Is prlntrd a8 iet(rs of tunetlon cal Is, determlnrd from the regular Pushdawn I trt, startho?tom the most recent funatton 0811, If X is an integer, then X rpeoifle8 the numbat of regular pushdown list words to ]nclude the backtrace, If X Is T, than threntlre regular ~ushdown tist 1s backtraord to thr most rrornt ERRSET, The format for ~ r l n t l n irl ~ r>r lntout mean I ng fn1 ~ vl a uated Notel FOO) r EVALARGS tni - ENTER The arguments to fn1 rr@ bdno before enter lno funet Ion 1, The funotlon 1 la entered, 3 - fnl Some Internal LISP functlon called funotion I, The BACKTRACE prtntout is ottrn confused by oomdlrd function calls of the form (RETURN (FOO X)) which 18 comp?lrd a8 (JCALL (E FDO)) whlch can be changed to (JRST rntranor to whloh will not show up in the BACKTRACE, INITFN selects the function of no arfaurnente FN ar rn Inltlallratlon functlon whloh 1s rvaluatrd after a LISP rrror return vo the top level has oacurred or whenever a BELL is t ~ ~ e d INITFN, returns the prevlougly selected lnltlallz~tlon functlon, Inltlallzat~on funotionr are ueeful when it 1s drrjrablr to ohanae the top I W @ I of LISP, For Instance8 (INITFN (FUNCTION EVALQUOTE)) aauses the too level ta become EVALQUOTE Inatead of EVALq

APPENDIX A APPENDIX A ALVINE by John A l len ALVIN is a LISP editor which 1s very convenient for Interactive debugging, ALVINE allows one to edit both functton definltlons and S-@x~resslon values, ALVINE Is oharacterlzed by the slmpnlclty wlth which one can correct a ~atbnthe~l8 mismatch and make context searches and replacements, Thls slm~~tclt~ arises from the data structure ALVINE Uses to represent an ~-expresslon, A l l S-exeresslons are flattened Into a llat of atoms lncludtng the atoms XLP, XRP and XD which represent "Iw and Beoausr of this re~resentatlon, ALVINE looks more I lke a string type text rdjtar with the smallest unit of resolution bolng a slngle atom or ~-ex~r~sslon dellslter (XLP XRP or %Dl, ALVIN has a ~ointer whloh oan move through the string belng edited, The editing funotlons affect only the string to the rhht of the polntet, ALVIN also contains functions for rnrni~ulatin~ In~ut~outdut f~les, and GRINOEF which Is useful for prlntlns tunctlon deflnh~ons. ALVINE 1s not ordlnarll~ a rssldent part of the LISP ~ystern, but is aut~mntlcally loaded whenever the funttlon ED is called, (ED ED loads ALVINE If It 1s not already loaded, If X t NIL then the edltor is entered, If X = T, the editor is not entered. ~hts 1s useful to load GRINDEF wrthout entering the editor. a ram the top level of LISP, (ED) I S the Sam9 83 (ED NIL). (SPRINT X Y 1) SPRINT prlnts S-expression X In a $~eelal format whhh auto ratio all^ indents according to parenthesis level, Whenever any sub-s-rx~resslon of X cannot flt entirely on the same ~rlntjng line, vhen its sub-s-expressions ara printed on separate llnrs with rnetchlng indentatton, The parameter Y specif b s the lnltial left hand column Indentatton, SPRINT use9 CHRCT and LINELENGTH to determine the number of ch~racters remaining on the print ~Tne, GRINDEF Is used to print the deflnltlons of functions and values in DEFPROP format, GRINDEF uses SPRINT to print functfon deflnltlons in a hishl~ readable format, GRINDEF orfnts all

~ropertlrs of the ldrntlflers Fl, F2,,,, Fn whloh are In the lht XXXL whlch Is lnltlallzed to EXPR, FEXPRt VALUE, MACRO and SPECIAL, Examplet (CRINDEF PLUS) (DEFPROP PLUS (LAMBDA (L) (*EXPAND L (QUOTE *PLUS))) MACRO) Descrl~tton of the Command Struotura Each oommand to ALVINE conalsts of a slngle eharaotor (possibly ~rrcedrd by a number) (01 lowed by a rtr 1n0 of argumrnts. These commands modffy the text fittrlng presently oeou~ylng ALVINE's buffer, When text \a lntroduc~d to ALVINE a ~ o ~ n t r/r r attached ~rrcrdtng the first objrct in the buffer, ALVINEts command8 rllow the user to move thfs pointer through the buffsr, ALVINE'8 text oodlf~lng eommands only affeot the string to the right of this polnter, w l l l In the fol lowing eommrnd darer lptlon8, "~olnter st!nov mean the string to the rlght of the ~olnter, and HSvq w 1 I I mean an altm~de, A l l of the command8 whloh allow a re~etltion argument n assume 1 If n Is omitted8 COMMAND MEANING DESCRIPTION Ba l anoed? Prlnt the buffer sfr1na8 No attrmpt 1s made to mrko thr output Pretty8 Examlnes the number of ~arrns In the buffer string, Raturns theicount of left and right 3 parens I f unbalrnordl othrrwlse re~i1ea "BALW8 Count For readabf I ~ Y the, cammands ffdn, ~ M W, tl>??, n<nt 'rsf', and "W", WI 1 ~rlnt an lnltlal srgment oi the 3 polnter buffer, "ncm #at$ the length of thls Prlntlng segment to n objsot~~, Ds latea the f I r st n ft~bjaotsw to the rhht of the polntri, 3 D l letrs the t lrst n S-rx~rrsslons to the right of thr dolnter, 3

~ APPENDIX A A-3 Get GRINDEFS the ldentlflers referred to by x on devlco Y using file name z, If X is a list of tdentiflet then each element of x 1s CRINOEFed If x Is an atom, then tho value of x is used as a list of atoms to GRINDEF, G will convert an S-expression with name x into ALVINE form, move It Into the ALVINE buffer and ln!tlallze the pointer to the left hand end of the buffer, GET looks on the ~roperty list of x for the, flrst property In the list XXXL I whlch Is lnitiallz@d to (FEXPR and,111 handle them Dto~erl~a ALVINE format was dercrlbed rarller as a slnelr level ljst of atoms including the s~rclal atom8 XLP, XRP, XD, I Insert Match Put Insert aomes In two flavorst ~ 1. I$xIl Insert "xft lmrnedlate~v to the rlght o? the pointer, 2, Ix$y%l Insert "yv after the first occurrenee (In the pointer string) of the strlna "xn, "xv may be a corno~rts strlng or desorlbrd by elll~sl8 a3 ttwa,tz't If 9" Is X then "yfl is introduc to the edltor as the ourrent str InQ, Move the polnter n S-ex~re~slons to the rlght of the current nointer ~osltlon, If n is negative, move n S-rx~rrsslons left, If there is no suoh S-rrpresslon the ~ o l n ~ eis r not moved and the bell 1s sounded,. Converts the edttor strlng from and puts it baek on the property 11st of x wlth the aporoor!atr ~rooertu. I ALVIN tormat to an S - ~ ~ ~ p r s ~ l o n

<toi~ows P) same as P exoe~t no tunctibn name nbcd be rprc~f lad, Q puts the S-ex~resrlon In th6 edttor buffer back on the ~ r o ~ r r t(1st y of the Identltler the lrst G s~solfled, 3 R ~ D I ~ o I the ffr~t ocourrsnor ot tr % tt by "yne A8 ~ l t "Iw, h f?xw may be d@acr/bed e l l l p t ~ o r ~ and l ~ ~ If "yqr 1s X, the f I rst ocaurranoe of o x " 1s deleted, 3 Search tor tho nth bccurrancr of the string "xw (In the potntrr string), If found, thr ~olnter 18 moved to the brglnnlng of the rtr lng followlno that occurrrnor, If lesr than n occurrenors,arr locrtad, the pointer Is ~ositloned after the last suoh oc~urronoe. If none are found thr pointer 1s not mbvrd, I "xw IS not ~lvrn, tor,, wnssn, than the Iagt dvrn re&roh~str\na I S Ulldn READS and define8 tho $unot\ons sprclflrd by th@ (1st x from device y uwlng z ar r tllr name. 11 x is an atom, then the val.ur 3 ot x is usrd a8 a Ibt functlon names to READ, U drlnts the name9 of the tunetfonr rr it drtinea them. The sprelf(od file must be in GRINDEF tormatc Print the flrst br'lancrd Prren arctlon to the rlght of' thr D O ~ C In paeudo CRINDEF format. Prlntg thr brglnning of thr Dolnter str lng. 3 These commands are dual1 they move the string palnf~r "nn ~bjaats to the rlght or left ;e8p@ct)vrl~. If v* fa auoh that rithrr the left or right snd of the t t r l n ~ would be rxeredrd, thr ~olnter 1s set to that extreme and flbellv 1s tvprd. 3 To resat to the extreme left of the string "0CW may be usrd, 3

0 AN EXAMPLE OF ALVINE This command returns control to LISP, ALVINE'J buffer Is [aft Intact, and returning to ALVIN # the user will find the pointer at the left hand end of the o('d str lng, Be1 1 to return aontrol to ALVINE4s command-l lsten-loop, may be used durfn~ any command Note! Bell, space and alt-mode are re~resrnted by W,, and $ rrspectlvely. 0 (ED) I X %(DEFPF?OP TEST (LAMBDA $1 the gtrlnq bounded by w91 1s!ntroduoed to ALVINE (DEFPROP TEST (LAMBDA I ~ r l n the entlre ALvINE buffer 0 0s 2LPS 0 RPS * I LAMBDA $ (X) (CAR YI EXPR) $1 append the string bounded by "$" to the buffer I) 0 BS 4LPS 3 RPS 0 I CAR Y S)O ; add the deficient rlght paren BS BAL ; 0!b VS (DEFPROP TEST (LAMBDA (XI (CAR Y))EXPR) * P TESTS; convert ALVINE string to LISP function * 0 9 ; exlt ALVIN I the fol lowlng oomrnands would also have the same i 1, "l1<ft,"i tls?' Z 2, "SYS*, I $If

SAILON 28,6 APPENDIX A TSi now talklng to LISP T (TEST (QUOTE(A 8))) V UNBOUND VARIABLE-EVAL LOSE 3 (ED) r rementar ALVINE, 0 ws (DEFPROP TEST; "Gtt need not be executed slnce the buffer 1s always left inta 4 R X % Y S 1) * P TSw I flu8h lnaortr~t "~ut" oommand by typing bell, (n) I) PTEST S 1 rrdeflnr TEST I) 9 3 (TEST A (ED) * 5 > = (Y 1 I) gc O (QUOTE(A B)))$ ; try rgaln I wln ; ohan91 ~rtnt count I) M $ (CAR Y)) a E $ 0 A s (REFPROP TEST (LAMBDA 0 W $ ) EXPR 0 < $ r(defprop TEST( ty))expr) I) R TEST ctr) %%% * A $ (DEFPR0P)EXPR) 1 same ettaat b ~ t 1, "SDEFPROP S", "6D" 0

APPENDIX 8 ERROR MESSAGES The LISP lnter~reter checks for some error condltlons and prints messages aeoordln~l~, Many erroneous condltlons ara not tested and result In elther the wrong error message at some latev time, or no error message at all, In the latter oase the system has scvewed YOU (or Itself) without oomplafnlns, When error messages are ~rlnted, It is usually dltficult to determlnr the function whlch caused the error and the functions whtch called It, In thts situation, (BAKGAG T) wlll turn on the BACKTRACE flag which causes the helraroh~ of function oalla to be printed as described In the next seotlon, The following Is an al~habetlcal ltstlng of error messages, Chelr cruse, and In some case@# thetr remedy, Some error mesaaaas prtnt two 1 Ines, such as: FOO UNBOUND VARIABLE a EVAL These messages are des~rlbed last in the Ilattng, and are of the torn5 X <message> BINARY PROGRAM SPACE EXCEEDED ARRAY, EXARRAY, or LAP has exceeded BINARY PROGRAM SPACE, ALLOCATE more BPS next tlrne, CAN'T EXPAND CORE INPUT, OUTPUT, LOAD, or ED fat led to expand oore, Your Job Is too large, CAN'T FIND FILE INPUT The Input f i l e was not found, YOU probably torgot to the fllr name extensfon, or a legal name list, DEVICE NOT AVAILABLE INPUT or OUTPUT found the speclflod devloe unaval lable, other Job is probably using it, Some DIRECTORY FULL The directory of the output device 1s full,

SAILON 28*6 APPENDIX 0 DOT CONTEXT ERROR READ does not I Ike dots rdjaernt to Patens or ~thrr dots, FILE IS WRITE-PROTECTED OUTPUT found that the s~eoltled file is wrltr-~rot$~ted, FIRST ARGUMENT NON-ATOMIC PUTPROP GARBAGED OBl,IST ILLEGAL DEVICE An attempt was made to PUTPROP onto a n~n*ld@ntjf/rr, Some member of.the OBLIST has been garbawd, You are fn trouble, INPUT or OUTPUT was attempted to elthrr 8 non-rxlrtrnt davloe or to a devioe of the wrong type, I INPUT from thr Ilnr~rlntsr, ILLEGAL OBJECT * READ INPUT ERROR READ objects to r~ntrctlcall~ lnoorreet S-rxdrrsrlong, Bad data was read from the selected devloe, - MORE THAN ONE S-EXPRESSION MAKNAM MAKNAM and READLIST objeot to a llst whloh constitute8 the ohar&ctrrs tor more than one S-erprraafon, NO FREE STG LEFT A l l free storage Is bound to the OBLIST and protected el Is (sueh as 1 l st ARRAY or l l s), and bound var lab les on el ther the REGULAR or SPECIAL pushdown Ilst. Unblndlng to tha top level w l l l U S U ~ ~ rrlerrr ~ Y the storafdr, If YOU are In a bfnd +or more tree storage, NO FULL WORDS LEFT try to REILLOC aa drgoribrd in APPENDIX Ce A l l full words are befng used for nrlnt nemes rnd numberse Tho problem and It8 solutlon are stmllar to FREE SIC, NO I/O CHANNELS LEFT

NO INPUT or OUTPUT fatted to flnd a free I/O channel, Thrre 1s a mawlmum of 14 aotive I/O channels, INPUT - INC n attempt was made to seleot a channel for Input ~ 7 t h INC whlch was not Inltlalized wlth INPUT, NO LIST - MAKNAM (3 NO OUTPUT MAKNAM and READLIST objeot to an empty Iht, OUTC 0 NO PRINT NAME - INTERN 0 OUTPUT ERROR OVERFLOW An attem~t was made to eeleat r channel for output with OUTC whloh was not hltlalfzed wlth OUTPUT, INTERN found a member of the OBLIST which has no prjnt You are In trouble, Data was lmproprrl~ wrlttrn on the selected output dsvloe, Posslbl~ a wr~ts-locked DECTAPE, Soma arlthrnstic functlon caused overflow - elthrr ))xed or floating, name. PDL OVERFLOW FROM GC - CAN'T CONTINUE There 1s not enough regular ~~9hdown llst to ftnlrh garbage ooll~ctlon, YOU lose. Try to REALLOC as descrlbsd in APPENDIX C, READ UNHAPPY - MAKNAM MAKNAM and READLIST objeet to a llst whlah Is not an entire S-axpresston, REG PUSHDOWN CAPACITY EXCEEDED SPEC PUSHDOUN CAPACITY EXCEEDED A pushdown 1 i8t has overflowed, This 1s usual ly oaused by non-termlnat Ion of recurs Ian, Somet im~s YOU need to ALLOCATE or REALLOC more pushdown llst. TOO FEW ARGUMENTS SUPPLIED - APPLY TO0 MANY ARGUMENTS SUPPLIED - APPLY

SAILON 28.6 APPENDIX B 8-4 X X APPLY ohaoka all trl la on lnter~rrted tunotlbna tot the Proper numbr bf argum@nts. MADE ILLEGAL MEMORY REFERENCE The funetlon X referred to an Illegal address, Ueually orused by taklng the CAR or CDR of an atom or number, NON-NUMERIC ARGUMENT Arlthmrtlo funotlonr requlre that thrlt argument8 be numbais. X PROGRAM TRAPPED FROM An lllrgal ingtructlon was rxetuted In funetlon X, X X UNBOUND VARIABLf - EVAL EVIL trlrd to evaluate an ldenllfler and found that it had no vrlur, You ~ r o b a b forgot l ~ to QUOTE some.tom to jnitlrllze It, UNDEFINED COMPUTED GO TAG IN A GO in some oorn~tlrd funotlon had an undefined label. 1 X UNDEFINED FUNCTION X UNDEFINED FUNCTION a APPLY The tunatfon X fa not defined, X UNDEFINED PROG TAG a GO A GO in some Intarprrtrd Cunetlon had an undrflnrd lrbel,

APPENDIX C MEMORY ALLOCATION The LISP 1,6 system has many different areas at memory for storing data which can independently vary in size, Some LISP applicatlona demand larger allooatlons for these areas than others. To allow users to adjust the S ~ Z of ~ S these areas to thrlr own needs, a merory allocatfon orocedur~ exlsts, C,1 Suvmary of Storage Allooatfon Areas BINARY PROGRAM SPACE FREE STORAGE FULL WORD SPACE BIT TABLES REGULAR PUSHDOWN LIST SPECIAL PUSHDOWN LIST EXPANDED CORE T""' TOP OF CORE Area for oorn~ilrd functlonr and arrays. Area for LISP nodes, Area for prlnt names and numbers, Area for the garbage collector, Area for all funotlon calls and non- s~rolal varlablrs In oomoiled funattons, varlablrr and s~eclal Area for lnter~rrted vatfables, Area for I/O bufferg, ALVINE, LOADER, and any loaded proorama, ----"""-~-w.lw~o--~.l~~.li.ro-~ii)* I I EXPANDED CORE I I,,,,,,,- i.-,,- -,---w.l---------------- I I I I SPECIAL PUSHDOWN LIST I I i - ~ - r - r - - m - r r r r w - r - r. ~ ~ - o ~ m ~ - -. c. ~ ~. ~ w - - ~ ~ ~ Memory map for the LISP 1,6 system REGULAR PUSHDOWN LIST -I)~------~Io"I--~----~I)-..--~-~C0-1.)-0 BIT TABLES I FULL WORD SPACE I I I -------------------ow-e--o-.c-------s I I I FREE STORAGE I I BINARY PROGRAM SPACE I I-'C----,-~~,o-o,,--L.L--" o--- I---- -".L I I I LISP INTERPRETER 1 I ---,a-"--,,-,,,---l.c-.l--..,--.l-~*o-~.il- I BOTTOM OF CORE

APPENDIX C When the LISP system ir lnltlallv started, it asks thr usor vo speelty the rlxe of eaoh of Its various a~aue~ as fol lows, FREE STORAGE = 10000 o FULL WORDS a one fourth of free storag~ 8 BIN, PROG, SP, o 2000 g REG, PDL ifla0 + one slxtrenth of trrr storage = SPEC, POL 1000 + one sl%ternth of free storapr a OBLIST SIZE 177 o the number glvrn in betwren the ooual signs is the default size whloh LISP wlll uee It no number 1s suopl!rd, A8 shown above, for romr spaoea it w l l l vary wlth the rlzes of otherr, There are three baalo rrs~on8aa to any of the180 auestlonsr 1) A oarrfags return wlll causr the default vrlua to b@ used, 2) A number followed by a carrfa~e return w t l l pr~d~ee a ~pao@ 01 that S~ZQ, $) An altmode In Plaoe of a oarrtaee return w l l l result in the rrmalndar of thr questtons baing aklpped and the alloortton ~rooadurr bslng ended, If you have an rxlrtlng LISP core image but have rxhaurted one of tho sforage areas, it I8 ~os3lble to inorease the slza of that area urlng the real locatlon ~rocqdurr, Flrrt, expand oorc wlth the vlme sharlng r~stam command CORE and than rr-enter thr LISP core Image wlth the START command, For examole, I f the orlglnal eorr dzr was 20K, you could lnorarse It by 4K as followrt When you re~llotatr r aore Image, all addltlonal aorr 1s alloaatrd l/4 for full word space 1/64 for each pushdown Ilst, the remelnder to free storage and bit tables,

SAILON 28,6 APPENDIX C Cm3 C84 Blnnry Program Space The reallocation procedure does not Increase tha aize of binary program space, However, It fs possible to Inorease blnary program space by rxpandfng Gore wlth the CORE (C) command and setting BPORG and BPEND to the beglnntng and end of the expanded area of core, For exam~ls, if you now have 32K of core and want 4K more BPS, to the tollowfngt (EXCISE) to ellmfqate I0 buffers +c,core 36,ST ART *(SEW BPoRG (TIMES 32, 1024,)) *(SETQ BPEND (PLUS BPORG 4095,)) Note! If you u34 the reallocation ~rooedure rftrr having rrpanded core for any ourpose, it w l l l reallooate this nddltlonal core for Its own ourposes, thus destroying the contents of the expa~ded oar@, The fol lowtng are the standard aau3es for ex~anslon of 00re: 1) uslng 110 channels, 2) uslns the LOADER -(LOAD), 3) ~ x ~ a n d l ncore g for more binary program sdao@, 4 using (ED),

APPENDIX Ll GARBAGE COLLECTION 41 I LISP systems have a function known as the garbage collector, This funotl0n analyzss the entire state l18t structure which is polnted to by either the OBLIST, the regular Pushdown list, the spralrl ~Ushdown Ilst, list arrays, and a few other s~eolal cells, BY reeurslvel~ marklng all words on free and full word spaces which are potntrd to in this manner, it is ~ o s s l b ~ e t o determlne which Words are not ~olnted to and are therefore garbage. Such words are collected together on their respective free storage nlsts, CC causes a garbage collectlon to occur and returns NIL. Normally, a garbage colleotlon ocour3 only when elther free or full word spaoe has been exhausted,. (GCGAG X I flag NIL lnittall~. GCGAG sets a speolal flag In the lnter~retsr to the value of X, and returns the orevlous setting of the flag, When any garbage collectlon occurs, if the flag # NIL, then the following 1s printed! FREE STORAGE EXHAUSTED FULL WORD SPACE EXHAUSTED nothing followcsd by x FREE STORAGE, y FULL WORDS AVAILABLE where x end y are numbers In' o ctal, (SPEAK) SPEAK returns the total number of CONSes which have barn executed In thls LISP core Image, GCTIME returns the number of mlllfseconds LISP baa spent garbage oollectlng fn th1$ core Image, It Is poss]ble to determlne the lengths of the free and full word free storage lists by: (LENGTH (NUMVAL 1 5 b 8 ) ) 8 length of free storage ljst (LENGTH (NUMVAL 16&8)1 length of ful I word Ifat

APPENDIX E CQMPILED FUNCTION LINKAGE AND ACCUMULATOR USAGE Thls appendlx Is intended to explain the structure of aomplled functlons, functlon calls, and accumulator usage, This discussion Is relevant only if one intends to fntorfaoe hand eoded tunctlons or ~ossfbly functions generated by another system (such as FORTRAN) wlth the LISP system, In such a case, it 1s hlghly recormended that one examine the LAP code generated by thr LISP aompller for some famtliar functlons, ACCUMULATOR USAGE TABLE s weans "sacredu to the Interpreter P peans "protectedw during garbage collection NIL = 0 A = 1 Header for the atom NIL, Results from tunotlona, 1st arg to funct Ions 2nd are 3rd arq 4th aru 5th arg used for LSUBR ltnkage rarely used in the Interpreter rarely used In the Interdreter TEMPORARY STQRAGE regular pushdown llst ~olnter tree storage fat polntsr full word llst polntar specla1 D U S ~ ~ Olist W ~ pointer, Whenever a LISP functlon is called from a com~llsd functlan, It is assumed that all accumulators from 2 through 13 are de8tro~ed by the tunotlon unless it Is otherwise known, Therefore, local varlable~ and ~ararnrtrrs In a ~0m~Iled functl~n should be saved in some protected cells such as the regular pushdown Ilet, The PUSH and POP Instructlons are canvenlent for this pur~ose, SPECIAL VARIABLE BINDINGS Speclal var lablee In corn01 led functlons rrr bound to eel Is by; spaolal

APPENDIX E PUSHJ P, 0 ndi, varsi 0 nb2, vard2 SPECBIND SPECBIND saves the revf four valurs of varrl on the speolal pushdown nlst and blnds the eontents of ~toumulator ndl to eaoh vardt. the vatdl murt be ~ofnters to S P I O ~ 08118 ~ ~ of Id@ntlfl~rs, Any n41.0 aau3as the vat41 to be bound to NIL, S~eclal varlablrs are restored to their prrv~our vrlurr by1 PUSHJ P,SPECSTR which stores the values ~rrvlougl~ saved on the rpeclal dushdown llst In the a~~roorlate ~ ~ e c f cellsi a l NUMBERS To convert the number in A from its LISP rrprrrentrtlon to machlne re~resentatfon use: PUSHJ PbNUMVAL which returns the value of the number in A, and its tyde (elthrr FIXNUM or FLONUH) In 0, To oonvert the number In A LISP rrpresrntatlon use rltherl from its machlnr rr~rraantatlon to PWSHJ P,FIXlA tor FIXNUMS o r PUSHJ P, MAKNUM wlth t v ~ e in B, Both of the above functjons return the LISP nurnbrr In A, FUNCTSON CALLING To allor ease in llnklng, d@bugglng, and modify\no of eomplled funetlons, all complied functions call other functions wlth apeclal o~codrs called UUOs, Sev@ral ~ateg0rie8 of funetlon oalls are dlstlngulshed: 1) Calls of the form (RETURN (FOO X)) are orllbd tetmlnrl oallr and ~ssentfall~ "Jumpw to FOQ, 2) Calls of the form (F X I where F Is 8 computed (unction namr or funot l onp I argument Is oa l led o funet 1 onr l oa l I, The functlon calling IJUOS are!

non-functional functlonal CALL n,t CALLF ntf JCALL nrf JCALLF nmt where f is elther the address of a tomplled functlon or a ~ointer to vhe idsntlfler for the fun~tlon, and n s~eoif les the ~YDI of funation being called as followsl speolffes a SUBR call with n arguments speclfies a LSUBR oall speolfles a FSUBR oallr The function calllng UUOs are detfned fn MACRO by1 OPDEF CALL ~34B81 OpOEF JCALL C35083 OPDEF CALLF ~36881 QPDEF JCALLF ~37881 (NOUWO X) flag a T l n f t l a l l ~ NOUUO sets a s~eclal flag In the compllrd function calling mechanism to the value of X and returns the previous setting of the flag, Cornpllrd funotlons i n l t i a l l ~ call other funotlona with function Gal llne UUOs whlch "trap" Into the UUO meahanlsm of the interprater. Ordlnar l ly, such functlon cal Is Involve searchlns the prodert~ llst of the functlon betng called for the functlonal ~ropetty, and than (depending on whether the functlan 1s complied or an $-axeresalon) the function Is called, If the NOUUO flag Is set to NIL, then the overhead in calling a C O ~ led P ~ function from a com~\led function can be eliminated by reolaclng the CALL by PUSHJ and JCALL by JRST, CALLF and JCALLF are never changed, However, there are several dangers and restrtction$ when using (NOUUO NIL), Once the UUO's have been replaced by PUSHJ'S then It Is not possible to redeflne or TRACE the functlon befng @allad, 1t is therefore recommended that aompl led functions be debugged wjth (NOUUO TI* SUBR LINKAGE SUBRs are comptled EXPRs which are the most common type of functiov, Cansesuently, considerable effort has been made to make nlnkage to SUBRs efficient, Arguments to SUBRs are sup~lfed in accumulators i through n, the flrst argument fn 1, There Is a maxlmurn of 5 arouments to SUBRs, To call a SUBR from C O ~ Pled I code, use oall n,func, where n 1s the number of arguments, and call Is the ap~roprlate UUO,

SAILON 28.6 APPENDIX E The result from a SUBR la returned In A(a 11, FSUBRs recefvr one argument in A and rrturn their result in A, FSUBRs whleh use the A-LIST Coaturr colll PUSHJ PI *AMAKC which generates in B a number encodlno the state of the rpeolal mushdown polntar, To oall a FSUBR, urr oall 178 FUNC, here ool l is the r~~roorlrte UUO, LSUBR LINKAGE LSUBRs are s!ml lar to SUBR8 exerpt that thay al low an rrbltrar~ number of arguments to be ~asaed, To oall a LSUBRI the followlno srauente fa used! teti PUSH P, Cretl lreturn address PUSH P1 a w l 11st argument PUSH';: rrsn nth and last argument MOVNI T,n ;minu8 number of arguments oall 16,func jthe r ~ ~ r o ~ r i UUO a t r Ithe LSWBR returns here When a LSUBR la entered1 It executrsl I whleh lnltlallzrs the LSUBR, A will tontaln n, The lth aigumrnt oan be rqferenced by! MOVE A, ~ x t from t an LSWBR with al-i(p) which returns to *LCALL to restore the staok,

APPENDIX F APPENDIX F THE LISP COMPILER by Whltfleld DiffTe The LISP compiler is a LISP program whlch transforms LISP functions drflned by S-expressions lnto LAP assembly code, Thla can be loaded lnto blnary program s~ace by LAP (LISP Assembly Program), a oombined assembler and loader, which produces absolute machina code In core, Com~lled functton~ are a~proxlmately twenty times as fast as interpreted functions, Complled funot!ons also take up lees memory space and relleve the garbage ~ollector from marklng function deflnltiona, In a very large system of functtons, t h ~ s last point ts partloularly slanlflcant, The LISP c0m~ller exlsts as the system program COMPLR, r ~ 1s d called by the Incsntatlon 'R COMPLR,' Once started, It lr ipbken to in the same dlalect as any other LISPl USE OF THE COMPILER (COMPL, "FILENAME - LIST") The funotlon COMPL takes as arguments an assortment of fllr names and devlce names In preoisel~ the same way as the tunotion DSKIN, The default devfce to be used for input In the event that none is su~plled in the argument sequence is given by the value of vhe variable INDEv, There 1s no ~rovlslon for sprclflcat)on of an output device In the argument sequence, If the output 18 wanted on some drvlce other than the user's dlsk area, the variable OuTDEV must be set to lndleate thts deslre, All error rnessaqes and gommrnts are normal ly dlreoted to the teletype, They can be sent to some other devtce by tsettlne the variable LISTING, F\ 18s ~roducrd by the oompller have the ff lename extension LAP, (COMPL FOO sys: TRACE) wiii camptle the flle FOO from the users dlsk area and the file TRACE from the system area to produee the files FO0,LAP and TRACE,LAP on the users dlsk area, (SETQ INOEV (QUOTE DTA2l)) (SETQ QUTDEV (QUOTE (2,DAV))) (SETQ LISTING (QUOTE (USKI CMPMSG))) (COMPL HAT SYSt SMILE)

w l l l compile the fllr HAT fram DTA21 and the tilr SMILE from SYSI to ~ r o d u ~ the e f! les HAT,LAP and SMILE,LAP on tho dlsk area C2,0AVa, A l l oorn~l,l@r messages wf II appear as the file CMPMSC on the US@P'S d1sk area, PREPARING FILES TOP COMPILATION In prrparlno a fllr for eom~llrtlon thrrr 4rr several that the uarr is we1 l advised to bear In mlnd, thlngs 1) A l l normal functlon drtlnlno tunctlons are aceeptrble to thr complier, Functions detlnrd by DE, DF, and DEFPROP, and mretos drflned by DEFPROP or DM, w i l l be corrrctly understood, 2) Any funetton whlch Is unknown to the oompller when it ir first obl lged to Qenerate a oal l thereto, w l l l be ~ssum@d to br an EXPR or SUBR, If o tllr contafnsatunetlonof any other ~YDI whloh called by a fun~tbn deflned earlier fn the file, it murt be drolatrd vo the oom~llrr with one of the atatrmrntsr (DEFPROP tun T @FSUBR) or (DEFPROP fun T *LSUBR) ro that the compl lor will know how to rot UP Its argumentn, 3) Any varlable which occurs free in any funetlon murt be drolaird SPECIAL ~ r l o r to the def lnltlon of any function whloh blnd8 it, lhis may hr done wlth a atatemant of the form '(DEFPR0Pv.r T SPECIAL),' 4) AS maorag are functions which are roturlly executed at aorn~lle tlmr, thelp drtb/t?onr must oecur sarllrr in the?11e than rnv functlon whleh PDD~PIS to them, If this 1s not done, thr maor0 will be mlstaken tor an undetlnsd EXPR, COMPILER MESSAGES CI the com~/ler goes about its busln@ss, It wt ll make various aommrnts and eomplalnts about Your code, 1) As the aom~flatlon of each function Is oom~leted, its name wlll be vyped on the teletype without oarciago return, Any Other m @ 8 ~ a ~ ~ wlll be rtood off by carrla~r returns above and below, 3 2) Whenever the oomptler discovers a tree variable whloh has not been deolwed s~selal, it declares it, A t the end of any functfon In which It found such variables It will ~ r h out t thr rnrssrgat (SPECIAL war1 var2 etc,), 3 3) If a prog variable Is unused in a funotlon the com~llrr w i l l ~rlnt Che message (UNUSEDPROCVAR varname), It w l ll also declare the variable s~eclal on the theory that if it was not used there, it nuat have been uwd sornqwhere else, 3

4) Many minor errors In user code wlll unfortunately go undeteotsd. Any serlqu8 error will the *USER ERROR* follow8d by a description of what Was wrong. Thls wlll halt the compllrr, 5) The error message *COMPILER ERROR* indicates a b u ~ in the com~iler. Please report this to Whftfleld glffte, 6) khen the 00m~ller has tlnlshed, It ~f 1 1 type out the name of the flle, the number of words of code produced and tha time taken, Followln~ these will be lists of any functtons called but not defined in the fl lr and any auxi l iary funottons the tomd let generpted, USING COMPILED CODE As LAP is self loading, the loadlno of com~lled files 1s the same as for Interpreted functions, The allocattons must be ohangad, however, to reflect the passaga of the code from free storage to bfnar~, program space, The correct size of the latter 1s tha size ot the program as stated at the end of compllatlon, plus the length of lap khlch Is about 500(8) words, The folnowing example I I Iu~trates var(ous BBPIC~S of the complier's behavior, We shew a collrctlon of functions, the LAP code generated from it, and the comments made by the complier In the P ~ O C ~ S S, THE FUNCTIONS (DM FIRST (L) (CONS @ CAR (CDR L))) ;macro defined at beglnnlng (DEFPROP I T T SPECIAL) ;specla( declatatlon (DEFPROP MAPCONS ;the Internal lambda (LAMBDA (IT LIST) Ibecarnrs a separate function (MAPCAP (FUNCTION ;thus the varlable IT must (LAMBDA ( X I I be made ~ ~ e ~ i ~ l (CONS I T X I ) ) LIST) EXFR (DEFPROP COUNTM (LAMBDA (SEXPR) (PROG (COUNT) ;the variable COUNT has not beon (SETQ COUNT 0) ;declared special and will be treated (COUNTI SEXPR) ;as local (RETURN COUNT))) EXPR 1 (DE COUfuTl (SS) (COND ((ATOM SS) NIL) (1 (INCR COUNT) ihere It 1s dlaoovered to be s ~ e c i ~ l (COUNT1 (FIRST SS))!but too late

tde SCALE (NO) ithls vorlable la found to (TINES NO SCALEF)) ;be s~rolrl, in good t I m ~ (OF SETQQ (I.) (SETQ SCALEF 3) THE RESULTING LAP (SET (CAR L? (CADR L))) rthlr wlll b* output unchanwd lnotr that the macro drflnltton and the s~eclal drclrratlon have ;been gobbled UP by the compl let. (LAP MAPCONSG0220 SUBR) ithb Is thr functlon (MOVE 2 (SPECIAL IT)) ;generated by the (JCALL 2 (E XCONS)) i Internal lambda NIL ~ l MAPCONS n (LAP MAPCONS SUBR) (JSP 6 SPECBIND) (0 2 (SPECIAL IT)) (MOVE1 1 (QUOTE M A P c O N S C ~ ~ ~ ~ ) ) (CALL 2 (E MAPCAR)) (JRST 0 SPECSIR) NIL (LAP COUNTM SUBR) (PUSH P 1) lthls code Is In error (PUSH P (c 0 0 (QUOTE 0) 0)) ;due to the fallur~ (CALL I ( E COUNT^)) r to mrkr COUNT ap~eir I (MOVE 1 0 p) (SUB P tc 0 0 2 2)) (POPJ P) NIL (LAP COUNTI SUBR) (PUSH p 1) (CALL 1 (E ATOM)) (JUMPE 1 G0229) (MOVE1 1 (QUOTE NIL)) (JRST 0 G0228) C0229 [MOVE 1 (SPECIAL COUNT)) Ireferrnce to the r~rcl~l (CALL 1 (E INCR)) lvarlablr COUNT, whjoh hrs (HLRt) 1 0 P) rnot been bound ~t008rly (CALL 1 (E COUNT%)) (HRRLe 1 0 P) (CALL 1 (E COWNTI)) C0228 (SUB P (C 0 0 11)) (POPJ PI NIL

ii (LAP SCALE SUBR) (MOVE 2 (SPECIAL SCALW)) (JCACL 2 (E +TIMES)) NIL (LAP SETQQ FSUBR) (HRRZe 2 1) (HLRtQ 2 2) (HLRZ@ i 1) (JCALL 2 (E SET)) NIL JSCALEF 1s a tree variable ioorrectly datected c THE COMPILER'S OPINION MAPCQNSG0220 MAPCONS COUNTM (SPECIAL COUNT? COUhT1 (SPECIAL SCALEF) l~~ectal found too late lsoeclal found In time I, SCALE SETQQ (CMP, CMP) COMPILED 41 WORDS 3 CONSTANTS 1 SECONDS L UNDEFINED FUNCTIONS I NCR GENERATED FUNCTIONS MAPCQNSG8220

APPENDIX C LAP Is a ptimttlve assembler deslgned to load the output of the ~ompller, Norrnall~, It Is not necessary to use LAP tor any other aur~ose, LAP Is self loading, The format of a ~ornplled funatton In LAP Is: (aeauence of LAP Instructions> NIL where name Is the name of the funotion, and type fs either subr, or FSUBR, LSUBR, A LAP Instruction Is elthert 1, A label w h l ~ h Is a non-nil Identifier, 2, A (1st of tha form (OPCQDE AC ADDR INDEX) a, The Index field is optional, b, The opcode is rlther 8 PDP-6/10 (natructlon which 1s defined to LAP and optionally suff\xed by p which designates lndlrect oddresslnp, or a number whlch s~eclfles a numerloal opoods. c, The AC and INDEX flelds should contaln a number from 0 to 17, or P whleh designates re~lstor 14, d, The ADDR fleld may be a number, a label, or a Ilst of one of the tollowlng formst (SPECIAL x) (QUOTE ~aexpresslon) For rxardie, the lunctlon ABS could be deflnedr to reference list structure. to reference the value of identlfler x, (E f) to referrnoe the function f. (C OPC(1OE AC AODR INDEX) to referenca a I l teral cons

APPENDIX C (LAP ABS SUBR) (CALL 1 (E NUMVAL)) (MOVMS 0 1) (JCALL 2fE MAKNUM)) NIL

APPEND1 X H APPENDIX ).I THE LOADER A modlf fed vergion of the standard POP-6/10 MACRO-FAIL-FORTRAN loader Is available for use in LISP, the noader Into a LISP core Image at any time by exeoutlng; (LOAD X I One can call When a Is typed, you are In the (LOAD X I loader, and the loader cornrand strlngs are expected, AS soon as an altmode 18 tyded, the noaaer flnlshes and exlts back to LISP, The loader is~laced inexoanded core. If X s NIL then noaded programs are placed in expanded core, otherwise (ji X $ NIL) vhe9 are plaoed In BINARY PROGRAM SPACE, The loader removes Itself and contracts oore when It f a finished, In the following dlscusslon a "RELOCW program w'ill refer to any Drogram whlch 1s guftablr for loadhg with the lordrr, The output of FORTRAN, MACRO or FAIL Is a RELOC Program, (EXCISE) EXCISE contracts oore to its IrnfJth after ALLOCATION or the last START, Thls removes I/O buffers, and all RELOC programs, *GETSYM searches the DDT symbol table for the symbol S and if found returns Its value, othsrwlse it returns NIL, (GETSYM "P" and~laces Exarpler ''SslW "~42",,, WSdn") GETSYM searches the OD7 symbol table for each of the symbols Ssl the value on the ~roperty list of Shl under prooerty P, (GETSYM SuBR DDT) Thls Gauges DDT to be deflned as a SUBR looated at the value of the symbol DDT, Note: In order to load the symbol table, either /S or /D must be typed to the loader, ~Ymbola which are declared INTERNAL are always In the symbol table without the /S or /D, In the case of m u l t l ~ dsflned l ~ s~mbolst 1,em# a ~YmbOl used In more than one RELOC program, a symbol declared INTERNAL takes preoedancer the last symbol otherwise,

SAILON 28,6 APPEND1 X H Hm2 value V, *PUTSYM enters the rymbol S 1nt0 the DDT rvmbol tablo wlth PUTSYM Is used to place eumbols In the DOT symbol trbl'r. It Xh is an atom then the symbol XI I Is laced In the 8vmbo 1 table wlth its value ~olntlng to the atom Xb1, If Xcl 18 a Ilst, fhr 3urnbol in (CAR X4I) Is placed in the symbol table wlth its value (EVAL (CIDR ~ l t ) ), PUTSYM 19 UIIIUI for making LISP atom#, lunctlons, and varlablrr avrlloblr to RELOC programs, Symbols nuat br drfjnrd with 3 PUTSYM brforr the LOADER fa used, Examp lea t (PUtSYM BPORC (VRPORG (GET (QUOTE BPORGl(QU0TE VALUE)))) drffnrs the Identtfbr BPORG and Its value orll VBPORG, A RELOC program oan referenoe the valua of BPORG ~YI 3 MOVE X, VBPORG (PUTSYM (MAPLST (QUOTE MAPLST)) (NUMBERP (QUOTE NUNBERP))) (PUTSYM (MEMO (GET(QU0TE MEMQ) (QUOTE SUBR)))) A RELOC program would cal l there funations a8 Col low81 CALL 2,MAPLST CALL 1, NVMBRP PUSHJ P,MEMQ Or CALL 2,MEMQ An rxample of 8 slm~lr LISP oom~rtlblr MACRO program to oompute square roots urfng the FORTRAN I lbrrry, TITLE TEST Pri4 A = l 8102 LSORTI CALL 1, NUMVAL MOVEM A,AR1 MOVE AICXWD O,BLT13; SAVE THE AC'S BLT A,BLTl+l7 JSA 16,SQRT JUMP 2,ARl ;SOP TO FORTRAN MOVE 0,ARl MOVE A,EXWD BLT1 103 BLT A117 MOVE A,AR1 MOVE1 B,FLONUM JCALL 2tMAKNUM ARi 0

SAILON 28,6 BLTlr RLOCK 20 END

SAILON 28,6 APPENDIX I APPENDIX I BIGNUMS - ASBITRAHY PRECISION INTEGERS i ; i' LISP numbers have always been second class otti~ens, i n the sense that unlike 9trlngs tprint names) numbers have had r maximum nencth, I n the PDP-6/10 LISP system there 13 an optional arbitrary preclslov Integer package which extends the length of LISP inteorrs fror 36-blts to any length, To load the BIGNUM system, execute the fo(lowing at the top nevel of LISP{ *(INC(INPUT SYSI (BIGNUM,LSP))) <SEQUENCE OF OUTPUT> *(LOAD T)*SYStBIGNUM$ (LOADER TYPES BACK> *(APNfNtT) and then your eore image will perform arbltrsry precialon!nteger operations using the standard LISP arlthmetlc functlons whieh were tedeffned by APNINIT, It Is possible to load th@ BIGNUM package at any tlmr unless you have already executed oom~iled functlons with (NOUUO NIL), In which oase You must reconstruct Your core Image,

A USER MODIFIABLE LISP SCANNER by Lynn Quam LISP uses a table drlven scanner, whose tabla may be modlffrd by the user for the purdose of Omalementlng soannars for other nsnguages, For ~ l m ~ ( l c t t y the, tunctlons tor construattng the aernner table inltlally give an ALGOL type scanner, that la ths ALGOL deflnltions for identifiers, strtnes and numbers ( ~ x Q W tor ~ powers of ten), The ALGOL table may be modlfled by using addttional functions to include addltlonal eharaoters in identlflsrs, and to specify dellmfters tor strlngs, 1 FORMAL DEFINITIONS Syntax! : t = (a comment-gtart followed by any sequence of characters endlns In a oamment-and) digit ::re ttgtt I f y t 1,,, I "9VQ netter ::z *)A'! I IIBI~ I,,, 1 ~ t ~ t1 t 1 tfbtt 1,,, 1 ~ ~ 1 ~ l t extra-letter character r..=: (any ASCII oharacter other than null, rubout, and comment-start) del lrrlter g..= (any character not a letter and not a dlglt) t := letter ::= tdentlfter dlglt ::a rt o r y identlfler letter slashlfled oharacter ::= /dsntlfler slashlfled character In the above syntax, underlined symbols can be rprclf?ed by the user, For instance, comment-start and comment-end could both be speclfled to be double quote ('I), If it 1s desirable to Include follar and percent signs In ldsntlflers, then both of these characters should be extra-letters, Slashlfiers make it ~oss)ble to include any delimiter in an Identifier, For example, 11 qurrtlon mark Is the slashlfier (3) and It Is deslrabla to Include the character (+I In the identlffer V as V*, then anm should slashlf~ the plus: v3+, str Ins *. * = (a strlngwstart f o l l o ~ d by any sequence of characters endlns In a strlno-end)

SAILON 28,6 APPENDIX J, Ssmantlcrrr Str Inowstart and strlno-end rrr s~relfiable, J,1,3 Numbers or -1 Same ar speoltlrd In Chapter 4, except that lerdfng shnr (+ In numbers are treated as drlfmlterr, J,2 DESCRIPTIONS OF THE SCANNER MODIFYING FUNCTIONS In the followfn~ daecrl~tlonr, all oharrotaru rrr ro~chled by thdr num@rloal ASCII value, For exam~lr, in ootrl, blank it 40 end A Is 101, 3 (SCANINIT oonment-start eornmant-@nd rtrlngastart rtrtng-and ilrahl?lar) SCANINIT modltlrs the LISP scanner to br an 4 ~ ~ ~ ~ ~ m t scanner with r~rcial drllmlterr tor oommrnts and rtrlnga, SCANINIT must be oallrd before any of the other scanner funotion8, (IGNORE x) LETTER epeclfles to the seanner that x 1s not to be returned as a dellmltrr from rcan, but Inatead will be lgnorrd, Howrvrrr~ x will stlll functlon as a separator between idrntlfier and numberr. For example, oarrlrgr-return, llne-trod, tab and blank are urr~ul oharrctrrr to ignore as drllmltrrs, (LETTER X I Letter rpetttles to thr #tanner that X and thus a(lowa X to be In an Identlflrr, I8 an rxtra~lrttrr, ( SCAN 1 SCAN reads an atom or dr l lml tar and.8rhs tha va l ue bf thr global varlable SCANVAL to the value read, and rrturns a numbrr eorras~ondlng to the s~ntrctlo type read a8 followel (SCANSET) ~yntrctlo type Value of SCAN valuie of SCNVAL IdentIfler stplntl numbr r del lmlter 0 the unlntrrnrd identltlrr I the strfn~ 2 the value 3 the A S C I ~ value ot the dellmfter, SCANSET mod l f les the LISP roanner In READ record i no to the user ~~eclfloatlons, Evaluate (SCANSET) before o a l l h ~ SCAN,

L (SCANRESET) SCANRESET unmadffl8s the LISP scanner to Its normal staw, and wust be called before READ w l J I work properly again onoe SCANSET Is used, Use INITFN t o call SCANSET after errors, J,3 USING THE MODIFIABLE SCANNER The scanner modffytng functfona are not a normal part of the LISP system and must be ex~llcltl~ loaded into a LISP Gore image. The following steps Indicate how to ~rovlde the DrODIr interface L betrren LISP amd the wanner, load the scanner, and lnttiallzr the scanner tables, (SETQ SCNVAL NIL) (PUTSYM (SCNVAL (GET (QUOTE SCNVAL)(QUOTE VALUE)))) (LOAD) SYS:SCAN$ (GETSYM SUBR SCANINIT LETTER IGNORE SCAN SCANSET SCANRESET) (SCANINIT 21 73 42 42 45) <this makes comments start wtth strings start and end wtth double quotes percent ( X ) Is the slashlfler) and with semicolon, and To use the scanner, one mu%t first oall the SCANSET, Once SCA~SET has been called, the normal LISP funotlon READ no longer \ L behaves In a normal fa~hion, slnoe READ will now use the modlfied scanner tables, Care must be taken to call SCANRESET before oalllng READ,

APPENDIX K APPENDIX SOS-L INK K The SOSLINK program is an aid to debugging Interpreted LISP functlona, whlch allows rapid turnaround In the vtsst-odlt-tsstt lood of debugging, It 1s famous for the two functlona FILEIN and EDFUN whlch behave as toll~ws, The way In which this functlon takes Its rr$uments differs only from DSKIN in that all files must come from the user's own dlgk area, When a flle 1s loaded with FILEIN, InformatIan is srvrd for each funotlon deflned fn the file trlllng what flle It came from and on hhat page and l Ins It was detlnsd, Inltlall~, thlr information w \ ll only be saved for atoms whlch are deflned to be EXPRS, FEXPRS, or MACROS, If the user wlthss to have it saved for rome other property, tar axamole VALUES, he orn athleve thls rffrot by puttlng the property SWAPIT en the pro~erty l!?t of the lndlo~tor he wl~hed vo have 30 honored, in thls orse by putting the property SWAPIT on the ~ r o p ~ r t(1st y ot the Indlcator VALUE, i (EDFUN "FUN" "PROP") Thl8 functlon Is used In the envfronment created by FILEIN, I t wi 1 1 oal l in the system editor, SOS, with it$ attention focusrd on the funotlon FUN, ~t the same tlme, it wl ll save a oopy of the user's LISP and orepare for a aulck return to thls CODY, Once the edjtor has bran started the funotlon dettnltion may be edited in the usual way, it should be noted, however, that although edjts may be made to other parts of the flle, only the deflnltlon of FUN will be noaded or return to LISP, If FUN has more that one property for which flla lnformrtion 1s belna saved, It may be neaessary to use the second argument PROP of EDFUN In order to s ~ e c l f whtoh ~ one Is deglred, When edltlng has been finished, and a return to LISP t s wanted, It is only necessary to type the command G to SO$, A saved copy of tha userts LISP wlll be started and the sfngle funetlon deflnitlon whlch Is modtfled wlll be teloaded, As lone as no global modlfl~atlons are mrde to the fl la, t h l ~ process may be repeated Indrflnttely, Such actions as ienumberjng the ti 16 are d!saouraged, however,

L SAILON 28,6 APPENDIX L APPENDIX L SOME DIFFERENCES BETNEEN THIS AND OTHER LISPS 1) The tap level of thls system doe8 not use EVALQUOTE ar do many systems, However, EVALQUOTE may be deflned as tollowsl (RE EVALQUOTE NIL (PROG NIL L (TERPRI) (PRINT (EVAL (CONS (READ) (MAPCAR (f'unction (LAMBDA (X? (LIST (QUOTE QUOTE) %)I) (READ))))) (GO L))) the top level of LISP 1,6 Is equfvalent tat (PROG NIL i. (TERPR 1 ) (PRINT (VAL (READ))) (GO L)) L 2) The order of the arguments In the varlous functions MAP, MAPCAR etc, 1s functlon flrst, list second, rather that the revera6 as In many systems, 3) There are certain dffferencea even between Stanford LISP and other DEC system Lls~s, a) the comment charaoter 1s ~ s c f32 f b) project programmer numbers are ~alrwords In whtch each half holds up to three rlght adjustrd slxblt oharooters, a) The new dabugglng package de~ends on system features only available in the Stanford system, Thls debugging ~aokage is drscrlbed in nppendlw K,

APPENDIX M APPEND! X M LISP D ~ s D ~ Prlm!tlves ~ Y by Lynn Quam A set of display ~rimittves are now avsllablr for LISP users. These ~rlmltlves use the features In the 0, pool. dlt?pi~y servlce subsystern, Ueors should be trmll tar with srctlon II,D,8 o f sailon 55, and SAILON 29, The lollowlno display ~rtmltlves allow the usor to enter display oomnands jnto "then current d t s ~ l a buffer, ~ Thr eontents of th/r buffer arb not seen untll the user exreutrs the ttshowtv arlrr.ltiv~, (AIVECT X Y) draws an absolut. Invlslble vector to (X,Y), (AVECT X Y) draws an absolute vlslble v6ctot to (XnY), (APT X Y) draws an end~olnt veotor to (X8Y), (RIVECT X y) draws a relrtlve lnvfslble vector to (%8Y), (RVECT X Y) draws a relatlve vlslble veotor to (X,Y), (RPT X Y) draws a relative endpoint vector to (XtY), (GVECT X Y OP SIZE BRT) assembles display procssaor ODOO~O COP> wlth X, Y, SIZE, BRT fields sproitlrd, ( E,g,, (GVECT 0 0 46 1 0) draws a zero length Invlstblr veotor and sets the character rlze to 1, (LOCATE 1 returns the posltlon of th@ last word put tn the ~ I s D b ~ ~ ~ f f Y ~ r c (DJUMP N) stores a dlsplay processor jump to locrtlbn n, (DJSR N) stores a dlsplay prooersor subtoutlnr orll to nocatbn n, ~ l of l the above commands return the referred to dlrplay buffer &ddr@g% (SHOtr N) the current dlspla~ buffer is dl#~layrd bn "piece of glasgtf (N), (KILL N> (CLEAR) (OTY OS) erases @,pleoe of glass" (N), erases the current dlaolay buffer, selects the dlsploy buffer tor ohara~ter output from LISP, (TYb PRINT, ETC,)

SAILON 2896 APPENDIX M Id-2 3 (DTYOU) un8glgctr oharrcter output to thr dt8pky bu(f@rl I@ to drt lne a pr l n t h funotlonl DTYOS and DTYOU make It ~ o s d b (DE DPRINC (L) (PROC NIL (DTYOS) (PRINC L? (DTYOU) (RETURN I.))) (CHINIT CHSfZ LINELENGTH LEFTMARGIN) lnltlallzes Internal p@rrm@t@rfi tor DTYOS so that text will be dlrplay@d wl h,izr <CHSIZE> and with llnr length and left marg n rpaa~tlad, 1 Crrquenoe of output) (LOAD <NIL or 7)) *SYSILISPDPS < 1 Order output) *(DISPINIT) <now YOU 0.n U88 the d!8pita~>

L APPENDIX N TRACE by Lynn Quam and Whltfleld Dlffls 1 FUNCTIONS FOR DEBUGGING FUNCTIONS Three different types of debugqlng alds are avallablrr TRACE, TRACET and BREAK, A ) TRACE and Its auxlllar~ functlone UNTRACE and RESET allow oh@ to oonltor the entrance to and exlt trom "tracedw functions, (Warnlngg wse (NOUUO T) wlth oom~llsd funotlons) when a 9racedW function I S entered, (ENTERING (retursl~n dwth> <funotlon name)) Cvrlues of arguwbnts) la t ~ ~ e d When, rwltrd, (LEAVING <recursion decth> <funetlon name>) <result> Is V Y P ~ ~, (TRACE <Ilst of names>) FEXPR aausrs all functions In ll8t of nrmm to br 'tracedtt, TRACE returns a I 1st of names ot those functions wht~h ware prevlous(y not traoed, (UNTRACE <Ilat of names>) FEXPR is the lnvrrse to TRACE,, it restores each fun~tlon to ltr revl lo us untrrord atate, (RESET) EXPR causes all recursion depth oountera to be reset to zero, Only necessary when a traoed funatton is abnormall~ ex1 tad, B) TRACET and Its auxl l lary functl'ons UNTRACET SLST and USLST rl low one to monttor all SET'S or SETQ's to atoms selected tor by SLST, When such a SET or SETQ OGcUrSr 1s prlntrd8 SET <atom name> <value>) or SETQ tatom name> <value>) (Warning - use (NOUUO 7) wtth ~ornollbd funct~bns) < (TRACET) EXPR turns on SETmSETQ monl tor f nq8 t UNTRACET) EXPR turns off SET-SETQ monl tor in^, (SLST <Ilst of atoms)) FEXPR a~prnds CIlat of atoms> to thr lirt of monitored atoms, / L (USLST <Ilst of atoms) rrmovrs eaoh atom from llat of monitored atome,

SASLON 28,6 APPENDIX N N12 C) (BREAK <oommrnt> <rxpr#tsslon>) FEXPR 18 urrful for obraivlng the rtatr of varlablr blndlnar wlthln lrmbda erpra8slonr and progal Whrn BREAK 18 snt~rrd, BREAK, <oommant?) 1s prlntrd, BREAK then rntrrr a READmEVAL.PRINT loop untll an @torn whloh is the vrlur of the atom rbprocced* 18 typed to READ, Thir atom W J I I lnltla~~v be P>, br changed by rettlng tho vrluo of *BPROCEED*, exlt8 wfth <val~@>~ but may BREAK than

APPENDIX o APPENDIX 0 SMILE by Lynn Quam and Whitfield Dfrfle I, 'FUNCTIONS FOR USING OUTPUT DEVICES (LPT) EXPR I t does (OFF) EXPR Is used to start an out~ut file on the line ~rlnte~', (PROG NIL (OUTC (OUTPUT LPT1) T) (LINELENGTH LPTLENGTH) (OUTTIME)) where OUTTIME ~rlnts Q headlng, tlmr and date. 18 used to end an output file, It does cprac NIL (PRINT T) (OUTC NIL TI (LINELENGTH TTYLENGTH)) (LPTOUT <expr-ilst)) FEXPR Is used to ererte an entire out~ut flle on the Ilne~rintsr, It does (PROC NIL (LPT) (HAPC (FUNCTION EVAL) <expr-list)) (OFF)) Exam~les: (LPTQUT (GRfNL ALLFNSI) (LPTOUT (PRINT OBLIST) (PRINT FOO)) (DSKOUT <file name) Cexpr-list)) FEXPR Is used to oreatr an entire output file on disk fi I@ DSKi Ctlle-nome>,~S~, It sets lfnelength to LPTLENGTH, and evaluatrs all expressions In Ce~~r-l lst>, than does (OFF), Exam~lel (DSKOUT NEWFNS (GRINL NEWFNS)) '- L 11, OTHER USEFUL FUNCTIONS (GRINL <atam>) <value of atom)) FEXPR causas rl l atoms In the list (<atom> to be CRINDEFed, For example, (GRINL ALLFNS) will cause ALLFNS and every functfon which has been drflnad by DE, OF, or DM to br CRINDEFed, CRINDEF uses the auxlllar~ lunctlons SPRINT, HUNCJi, PANL, and PPOS,

SAILON 28e6 APPENDIX 0 (GETDEF <drvloe name> <flla namr> <I lrt of tunotlon nrmer>) FEXPR nerds re lrotrd tunotlon det In1 tlonl from 8~rolflrd dbk illw and print8 thr name8 of thore found, GETDEF raturns *@ae (TIMER ~ex~rrsslon llrt)l FEXPR raturn8 the exrcut~on tfmr In ml 1 l \rrcondr of thr exprr8slonr in thr exotrsslon llrt, Exrrn~let (TIMER OGC) (GCW return8 the number of m\lll8@00nd~ nroarsrry to do 2 orrbagr col ~rctionr, (EDIT <atom> told) <nrr>) FEXPR crusr8 rl l oeourrrnor8 ot <bid> r-rxprrrr(on to be re~laord by <new> rarwprr8810n In mmr proparty of <atom>, The ~ r o ~ oto r t ~ ohrnor 18 aeleot@d ar followst Eram~lrr (EDIT OFF TTYLENGTH 105) Would ohrror OFF tot (DEFPROP OFF (LAMBDA NIL (PRO6 NIL (PRINT T) (OUTC NIL T) (LINELENGTH 105))) EXPR) EDIT rrturna T If a ohrnoe war made, 0thrrwl80 NIL,

APPENDIX P ~ CONSTRUCTION OF A LfSP DISK-OECTAPE SYSTEM I r' i L- by Lynn Quam LIST OF FILES, TYPES AND DESTINATIONS f C F I LEs TYPE DESTINATION LISPoMAC MACRO STEPS 2,5 LISPnDMP I I I NOADER,MAC MACRO STEPS 515 LISPoLoD SYMMAKnMAC MACRO STEPS 485 LISPOSYM C ALVINEtMAC MACRO STEP 6 LISPnED,' L LISPoLSP LISP STEP 5 LISPnLSP COMPLR L I SP STEPS 819 COMPLRnCMP LAP SMILE GR I hi LISP LISP L I SP i \. TRACE LISP STEP 5 STEP 5 STEP 5 STEP 5 LAP SMILE GRIN TRACE DISK DECTAPE The fol lowlng oonventions wtl l be made1 OTAS = dectaoe where system wfll be created DTAI deotape where souros fl los are DTAT = dr0ta~e for temdorary fl lea Also# make the fo(low/ng asstgnment~,assign DTASI DSKI

APPENDIX P PmZ 2) To ornsrrte thr LISP INTfRPRETER,R LOADER 3) To ernerato the LISP LOADER.R LOADER +LOADERS?C,START +DfAT;LOADERS (Thlr orrator the mode 17 fllr DSKlLISP,LOO Or DTASILISP.LOD> 4) fa aenerate tho LISP LOADER SYMBOL TABLE,R LOADER *c START *DSKILISP/J,DSKISY~~MAK$ *DTATl LI SP/J, DTAT 1 SyMMAKS <Thlr orr~tra thr fllr DSKlLISP,SYM> or <DTATILISP,SYM> 5) COPY to DSK OP arrs thr rollowlno tt~rst LISP.LSP, SMILE, GRIN, TRACE, and LAP Now If urln9 OECTAPE do;,assign OTASlSYSl

6) To gen@rate ALVINE cr LISP FREE STORAGE = 10000 r Caltrnode> * (LOAD) * (LOAD) + ALVINE $ * DTATI ALVINE $ * (GETSYM SUBR ALVINE) 6 (ALVINE) (Thls createa the flle DSK: LISP,ED> or (DTAS! LISP,ED? COPY the tile LISP,ED to SYS 7) To corn~lle the LISP com~llert 7a) 11 there IS an older revision of the dompflet, do 7b) If there Is not an older version of the COITIPII~~, do,r LISP 32 FREE STORAGE = 1fl000 a Caltmode> (this loads everything) and go to step 8, 8) Actual corn~llation of the LISP COMPILER (SETQ INDEV (QUOTE DTAI!)) * (SETQ OUTDEV (QUOTE DTATt)) <random messages)

SAILON 28,6 APPENDIX P P-4 <Thla Qrnrrrtr8 the file OSKI COMFLR,LAP> ar CDTAT; COMPLR',LAP>, 9) To lord the oornpilrd LISP COMPILER,,R LISP 30 <cr> FREE STORAGE 8 100fl0 8 20000 FULL WORDS = 4000 = 4000 BIN, PROGe SP, 8 1000 a 14000 REG,?DL 8 1000 + one alwtrrnth of?re! atorage R 2000 SPEC, PDL a 1000 + one slxtranth of frre atoraas n 1000 OBLIST SItE 8 177 a 475 * (EXCISE) (NOUUO NIL) *(INC(INPUT SYSt LAP DSKl *(INC(INPUT SYSt LAP DTATf (COMPLR,LAP))) (COMPLR,LAP))),SAVE DSKt COMPLR,SAVE DTAS; COMPLR Copy tha f 1 l r COMPLR,DMP to SYSt

SAILON 28.6 REFERENCES REFERENCES 1, John MoCarthy, et a(,, LISP 1.5 Programmer's Manual (Cambrldgr, Mass., MIT press', 19621, 3, Robert A. Saunders, "LISP - On the Programming System", In Edmond C, Berkley and Danlel G, Bobrow (eds,), The Pro~rammlng Language LISPI Its Operation and A p ~ lcatlons, l 2nd edltlon, (Cambridge, Mass,, Thr MIT Press, 1966)) p,54#

SAILON 28,6 INDEX INDEX ABS ADD1 AL I ST AND' APPEND APPLY ARC ARRAY ASCI 1 ASSOC ATOM BAKGAG BASE B I GNUM BOOLE BPEND BPORG BREAK CAR CDR SUBR o a,, a,,, a,,, e 8 r 1 2 * $ SUBR ( ~ 8 @, ~ o m, ~, r, @ r 1 2 n i LSUBR n arguments t,,,,,... 10-1 LSUBR,,,,.,.,.,,,,, 8 a 7-1 SUBR t r ~ c t r,,, c,, r c, r 6 ~ 2 FSUBR dtfterent,,,,,,,,, a 154 SUBR 8 ~ 8 @ 8 0 @ 8 ~ ~ 0 0 ~ ~ 1 1 * 3 SUBR USBS EQ a, a 8 a e a a 8 8 10-6 SUBR a a a a a a 8 a 3-189-1 SUBR inittallzed to T,,,,,,. 16-1 VALUE InftSalIzed to 8,,,,,,, 4 4, e a,,, a,, v a e, e, Ir4-2 LSUBR,,, a, q,, o, a,, a a, 1 2-3 VALUE top gt blnlry program a ~ a ~, e C-3 VALUE bottom of blnary Dragram space, C-4 FEXPR, 8 * 9 8 8 a N-2 SUBR 1. ~ ~ 1, e 1 ~ 1 ~ ~. ~ 8, 1 0 m 2 SUBR 1 m e,,, *, o *, e a u 1 f l a 2 ( 8 8 @ 8 8 @ ~ 8 @ ~ @ @ 0 8 0 @ @ ~ # CAAAAR SuBR, ~ 8 @ 8 @, @ ~ 8 ) @ ( O @ 1 0 m 2 CDDDDR SUBR a, c i r c r t r c, m r c e, l @ l & chrc~ SUBR @ ~ l ~ 0 8 l ~ ( ) l O ~ ~ ~ COND FSUBR allows more than onr consequent 8-1 SUBR a, o,, e, m a e e e, m r I f l " l 8:; FSUBR, # a, a a, a,, a, a a,, 1 1 ~ 3 DDTIN SUBR,, a,,, 8,., 8 a a 0, 1 4 ~ 3 DOTOUT SUBR OE FSUBR e m,,, a,,,,,,,,, a l l - 2 DEFPROP FSUBR t r t a a 1 1-2 DEPOS I T SUBR @ t t, a, o, @ a e, 0, 1 5-2 DF FSUER, m a,, 8 m a 9 t a a a v e l I - 2 DIFFERENCE MACRO n arguments,,,,,,,, 8, 12-1 DIVIDE SUBR @ # @ ~ ~ @ ~ @ 1 @ 8 1 @ 8 @ a ~ 2 w 1 DM FSUBR @, 8 t, @ @ @ ~ @ + # @ @,. 1 1-2 DSKIN FEXPR a r a,,,,,, I a,,,14-28 ED SugR @ ~ @ ~ 8 @ ~ A w l 8 ~ ~ ~ EDFUN FEXPR, m,,,,,,, a t a, a, a K-1 E Q SUBR t a a * 9, o, o a e,, 8, 9-L EQUAL SUBR 9-1 ERR SUBR t,,, e a, a ( o l m e 8 r l b - l ERRSET F ~ ~ B g,,,,., ~,,,,. r 8. 1 6-1 VAL LsUBR second argument a1 lowed,,. 7-1 EXAIVIINE SUBR,, 8,. q e, * t a, a, @ a 1 5-2 EXARRAY FSU~R,.,,,,,,,,,, 8. 1 5 w 2 EXCISE; SU~R @ ~ @ @ ~ ~ @ ~ * Hwl @ ~ ~ @ ~ @ EXPLODE SUBR @. 1, m,, 1 * a, * e, 1 * 1 0 1 7 EXPLODEC SUBR,, 8 a, a e, * @ @,,,,, l g a 7

SAILON 28,6 INDEX J N Dm2 EXPR FEXPR * r u * e e e e : t e e * c e 6m2 FILEIN FEXPR. *, e e e e e. e, e e * * e K-1 FILENAMES *, q 8, * e e, * e * e 8 e e 1 4 - i FIX SUBR t *, e e e * a e, e e e, e, 1 2 = 2 FIXlA SYM * *, e e e e e e e, e e e e e Em2 F I XNUM * e * e e a e e e e e e e,, e 4'2 FLATS1 2E SUBR * e t e e e * e e e * e * e a e l @ n 7 FLONUM, @ a e e e e e * e * @ e o @, 4-3 FORCE SUBR 0 1 e. e e e e * e o o e e e 1 4 * 3 FSUBR *. * @ Q * * e * * e * * e e * e Em4 FUNARG. @ o, *. * @ * * e @ @ * @ 7m4 FUNCTION FSUBR, e, e 7-1 FUNCTIONAL ARGUMENTS e e e e * * e e l, @ 7-1 6C SUBf? @ ( @ @ @ @ @ 6 @ ( 1 @, ( 8 @ Dvl GCD SUBR c r ~ e c r r c c r e c c c r i ~ ~ i GCGAC SUBR * e t e e e e e e * * e e, * e 0-1 ' CCTIME SUBR * e * e e ~ e * * * * e e, * * 0-1 GENSY M SUBR *, e a a a e *, *, e e t * e l % m 3 GET SUBR e e t e * ~ e ~ e o o e o e 1 1 m l GETL SUBR * v e e a e e e * e, e e * * e e l i ~ l GE TSY M FEXPR e e * e e e e * e * *, e e * e Ha1 GO fsubr *., * e e e *., * * 0, * * 1 3-1., @ GREATERP MACRO n~rgurnrntr~,. GRINBEF FSUBR, e e e o t e r * e e Am1 I BASE VALUE fnftiailtrdto8 * t * I, 4-1 IDENTIFIER * e, * e e e n,,, e * e a e 3-1 I NC SUBR *,, *, e e e.,,, e e, e 1 4 m 2 INITFN SWBR e e, e e e * e e e e e *, * e % 6 ~ 1 I,. 913 INPUT FSUBR e e * *,, e e 1 4 * 1 t NTECER e e ~ e e o ~ e t * e e e * 411, f NTERN SUBR e e e e, e * * e t e e e * f i e I 1 ~ 2 LABEL, * * e e * e e * e m e m t a q 6 4 LAMBDA a ~ t e e e t e a e 6-P. LAST SUBR rrturnr and of I t,,. $012 LENGTH SUBR. e e e e e e e e e o * * e - e e t l f l. 4 CESSP blacro pargumrnt$t. * I 9-3 LEXpR e q * e e * e * e e t e e o * 6-2 L 1 NELENGTH SUBR e. * ~, * e e e * + e o e 1 4 ' 5 LIST FSUBR e e e e e e r ~ e e a e. 1 0 ~ 1 LOAD SUBR 8 ~ * * e * e * e o e e e * * * Hw& LSH SUBR * e * e * e * * e * e * f i * e # l z - J LSUBR, e,, @ * e @ e, ~ @ o * e @ E-4 MACRO e r o q * e * e, o e, * e 6-3 MAKNAM SUBR * v * * e e e * e e t e e t e e e 1 f l m 7 MANNUM SUBR * e * * e e e e e g * e e a * e w MAP SUBR d)+?@r@nt argumrnt order,.,,, 10-5 MAPC SUBR t1 e r r 10a5 1) t* MAPCAR SUBR 91 *, r 10-6 1, t *I YAPL I ST SUBR tt e e e 104 MEMBER SUBR UIIU EQUAL 8 e e o MEMQ SUBR ~ ~ ~ ~ E Q u e t t * 9*2 e e m r w

MINUS M 1 NUSP NCONC NCONS NIL NOT NOUWO NULL NUMBER NUMBER? NUMVAL OBLIST OR OUTC OUTPUT PGL I NE PLUS PNAhE PRINl PRIrVC SUBR SUBR LSUBR SUBR VALUE SUBR SUBR SUBR SUBR SUBR VALUE: FSUBR SUBR FSUBR SUBR MACRO INDEX SUBR SUBR PRINT SUBR. PROG FSUBR, m @ *, a, a *, ~ a o,, @ 1 3 - I?ROC2 SUBR allows UP to 5 arguments, @. 13-1 PROPERTY LIST r q a, * c m r c. a r m o e r 3-2 PUTPROP SWBR order of arguments different 11-1 PUTSVM FEXPR @ a a e a o a @ o, o @ a m, H-2,.,.. 1211. QUOTE FsueR @ m, * v, * a t o *, o,,, 7-1 QUO1 IENT MACRO n a I READ SUBR e r a e v a *, o v o a a o r 1 4-3 READCH SUBR, e a a o a e a e t e a a a ~ @ I 4 ~ 4 READL I ST SUBR ) @ a o @ o @ a @ @ m @ @ a.. l 0-7 REMA I NDER SUBR #. o o e e e q * e, o e,, m l 2 m l REMOB FSUBR o e t o e o e o m t a a ~, o @ l A ~ 2 REMPROP SUBR @, a a @ o o e o a r, o @ i l ~ l RESET EXPR @ a o @ e o o @ * t o o @ e o RETURN SUBR, @ a, @ o @ e o, o o, a @ 1 3-1 REVERSE SUBR m m a o * o e o m @ e o a o @ @ 1 f l m 4 RPLACA SUBR @. a ~ ~ a @ o. @ ~ a r u ~ 1 0 ~ 3 RPLACD SUBR @ q a o ~.. o a a m a * @ a A J m 3 SASSOC SUBR U S ~ S EQ a a m t a a I a 8 10-6 SET SUBR @ ~ o m e o @ o, e @ @ ~ a o, I ~ ~ 2 SETARG SUBR e m a m r, e m c, a r m c r m 6-3 SET Q FsUBR, @ @ @ @ @ @ a, @ e a m @,, 1 1 ~ 2 SEXPRESSION @. a @ @ a a m e o, a @ o a e 5-1 SPEAK SUBR, q ~ v m, e #, ~ r @ a, a D-1 e SPECB I ND SYM q a 1 a * ~ * ~ e a v e @ a a E-2 m SPECSTR SYM, @ o @ m a,, @, e e @ a, a Em2 SPEC I AL not In Interpreter r I e F-1 SPECIAL VARIABLES t, a a @ e e, m @ @ @ m e a * 7-3 SPRINT SUBR, m,, m t e @ @ o * a o m A 4 ST ORE: f'sub4 o a o, t t @ 1 5-2 STRING t m ~,. a * o * a ~ @ a o 3-3 a ~

~ U B I SU$R SUBR SUBS7 SUBR T VALUE TERPR 1 SUBR TIME SUBR TIMES. MACRO TRACE FEXPR TRACET EXPR TYI. SU8R TYO SUBR VALUE VARIABLE BINDINGS %CONS SUBR ZERQP SUBR SYM SUBR SUBR SUBR SUBR SUBR QSURR SUBR SUBR SYM SUBR VALUE SUBR SUBR SUBR SUBR SU0R