May Be Protected (Title 17 U.S.C.)
Total Page:16
File Type:pdf, Size:1020Kb
UCI LISP MANUAL by Robert J. Bobrow Richard R= Burton Jeffrey lU Jacobs ' Daryle Lewis Notice: This Material may be protected by Copyright Law (Title 17 U.S.C.) Department of Information and Computer Science University of California, Irvine TECHNICAL REPORT #21 updated 10/73 Table of Contents. Introduction Oo 0 Debugging Facilities 1» 1 Introduction 1= 1 Temporarily Interrupting a Computation 1» 5 BREAKl - The Function that Supervises all Breaks 1= 6 What You Can Do In a Break 1- 8 Break.Commands 1. 8 Leaving a break with a value (0K,GO,EVAL,FROM ?) 1.8 Correction of UNBOUMD ATOM and UNDEFINED FUNCTION errors (>, USE) 1. 9 Aborting to Higher Breaks or the Top Level (t, TT) 1-10 Examining and Modifying the Context of a Break 1.11 Searching for a Context on the Stack 1.11 Editing a Form on the Context Stack 1.12 Evaluating a Form in a Higher Context 1.12 Backtrace Commands Printing the Functions, Forms and Variable Bindings on the Context Stack 1.15 Breakmacros User Defined Break Commands 1.17 How to Use the Break Package 1.18 Setting a Break to Investigate a Function 1.18 Tracing the Execution of Functions 1.19 Setting a Break INSIDE a Function 1.19 Removing Breaks and Traces 1.21 Using BREAKO Directly to Obtain Special Effects from the Break Package 1.23 Error Package - Getting Automatic Breaks 'When Errors Occur 1.24 Summary of Break Commands 1.25 The LISP Editor 2o 1 Introduction 2. 2 Coinmands for the Nev/ User 2.1Q Attention Changing Commands 2.15 Local Attention Changing Commands 2.16 Commands That Search 2.22 Search Algorithm 2.24 Search Commands 2.26 Location Specification 2.30 Commands That Save and Restore the Edit Chain 2.36 Commands That Modify Structure 2.33 Implementation of Structure Modification Commands 2.39 The A, R, : Commands 2.41 Form Oriented Editing and the Role of UP 2.45* Extract and Embed 2.46 The MOVE Command 2.50 Commands That "Move Parentheses" 2.54 TO and THRU 2.57 Commands That Print 2.62 Commands That Evaluate 2.63 Commands That Test 2.66 Macros • 2.68 Miscellaneous Commands 2.71 Editdefault 2.78 Editor Functions 2.80 Extended Interpretation of LISP Forms 3. 1 Evaluation of Sequences of Forms Extended LAflBDA Expressions 3. 1 The Functions PROGl and PROGU 3. 2 Conditional Evaluation of Forms - SELECTQ 3. 3 Changes to the Handling of Errors 3. 4 Miscellania - APPLY ff, MILL 3. 5 Extensions to the Standard Input/Output Functions 4» 1 Project-Programmer numbers'for Disk I/O 4. 1 Saving Function Definitions, etc. on Disk Files 4o 1 •Reading Files Back In . 4. 1. 1 Reading Directories 4. 1. 2 File Manipulation 4. 1. 4 Queuing Files 4. 1. 7 Recovery from QMANGR Errors 4. lo 10 Printing Circular or Deeply Nested.Lists 4o 2 Spacing Control - TAB 4o 2 "Pretty Printing" Function Definitions and S-Expressions 4. 3 Reading VJhole Lines 4. 4 Teletype and Prompt Character Control Functions 4.. 5 Read Macros - Extending the LISP READ Routine 4» 6 Functions for Defining Read Macros 4o 6 Using Read Macros 4. 7 Modifying the READ Control Table 4. 8 Reading without Interning 4. 9 New Functions on S-Expressions 5. 1 S-Expression Building Functions 5. 1 S-Expression Transforming Functions 5. 3 S-Expression Modifying Functions 5. 4 Mapping Functions with Several Arguments 5. 5 Mapping Functions v/hich use NCCrJC 5o 5 S-Expression Searching and Substitution Functions 5. 7 Efficiently 'Norking v.'ith Atoms as Character Strings 5. 9 Nev/ Predicates 6 . 1 Data Type Predicates 6. 1 Alphabetic Ordering Predicate 6o 2 Predicates That Return Useful Non-NIL Values 6. 3 Other Predicates 6 = 4 Nev/ Numeric Functions 7o 1 Minimum and Maximum 7. 1 FORTRAN Functions in LISP 7 = 2 Functions for the Systen Builder 8. 1 Loading Conpiled Code into the High Segment 8. 1 The Compiler and LAP -8o 2 Special Variables 8» 2 Removing Excess Entry Points • 8. 2 MiscellaneousUsefulFunctions 8. 3 Initial System Generation 8. 4 The LISP Evaluation Context Stack 9. 1 The Contents of the Context Stack 9= 1 Examining the Context Stack 9» 2 Controlling Evaluation Context 9. 4 Storage Allocation 10. 1 Contiguous Blocks of Storage 11. 1 Index INDEX. •INTRODUCTIOM UCI LISP is a compatible extension of the Stanford LISP 1=6 programming system for the DEC PpP-lOo The extensions make UCI LISP a pov/erful and convenient interactive programming environment for research and teaching in artificial intelligence and advanced list processing applications= All Stanford LISP programs, (except those using the ' BIGMUM package) can be run directly in UCI LISP. In addition, the extended features of UCI LISP make it much, easier to transfer interpreted LISP programs from BBN LISP and MIT AI LISP (we have already converted several large programs, including a version of the Woods' Augmented Transition Network Parser from BBM LISP, and a version of Micro-Planner from MIT AI LISP.) This manual describes the extensions to the Stanford LISP 1.6 system, and should thus be read in conjunction v/ith the latest Stanford LISP 1.6 manual, currently SAILOH 28.6 (Stanford Artificial Intelligence Laboratory Operating Note 28.6). As can be seen from the relative sizes of the tv/o documents UCI LISP represents a substantial extension to Stanford LISP, and from our ov;n experience presents a major improvement in the habitability of the system for both naive and experienced users. (A majority of the extensions were suggested by the features of BBN LISP, probably the best interactive . LISP system in existence, but unfortunately available at the time UCI LISP v.'as implemented only on TENEX, a paged virtual memory system for the PDP-10, produced by Bolt, Beranek and Nev^man Inc.; this I,ISP system is now or soon will be available on the BURROUGHS 36700 and the IBM S/360 and S/370 series m.achines, and is nov; called IMTERLISP.) The major extensions to Stanford LISP can be briefly described as follov/s: 1) Improvements in storage utilization: a) UCI LISP is reentrant and com.piled code may be placed in the sharable high segment b) The allocator a1lows reallocation of all spaces (including Binary Program Space) at any time, and new versions of GETSYM and PUTSYM are now available to permit relocation of MACRO-10 and FORTRAN coded routines c) A new data type, the BLOCK, v^;hich allov/ users freer access to Binary Program Space and permits the construction of data items such as the system OBLIST, which is both a list and a contiguous block of storage (to provide efficient use as a sequential hash table) 2) Powerful interactive debugging facilities, including: a) Sophisticated conditional breakpoint and function tracing facilities b) A powerful list structure editor for editing function definitions and data c) Facilities for examining, correcting and continuing to run in the context of a program v/hich has been interrupted by an error or by a user initiated temporary interrupt 3) Extensions to the I/O facilities available in the basic system, including: a) Convenient I/O to disk files, including use of project/programmer designations and v/ays to save and restore functions and data b) Read Macros (patterned after MIT AI LISP) for extending the LISP READ routine c) A routine for printing circular or deeply nested expressions d) Routines to modify the control table of the LISP READ routine e) The ability to change the OBLIST used by INTERN (and, hence, READ) at any time by changing the value of the atom OBLIST to a properly structured BLOCK list (see Ic above and Chapter 11) f) The ability to RENAME and DELETE files from within LISP g) The ability to read file directories for any accessible project-programmer number, to see if a file exists in a directory h) Several useful functions for carriage positioning, teletype echo and prompt character control, reading input a line at a time, reading list structures v;ithout interning their atoms, etc- 4) Functions for examining and modifying the special pushdown stack v/hich holds the context of ongoing computations 5) Error protection facilities: a) NIL, T and other atoms cannot be easily damaged by RPLACA, RPLACD, SETP and SET b) The system v;ill no longer go into an infinite loop V7hen searching for the function definition of the CAR of a form c) Changes to the disk output routine DSKOUT so that it uses the RENAME facility to provide a backup for user files (m.inimizing the risk of unintentionally clobbering files) 6) Extended basic functions including: a) New predicates for data types, and most predicates now return useful non-MIL values, rather than T b) New list construction and modification functions c) Multiple sequential form evaluation in LAMBDA expressions d) An efficient n-v;ay switch e) Availability of the FORTRAN mathematical functions f) Mapping functions with several arguments, and ones which build new lists using NCONC to join segments 7) The ability to use. many of the system Queue Manager's facilities without leaving LISP, a 1 lov^ing: a) Listing of files on the line printer b) Initiation of batch jobs As mentioned, v/e have made UCI LISP a reentrant system which may be used by several users simultaneously. Thus, v/hile the new features of UCI LISP reouire a larger system than the original Stanford LISP, this impact is minimized in any environment with more than one LISP user. In addition, since the ba sic LISP system contains many features previously available only in the various extension files (such as SMILE, ALVINE, TRACE, etc.) or which had to bo written by the user, it is possible to write and debug meaningful jobs in the basic system, without getting extra core.