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

Form & Function in Software. Richard P. Gabriel phd mfa

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


MASSACHUSETTS INSTITUTE OF TECHNOLOGY PROJECT MAC. Memorandum-M-352 July 21, 1967 ABSTRACT

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*