GPW/10:33, August 21, 1984 HLISP Reference Manual Version 6 1.0 INTRODUCTION . . . . . . . . . . . . . . . . . . . . 2 2.0 PRELIMINARIES . . . . . . . . . . . . . . . . . . . 3 2.1 Primitive Data Types . . . . . . . . . . . . . . . 3 2.2 Classes Of Primitive Data Types . . . . . . . . . 5 2.3 Structures . . . . . . . . . . . . . . . . . . . . 6 2.4 Function Descriptions . . . . . . . . . . . . . . 7 2.5 Function Types . . . . . . . . . . . . . . . . . . 8 2.6 The Extended Syntax . . . . . . . . . . . . . . . 9 2.7 Error And Warning Messages. . . . . . . . . . . 10 2.8 Comments . . . . . . . . . . . . . . . . . . . . 10 2.9 Input Syntax . . . . . . . . . . . . . . . . . . 10 2.9.1 Superbrackets . . . . . . . . . . . . . . . . 10 2.9.2 Configurable Lexical Analyzer . . . . . . . . 11 2.10 Input Redirection Using GCML . . . . . . . . . . 13 3.0 FUNCTIONS . . . . . . . . . . . . . . . . . . . . 14 3.1 Elementary Predicates . . . . . . . . . . . . . 14 3.2 Functions On Dotted-Pairs . . . . . . . . . . . 16 3.3 Identifiers . . . . . . . . . . . . . . . . . . 18 3.4 Property List Functions . . . . . . . . . . . . 20 3.5 Function Definition . . . . . . . . . . . . . . 22 3.6 Variables And Bindings . . . . . . . . . . . . . 25 3.7 Program Feature Functions . . . . . . . . . . . 26 3.8 Error Handling . . . . . . . . . . . . . . . . . 30 3.9 Vectors . . . . . . . . . . . . . . . . . . . . 31 3.10 Boolean Functions And Conditionals . . . . . . . 32 3.11 Arithmetic Functions . . . . . . . . . . . . . . 33 3.12 MAP Composite Functions . . . . . . . . . . . . 36 3.13 Composite Functions . . . . . . . . . . . . . . 37 3.14 The Interpreter . . . . . . . . . . . . . . . . 41 3.15 Input And Output . . . . . . . . . . . . . . . . 45 3.16 LISP Reader . . . . . . . . . . . . . . . . . . 52 3.17 String Functions . . . . . . . . . . . . . . . . 52 3.18 System Related Functions . . . . . . . . . . . . 55 4.0 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS . . . . . 59 APPENDIX A FILES DELIVERED APPENDIX B REFERENCES Index - 1 - HLISP Reference Manual Page 2 INTRODUCTION 21 Aug 84 1.0 INTRODUCTION This document is intended to serve as a reference manual for HLISP ("Hacker's LISP"), version 6 (see the system constant VERSION). HLISP is an implementation of LISP on the DEC VAX under the VMS operating system. It is not intended to be an extremely efficient implementation, but rather an experimental system intended primarily for educational purposes and R&D. This document and the software it describes is not intended for commercial purposes. This document is not intended to be an introduction to LISP. Rather it assumes that the reader is already familiar with the basic concepts of LISP as a language, and needs only the details of the specific implementation. Those wishing to read introductory material are referred to books such as [2][3][4][5]. There is no such thing as a true standard for the language LISP. The most popular dialects of LISP are presently derived from either MACLISP or INTERLISP. Unfortunately, there are some rather large disparities between these two dialects, and there are advocates of both approaches to the language. [Recently, there has been a new effort to standardize LISP, leading to the development of what is now called COMMON LISP. I have very little information on this new dialect, but it seems to be based on MACLISP.] HLISP is intended to be most compatible with Standard LISP as defined by the paper "Standard LISP Report", by J. Marti, et al [1], hereafter referred to simply as the Report. Though the Report is by no means accepted as setting a new standard for all to conform to, it is at least a step in the direction of portability. The current implementation is not yet, nor will it likely ever be, a fully compatable implementation of this particular definition, however it is the preferred baseline.` HLISP presently implements a large part of this standard, and contains many extensions. The remainder of this document is structured similar to the Report. The descriptions given will frequently assume knowledge of the contents of the Report, and will use it as a baseline to compare this implementation. In fact, in places text similar to that in the Report has been used, and much of the remainder will be in terms of differences from the Report. Where no details are given, or statements made to the contrary, the contents of the Report may be assumed to be correct. An attempt has been made to distinguish between what is "standard" and what is not using the following notations: - 2 - HLISP Reference Manual Page 3 INTRODUCTION 21 Aug 84 * [standard] - This indicates that the implementation is according to the standard as defined in the Report. * [subset] - This indicates that the implementation is a subset of the standard as defined in the Report. * [superset] - This indicates that the implementation is a superset of the standard as defined in the Report. * [non-standard] - This indicates that the implementation is different from the standard defined in the Report. * [not implemented] - This indicates that the item in the Report is not implemented at the present time. This does not imply that the item will or will not be implemented in the future. Note that a definition may be indicated as [standard] (or [superset], etc.) and still have non-standard aspects; such definitions will have specific aspects of the definition marked as to the degree of compliance with the standard. 2.0 PRELIMINARIES In this and subsequent sections, references are often made to nodes and the node pool. A node is the unit of storage allocation in LISP memory (presently ten bytes), and the node pool is the collection of all nodes which are available for use by the LISP system. 2.1 Primitive Data Types * Integer - I*4 [subset] The Report permits integers of an arbitrary number of digits. HLISP implements integers as 32 bit binary integers. Each integer uses one node in the node pool. * Floating - R*4 [subset] The Report permits a floating point number to begin with a period (when being read by the input system); this is not allowed. Each floating number uses one node in the node pool. - 3 - HLISP Reference Manual Page 4 PRELIMINARIES 21 Aug 84 * Id or identifier - A string of characters which may have the following things associated with it: - print name - the characters of the identifier. - flags - [not implemented] - properties - An identifier may have an indicator-value pair associated with it. Access is by the PUT, GET, REMPROP and related functions defined in the "Property List Functions" section. - values/functions - An identifier may have a value associated with it. Access to values is by SET and SETQ defined in the "Variables and Bindings" section. All bindings are presently fluid [subset]. An identifier may have a function or macro associated with it. Access is by the GETD, PUTD, REMD and related functions defined in the "Function Definition" section. An identifier may currently have both a value and a function associated with it [non-standard]. If this is the case, EVAL will return the value. Each id uses one node from the node pool as its "identity," plus a list of properties and values. - OBLIST entry - An identifier may be entered and removed from a structure called the OBLIST. Its presence on the OBLIST does not directly affect the other properties. Access to the OBLIST is by INTERN, REMOB, and related functions defined in the "Identifiers" section, and READ defined in the section "Input and Output". The maximum length of an HLISP identifier is 64 characters [superset]. The escape character "!" (defined in the Report) has no significance in this implementation since identifiers (as well as other tokens) are parsed using a table driven, finite state parser, which is configurable by the user [superset] using the LEX function. This parser is discussed in more detail in the sections "Input and Output" and "Configurable Lexical Analyzer". * string - A set of characters enclosed in quote characters. Quote characters are characters whose character class is that of a quote delimiter (CHRCLQUOTE), e.g., the double quote character (") [superset]. Strings have a maximum length of 32767 characters [superset]. - 4 - HLISP Reference Manual Page 5 PRELIMINARIES 21 Aug 84 * dotted-pair - A primitive structure which has a left and right part. A notation called dot-notation is used for dotted pairs and takes the form: (.) The is known as the CAR portion and the is known as the CDR portion. The left and right parts may be of any type. [standard] * vector - A primitive uniform structure in which an integer index is used to access random values in the structure. The individual elements of a vector may be of any type. [standard] * typed vector - [superset] A vector whose elements must all be of the same type. Currently supported types are: - FIXNUM - integers (I*4) - FLTNUM - floating point (R*4) Typed vectors are a special case of vectors. * function pointer - pointer to compiled functions. Function pointers are displayed and EXPLODEd as eight digit hexadecimal numbers. [standard] 2.2 Classes Of Primitive Data Types * boolean - The set of system variables {T,NIL}, or their respective values, {T,NIL}. (See the section "System GLOBAL Variables".) [standard] * extra-boolean - Any value in the system. Anything that is not NIL has the boolean interpretation T. [standard] * ftype - The class of definable function types. The set of ids {EXPR, FEXPR, MACRO} [standard]. In addition, there are several types of compiled functions: {SUBR, FSUBR, LSUBR}. Compiled functions must presently be builtin to HLISP. * number - The set of {integer, floating}. [standard] - 5 - HLISP Reference Manual Page 6 PRELIMINARIES 21 Aug 84 * constant - The set of {integer, floating, string, vector, function-pointer}. Constants evaluate to themselves (see the definition of EVAL in the section "The Interpreter"). [standard] * any - The set of {integer, floating, string, id, dotted-pair, vector, function-pointer}. An S-expression is another term for any. All LISP entities have some value unless an error occurs during evaluation. [standard] * atom - The set {any}-{dotted-pair}. [standard] 2.3 Structures Structures are entities created out of the primitive types by the use of dotted-pairs. Lists are structures very commonly required as actual parameters to functions. Where a list of homogeneous entities is required by a function this class will be denoted by xxx-list where xxx is the name of a class of primitives or structures. Thus a list of ids is an id-list, a list of integeres is an integer-list, etc. * list - A list is recursively defined as NIL or the dotted-pair (any . list). Note: () is an alternate input representation of NIL. [standard] * alist - An association list [standard]. Each element of the list is a dotted-pair, the CAR part being a key associated with the value in the CDR part. * cond-form - A cond-form is a list of two element lists of the form: (ANTECEDENT:any CONSEQUENT:any) [standard]. The first element will henceforth be known as the antecedent and the second as the consequent. The antecedent must have a value. The consequent may have a value or an occurence of GO or RETURN as described in the section "Program Feature Functions". * lambda - A LAMBDA expression which must have the form in list notation: (LAMBDA parameter-spec body) The parameter-spec must be a list [standard] of formal parameters or a single id [superset] (see the section "Function Types"). The body is one or more S-expressions to be evaluated [superset]. The value of the last - 6 - HLISP Reference Manual Page 7 PRELIMINARIES 21 Aug 84 S-expression is returned. The semantics of the evaluation are defined with the EVAL function (see the section "The Interpreter"). * function - A LAMBDA expression or a function-pointer. * funarg - A funarg binds a function to an environment. It must have the form in list notation: (FUNARG function alist) When a function (F1) is to passed as an argument (a function argument, hence the name funarg) to another function (F2), so that F2 can apply that F1 to argument lists which it generates, a funarg may be used to bind a particular environment to F1 to eliminate possible problems caused when bindings referenced within F1 might be different than desired within the evaluation of F2. The function FUNCTION may be used to generate a funarg referencing the current environment. 2.4 Function Descriptions Each function is provided with a prototypical header line. Each formal parameter is given a name and suffixed with its allowed type. Lower case tokens are names of classes and upper case tokens are parameter names referred to in the definition. The type of the value returned by the function (if any) is suffixed to the parameter list. If it is not commonly used, the parameter type may be a specific set enclosed in braces {...}. For example: * PUTD (FNAME:id, TYPE:ftype, BODY:function):id PUTD is a function with three parameters. The parameter FNAME is an id to be the name of the function being defined. TYPE is the type of the function being defined and BODY is the function being defined. PUTD returns the name of the function being defined. Functions which accept formal parameter lists of arbitrary length have the type class and parameter enclosed in square brackets indicating zero or more occurrences of that argument are permitted. For example: * AND([U:any]):extra-boolean AND is a function which accepts zero or more arguments, which may be of any type. - 7 - HLISP Reference Manual Page 8 PRELIMINARIES 21 Aug 84 2.5 Function Types Functions are classified based on how their arguments are passed. This is determined by both the ftype of defined functions and by the form of the parameter-spec of lambda expressions. Argument passing can be classified using the following terms: * EVAL type functions are those which are invoked with evaluated arguments. * NOEVAL functions are those which are invoked with unevaluated arguments. * SPREAD type functions have their arguments passed in a one-to-one correspondence with their formal parameters. The number of arguments must exactly match the number of parameters. * NOSPREAD type functions have their arguments passed as a single list. In the context of the description of EVAL functions, when we speak of the formal parameters, we mean their values. However, in NOEVAL functions it is the unevaluated actual parameters. Normally, functions are defined using DE or DEFINE and have a list as the parameter-spec of the defined function. In this case, the function is of type EVAL, SPREAD. This is also the case for lambda expressions with a list as their parameter-spec which are APPLY'd or when such a lambda expression is the first member of a list which is EVAL'd. However, if the parameter-spec is atomic, the function is of type EVAL, NOSPREAD. In this case, the single parameter contains the number of actual arguments, and the actual arguments must be obtained using the ARG function. Functions defined using DF are of type NOEVAL, NOSPREAD, regardless of whether the parameter-spec is a list or is atomic. However, there is a distinction between these two types in how the parameters are actually passed to the function: * these functions with a single atom as the parameter-spec have this atom as a single parameter which contains the number of actual arguments, and the actual arguments must be obtained using the ARG function. * these functions with a list as their parameter-spec may have zero, one, or two parameters. The first parameter, if present, receives the entire unevaluated expression which is the invocation of the function. The second parameter, if present, receives the alist with which the expression is to be evaluated. - 8 - HLISP Reference Manual Page 9 PRELIMINARIES 21 Aug 84 Functions defined using DE or DEFINE with a single atom parameter-spec lambda expression as their definition differ from functions defined using DF (or builtin FSUBRs) in that the arguments of DF are not evaluated by EVAL before being invoked, whereas NOSPREAD style lambda expression definitions (and LSUBRs) have their arguments evaluated by EVAL before their definition is invoked. [This is a rather subtle distinction that generally makes no difference when the function evaluates its own arguments, but can cause apparently anomalous behaviour when the function is APPLY'd.] MACROs are defined using DM, and are of type NOEVAL, NOSPREAD. They differ from other NOEVAL, NOSPREAD forms in that their associated function is always invoked with exactly one argument. That argument contains the entire S-expression which is the invocation of the macro in the form of a list. When the macro has been evaluated, the resulting S-expression is then reevaluated. The parameter-spec of the macro definition may be either a list containing a single formal parameter, or a single atom. In either case, the manner in which the argument is bound to the formal parameter is analogous to the mechanisms used for other function types. READMACROs are defined using DRM, and have no arguments. For this reason, their classification as EVAL vs. NOEVAL and SPREAD vs. NOSPREAD is not significant. READMACROs are evaluated when their name is encountered by READ, and the result of their evaluation is returned by READ. There are several types of compiled functions. SUBRs correspond to EXPRs and are of type EVAL, SPREAD. However, some of the builtin SUBRs can accept a variable number of arguments. FSUBRs correspond to FEXPRs and are of type NOEVAL, NOSPREAD. An additional type of function is the LSUBR, which presently has no directly corresponding function type in HLISP. LSUBRs are of type EVAL, NOSPREAD, and may therefore be simulated using the atomic form of parameter-spec with DE or DEFINE. The number of parameters that functions may have is limited only by space on the internal function call stack [superset]. The size of this stack and the amount of it which has not been used may be displayed using the STATUS function. 2.6 The Extended Syntax Functions that may be conveniently defined in LISP appear in a subset of the REDUCE syntax [reference 3 in the Report] which seems somewhat easier to read than LISP. A formal translation scheme for the extended syntax to LISP is presented in Appendix A of the Report. The definitions supplied are not intended as rigourous implementation definitions, but rather as precise definitions of the functions' semantics. - 9 - HLISP Reference Manual Page 10 PRELIMINARIES 21 Aug 84 2.7 Error And Warning Messages. Many functions detect errors. The description of such functions will include these error conditions and formats for the display of the generated error messages. A call on the ERROR function is implied but HLISP does not use error numbers [non-standard]. Warnings are not issued [subset]. 2.8 Comments The character % signals the start of a comment, text to be ignored during parsing. A comment is terminated by the end of the line it is on. The function READCH can read a comment one character at a time. Comments are transparent to the function READ. Other characters may be identified as comment characters using the LEX function [superset] as described in the sections "Input and Output" and "Configurable Lexical Analyzer". The escape character ! specified in the Report has no effect on the comment character, and comment characters may not be used in identifiers [subset]. However, the LEX function may be used to change % to a different character class so that it may be read. A semicolon (;) in column one of an input record identifies the entire line as a comment [superset]. Such lines may not be read by READCH and are completely transparent to the input system. 2.9 Input Syntax Normally, LISP input functions and data are read in standard list notation (see sections 2.1 through 2.3 of the Report). HLISP has several extensions to the standard LISP input syntax. 2.9.1 Superbrackets - The function READ supports list syntax using square brackets (aka "superbrackets") in addition to parentheses. A right bracket may be used to terminate parenthesized lists early, to any depth. The outermost list is implicitly enclosed in brackets. (Note that these extensions are not supported by the LINT utility.) - 10 - HLISP Reference Manual Page 11 PRELIMINARIES 21 Aug 84 2.9.2 Configurable Lexical Analyzer - HLISP contains a user configurable lexical analyzer as an extension. This has introduced a few deviations from the lexical syntax described in the Report: - ! is not an escape character - floating point numbers may not begin with a dot (.) character (use a leading zero), since it is used for dotted-pair notation I believe these minor deviations from the standard are acceptable given the added capability provided. The basic idea behind the lexical analyzer is that characters are processed one at a time, and tokens are constructed based on classes associated with each character. When the lexical analyzer is invoked by the HLISP input system to obtain the next token, it examines characters sequentially from the current input stream. Initial "white space" characters (blanks, tabs, etc.) are discarded based on their character class. The first character of a token determines the type of the token (e.g., identifier, number, special character). Subsequent characters which are compatible with the type of token being constructed are added to the token. When a character is encountered which is either a white space character, or one whose character class is incompatible with the type of token being constructed, the token is considered complete. HLISP contains a table which defines the character class for each ASCII character. This table may be referenced and/or modified using the function LEX. The classes are referenced using symbolic constants built into the HLISP system. Below is a list of the symbolic names for the classes, and a description of their effect when encountered by the lexical analyzer. * CHRCLALPHA Alphabetic. Any character which may start an identifier. * CHRCLCOMBEG Beginning comment delimiter. Pascal style comments may be introduced into the syntax by defining the left brace ({) to have this class. See CHRCLCOMEND. * CHRCLCOMEND Ending comment delimiter. Pascal style comments may be introduced into the syntax by defining the right brace (}) to have this class. See CHRCLCOMBEG. - 11 - HLISP Reference Manual Page 12 PRELIMINARIES 21 Aug 84 * CHRCLINTID Internal identifier class. Characters that may be used within identifiers but which are not to be used to start an identifier (e.g., "_" in some languages). * CHRCLMONOP Special characters that always are single character tokens (identifiers in LISP). * CHRCLNULL Characters that are always ignored completely. These characters may be freely imbedded in other tokens (except strings) without affecting their identity. * CHRCLNUMERIC Numeric. Characters of this class indicate the beginning of a numeric token (integer or floating point). Characters of this class may be contained in identifiers. * CHRCLQUOTE String literal delimiter. * CHRCLSPECIAL Special characters that may form multi-character tokens, but are are distinct from identifiers beginning with characters of class CHRCLALPHA. * CHRCLTERMN Terminator. Characters of this class always terminate processing of an input record by the lexical analyzer, terminating the token currently being parsed. The ASCII NUL character (code 0) is always of this class, and its class may not be changed. * CHRCLWHSPACE White space characters. These characters delimit tokens and may be used freely between tokens, they are otherwise ignored. In addition there is an additional class which is not a character class, but is used internally by the HLISP input system. * CHRCLFLOAT Floating point. This is the class returned to the input system by the lexical analyzer when it has detected a numeric token which is of floating point type. It is a predefined symbol, but has no significance or use to the LISP user. - 12 - HLISP Reference Manual Page 13 PRELIMINARIES 21 Aug 84 2.10 Input Redirection Using GCML All input read by the HLISP input system is read using the (more or less standard) library routine GCML. GCML permits input to be redirected to a file using either of two mechanisms. The first allows the file to be used as a subroutine, including the capability to nest them up to three levels deep. The second provides for chaining between files without adding to the nesting. These two mechanisms may be used independantly or together. In both cases, files of this type are typically referred to as indirect command files. To invoke input redirection the first column of an input record must contain either a "commercial at" sign (@) for nested input file invocation, or an ampersand (&) for file chaining. This flag character is intercepted by the input system, and a file specification must follow it starting in column two of the input record. Complete VMS file specifications are supported, with the device and directory defaulting to the user's current defaults, and the file extension defaulting to "LSP". No other data may be on the same input record as the control information used to redirect input in this manner. HLISP also permits input to be redirected programmatically using the function OCML. HLISP also uses GCML to inspect the DCL command line. If this line contains anything, then it is treated as a single line input file. This may be used to invoke an indirect command file, or to simply invoke however much LISP will fit on the command line. The input system also interprets a semicolon (;) in column one of the input record to indicate the record is a comment. This feature is enabled both for compatibility with other LISP implementations and since it is a common convention in input files read by GCML. GCML also provides prompting for input when the input is coming from a terminal. The default prompt for HLISP is "LISP> ". This prompt may be changed using the function PROMPTSTR. There is also a special mechanism for temporary input redirection to initialize or preload functions which may be invoked automatically at the start of a session using HLISP. When HLISP is run, one of the first things it does is check for the presence of the logical name LISP_INIT. If this logical name is defined, HLISP assumes that its value is the name of a file which is to be invoked as an indirect command file. For example, if LISP_INIT is equivalenced to PP, then the contents of the file PP.LSP will be read before HLISP attempts to get input from the standard input file. Note that the use of LISP_INIT disables the ability to specify input on the DCL command line which invokes HLISP. - 13 - HLISP Reference Manual Page 14 FUNCTIONS 21 Aug 84 3.0 FUNCTIONS 3.1 Elementary Predicates Functions in this section return T when the condition defined is met and NIL when it is not. Defined are type checking functions and elementary comparisons. * ATOM(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is not a pair. EXPR PROCEDURE ATOM(U) ; NULL PAIRP U ; * CODEP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a function-pointer. * CONSP(U:any):boolean [non-standard] Type: EVAL, SPREAD Returns T if U is a dotted pair (not an atom). CONSP is a synonym for the function PAIRP, and is provided for compatibility with other LISP implementations. * CONSTANTP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a constant (a number, string, function pointer, or a vector). EXPR PROCEDURE CONSTANTP(U) ; NULL OR(PAIRP U, IDP U) ; * EQ(U:any, V:any):boolean [standard] Type: EVAL, SPREAD Returns T if U points to the same object as V. EQ is NOT a reliable comparison between numeric, string, or vector arguments. * EQN(U:any, V:any):boolean [standard] Type EVAL, SPREAD Returns T if U and V are EQ or if U and V are numbers and have the same value and type. - 14 - HLISP Reference Manual Page 15 FUNCTIONS 21 Aug 84 * EQUAL(U:any, V:any):boolean [standard] Type: EVAL, SPREAD Returns T if U and V are the same. Dotted-pairs are compared recursively to the bottom levels of their trees. Vectors must have identical dimensions and EQUAL values in all positions. Strings must have identical characters. Function pointers must have EQ values. Other atoms must be EQN equal. * FIXP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is an integer (a fixed number). * FLOATP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a floating point number. * IDP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is an id. * MINUSP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a number and less than 0 (zero). If U is not a number or is a positive number, NIL is returned. EXPR PROCEDURE MINUSP(U) ; IF NUMBERP U THEN LESSP(U, 0) ELSE NIL ; * NULL(U:any):boolean [standard] Type: EVAL, SPREAD If U is NIL, return T, else return NIL. This function is a synonym for the function NOT. * NUMBERP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a number (integer or floating). EXPR PROCEDURE NUMBERP(U) ; IF OR(FIXP U, FLOATP U) THEN T ELSE NIL ; - 15 - HLISP Reference Manual Page 16 FUNCTIONS 21 Aug 84 * ONEP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a number and has the value 1 or 1.0. Returns NIL otherwise. EXPR PROCEDURE ONEP(U) ; IF NUMBERP U THEN EQN(U, 1) ELSE NIL ; * PAIRP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a dotted pair (not an atom). * STRINGP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a string. * VECTORP(U:any):boolean [superset] Type: EVAL, SPREAD Returns T if U is a vector or a typed vector. * ZEROP(U:any):boolean [standard] Type: EVAL, SPREAD Returns T if U is a number and has the value 0 or 0.0. Returns NIL otherwise. EXPR PROCEDURE ZEROP(U) ; IF NUMBERP U THEN IF OR(EQN(U, 0), EQN(U 0.0)) THEN T ELSE NIL ; 3.2 Functions On Dotted-Pairs The following are elementary functions on dotted-pairs. All functions in this section which require dotted-pairs as parameters detect a type mismatch error if the actual parameter is not a dotted-pair. * CAR(U:any):any [superset] Type: EVAL, SPREAD CAR(CONS a b) ==> a. If U is a dotted-pair, the left part of U is returned, otherwise NIL. - 16 - HLISP Reference Manual Page 17 FUNCTIONS 21 Aug 84 * CDR(U:any):any [superset] Type: EVAL, SPREAD CAR(CONS a b) ==> b. If U is a dotted-pair, the right part of U is returned. Otherwise, NIL is returned. The composites of CAR and CDR are supported up to four levels [standard], namely: CAAAAR CAAAR CAAR CAAADR CAADR CADR CAADAR CADAR CDAR CAADDR CADDR CDDR CADAAR CDAAR CADADR CDADR CADDAR CDDAR CADDDR CDDDR CDAAAR CDAADR CDADAR CDADDR CDDAAR CDDADR CDDDAR CDDDDR * CONS(U:any, V:any):dotted-pair [standard] Type: EVAL, SPREAD Returns a dotted-pair which is not EQ to anything and has U as its CAR part and V as its CDR part. * LIST([U:any]):list [standard] NOEVAL, NOSPREAD A list of the evaluation of each element of U is returned. * RPLACA(U:dotted-pair, V:any):dotted-pair [standard] Type: EVAL, SPREAD The CAR portion of the dotted-pair is replaced by V. * RPLACD(U:dotted-pair, V:any):dotted-pair [standard] Type: EVAL, SPREAD The CDR portion of the dotted-pair is replaced by V. - 17 - HLISP Reference Manual Page 18 FUNCTIONS 21 Aug 84 3.3 Identifiers The following functions deal with identifiers and the OBLIST, the structure of which is a list of all interned ids. The structure of the OBLIST is implementation dependant, and is subject to change. * ATOMCAR(U:atom):atom [superset] Type: EVAL, SPREAD The first character of the printable representation of U is returned as an atom. * ATOMCDR(U:atom):atom [superset] Type: EVAL, SPREAD All characters except the first character of the printable representation of U are returned as an atom. * ATOMLENGTH(U:atom):integer [superset] Type: EVAL, SPREAD The length of the printable representation of U is returned. * ATOMSTR(U:atom):string [superset] Type: EVAL, SPREAD Returns a string equivalent to the printable representation of U. * COMPRESS(U:id-list):atom [non-standard] Type: EVAL, SPREAD U is a list of identifiers which is built into an identifier and returned. The identifier is interned on the OBLIST. * EXPLODE(U:atom):id-list [standard] Type: EVAL, SPREAD Returned is a list of interned characters representing the characters of the print name of the value of U. Function pointers may not be EXPLODEd [subset]. * GENSYM():id [standard] Creates an identifier which is not interned on the OBLIST and consequently is not EQ to anything. The print name of the atom is Gn, where n is an integer sequence number which is incremented each time GENSYM is called, starting from 1. The new atom - 18 - HLISP Reference Manual Page 19 FUNCTIONS 21 Aug 84 will satisfy IDP, but is not interned on the OBLIST. * IMPLODE(U:id-list):atom [non-standard] Type: EVAL, SPREAD U is a list of identifiers which is built into an identifier and returned. The identifier is interned on the OBLIST. This is a synonym for COMPRESS. * INTERN(U:{id,string}):id [standard] Type: EVAL, SPREAD INTERN searches the OBLIST for an identifier with the same print name as U and returns the identifier on the OBLIST if a match is found. Any properties and values associated with the uninterned U will be lost if U is not EQ to an entry. If U does not match any entry, a new one is created and returned. If U has more than the maximum number of characters permitted an id, and error occurs. * INTERNCD():boolean [superset] Evaluation of this function causes INTERN to compare symbols on the OBLIST in a case dependant manner. * INTERNCI():boolean [superset] Evaluation of this function causes INTERN to compare symbols on the OBLIST in a case independant manner. * MKATOM(U:atom):id [superset] Type: EVAL, SPREAD The atom is converted to a string (if necessary), and then an atom is created with the string as the atom's print name. The new atom will satisfy IDP, but is not interned on the OBLIST. * OBLIST():list [superset] Returns a pointer to the OBLIST. * REMOB(U:id):id [standard] Type: EVAL, SPREAD If U is present on the OBLIST, it is removed. This does not affect U having properties, functions, etc. U is returned. - 19 - HLISP Reference Manual Page 20 FUNCTIONS 21 Aug 84 3.4 Property List Functions With each id in the system is a "property list", a set of entities which are associated with the id for fast access. (Note that property lists are not association lists.) These entities are called "flags" if their use gives the id a single valued property, and "properties" if the id is to ave a multivalued attribute: an indicator with a property. The entire property list may be accessed using the function GETP. Flags and indicators may clash, consequently care should be taken to avoid this occurrence. Flagging X with an id which already is an indicator for X may (in many implementations, though not this one) result in taht indicator and associated property being lost. Likewise, adding an indicator which is the same id as a flag may (again, in many implementations, though not this one) result in the flag being destroyed. In this implementation, an indicator may be sensed as a flag, and vice versa. Similarly, using REMFLAG to remove a flag which is also an indicator will result in the indicator being removed but not its value. In this implementation it is also possible to sense a property's value with FLAGP. These effects result from the fact that a property list is simply a linear list of properties, values, and flags. The property oriented function simply scan the list for an id which matches the indicator, and assume that if a match is found that the next list element is the property's value. Similarly, the flag oriented functions simply scan the list for an id which matches the flag name, and assume that anything that matches is the flag, even if the id was placed there as the value associated with a property. * DEFPROP(U:id, [PROP:any, IND:id]):id [superset] Type: NOEVAL, NOSPREAD PROP is stored on the property list of U as the value of the property IND. There may be any number of PROP and IND pairs greater than one. This function is similar to PUTPROP except the parameters are not evaluated. This function is provided for compatibility with other implementations. See PPPL. * FLAG(U:id-list, V:id):NIL [standard] Type: EVAL, SPREAD U is a list of ids which are flagged with V. The effect of FLAG is that FLAGP will have the value T for those ids of U which were flagged. Both V and all of the elements of U must be ids. - 20 - HLISP Reference Manual Page 21 FUNCTIONS 21 Aug 84 * FLAG1(U:id, V:id):NIL [superset] Type: EVAL, SPREAD U is an id which is flagged with V. The effect of FLAG1 is that FLAGP will have the value T for the id U which was flagged. Both U and V must be ids. * FLAGP(U:any, V:any):boolean [standard] Type: EVAL, SPREAD Returns T if U has been previously flagged with V, else NIL. Returns NIL if either U or V is not an id. * GET(U:any, IND:any):any [standard] Type: EVAL, SPREAD Returns the property associated with the indicator IND from the property list of U. If U does not have an indicator IND, NIL is returned. GET can [non-standard] but should not be used to access functions (use GETD instead). * GETP(U:any):{NIL, dotted-pair} [superset] Type: EVAL, SPREAD If U is an id, then its property list is returned, otherwise NIL is returned. U may be a quoted string literal to prevent interpretation as a READMACRO. * PUT(U:id, IND:id, PROP:any):any [standard] Type: EVAL, SPREAD The indicator IND with the property PROP is placed on the property list of the id U. If the action of PUT occurs, the value of PROP is returned. If either of U and IND are not ids, the type mismatch error will occur and no property will be placed. PUT can [non-standard] but should not be used to defined functions (use PUTD instead). * PUTPROP(U:id, PROP:any, IND:id):id [superset] Type: EVAL, SPREAD PROP is stored on the property list of U as the value of the property IND. This function is similar to PUT except the PROP and IND arguments are reversed. This function is provided for compatibility with other implementations. - 21 - HLISP Reference Manual Page 22 FUNCTIONS 21 Aug 84 * REMFLAG(U:any-list, V:id):NIL [standard] Type: EVAL, SPREAD Removes the flag V from the property list of each member of the list U. Both V and all of the elements of U must be ids. * REMFLAG1(U:id-list, V:id):NIL [superset] Type: EVAL, SPREAD Removes the flag V from the property list of U. Both U and V must be ids. * REMPROP(U:any, IND:any):any [standard] Type: EVAL, SPREAD Removes the property with the indicator IND from the property list of U. Returns the removed property or NIL if there was no such indicator. 3.5 Function Definition Functions are global entities. To avoid function-variable clashes, no variable should have the same name as a function. Functions are presently defined as properties on the property list of an atom. An extension permits parameters to be either SPREAD or NOSPREAD using the same syntax as the extended LAMBDA expression described in the sections "Structures" and "Function Types". * DE(FNAME:id, PARAMS:{id, id-list}, FN:any):id [superset] Type: NOEVAL, NOSPREAD The function FN with the parameter-spec [superset] PARAMS is added to the set of defined functions with the name FNAME. Any previous definitions of the function are lost. The function created is of type EXPR. The semantics of the two forms of the parameter-spec is defined in the section "Function Types," and is the same as for lambda expressions. Compilation using the system variable !*COMP is not supported at this time [subset]. The name of the defined function is returned. FEXPR PROCEDURE DE(U) ; PUTD(CAR U, 'EXPR, LIST('LAMBDA, CADR U, CADDR U)) ; - 22 - HLISP Reference Manual Page 23 FUNCTIONS 21 Aug 84 * DEFINE(FNAME:id, F:lambda):id [superset] Type: NOEVAL, NOSPREAD The function defined by the lambda expression F is added to the set of defined functions with the name FNAME. Any previous definitions of the function are lost. The function created is of type EXPR. Compilation using the system variable !*COMP is not supported at this time. The name of the defined function is returned. FEXPR PROCEDURE DEFINE(U) ; PUTD(CAR U, 'EXPR, CADR U) ; * DF(FNAME:id, PARAMS:{id, id-list}, FN:any):id [superset] Type: NOEVAL, NOSPREAD The function FN with the formal parameter-spec [superset] PARAMS is added to the set of defined functions with the name FNAME. Any previous definitions of the function are lost. The function created is of type FEXPR. If PARAMS is an id-list, between zero and two ids may be supplied; any more will be ignored. The semantics of the two forms of the parameter-spec is defined in the section "Function Types," and is the same as for lambda expressions. Compilation using the system variable !*COMP is not supported at this time [subset]. The name of the defined function is returned. FEXPR PROCEDURE DF(U) ; PUTD(CAR U, 'FEXPR, LIST('LAMBDA, CADR U, CADDR U)) ; * DM(MNAME:id, PARAMS:{id, id-list}, FN:any):id [superset] Type: NOEVAL, NOSPREAD The function FN with the parameter-spec [superset] PARAMS is added to the set of defined functions with the name MNAME. Any previous definitions of the function are lost. The function created is of type MACRO. The semantics of the two forms of the parameter-spec is defined in the section "Function Types," and is the same as for lambda expressions. Compilation using the system variable !*COMP is not supported at this time [subset]. The name of the macro is returned. FEXPR PROCEDURE DM(U) ; PUTD(CAR U, 'MACRO, LIST('LAMBDA, CADR U, CADDR U)) ; - 23 - HLISP Reference Manual Page 24 FUNCTIONS 21 Aug 84 * DRM(MNAME:id, FN:any):id [superset] Type: NOEVAL, NOSPREAD The function FN with no parameters is added to the set of defined functions with the name MNAME. Any previous definitions of the function are lost. The function created is of type READMACRO. MNAME may be a quoted string literal to prevent interpretation as a READMACRO. Compilation using the system variable !*COMP is not supported at this time [subset]. The name of the macro is returned. FEXPR PROCEDURE DRM(U) ; BEGIN PUTD(CAR U, 'FEXPR, LIST('LAMBDA, NIL, CADR U)) ; PUT(CAR U, 'READMACRO, 'READMACRO) ; END ; * GETD(FNAME:any):{NIL, dotted-pair} [standard] Type: EVAL, SPREAD If FNAME is not the name of a defined function, NIL is returned. If FNAME is a defined function the dotted-pair: (TYPE:ftype . DEF:function) is returned. FNAME may be a quoted string literal to prevent interpretation as a READMACRO. * PUTD(FNAME:id, TYPE:ftype, BODY:function):id [standard] Type: EVAL, SPREAD Creates a function with the name FNAME and definition BODY of type TYPE. FNAME may be a quoted string literal to prevent interpretation as a READMACRO. If PUTD succeeds, the name of the defined function is returned. The effect of PUTD is that GETD will return a dotted-pair with the functions type and definition. All scopes are presently implemented as fluid [non-standard]. If the function FNAME already exists, it will be redefined, but no warning message is issued [non-standard]. Compilation of functions using the system variable !*COMP is presently not supported [subset]. * REMD(FNAME:id):{NIL, dotted-pair} [standard] Type: EVAL, SPREAD Removes the function named FNAME from the set of defined functions. FNAME may be a quoted string literal to prevent interpretation as a READMACRO. - 24 - HLISP Reference Manual Page 25 FUNCTIONS 21 Aug 84 Returns the (ftype . function) dotted-pair or NIL as does GETD. 3.6 Variables And Bindings The current implementation supports only fluid bindings for functions defined using the standard input system. Global bindings are unimplemented. Local bindings occur only in compiled and builtin functions. * FLUID(IDLIST:id-list):NIL [not implemented] * FLUIDP(U:any):boolean [not implemented] * GLOBAL(IDLIST:id-list):NIL [not implemented] * GLOBALP(U:any):boolean [not implemented] * SET(EXP:id, VALUE:any):any [subset] Type: EVAL, SPREAD EXP must be an identifier or a type mismatch error occurs. The effect of SET is a replacement of the item bound to the identifier by VALUE. EXP must not evaluate to T or NIL or an error occurs. If there is no binding for the id on the current alist, its APVAL property is changed (or established if it did not already have one). * SETQ([VARIABLE:id, VALUE:any]):any [subset] Type: NOEVAL, NOSPREAD The value of the current binding of VARIABLE is replaced by the result of evaluating VALUE. VARIABLE must not be T or NIL or an error occurs. If there is no binding for the id on the current alist, its APVAL property is changed (or established if it did not already have one). Multiple assignments may be performed by providing multiple variable and value pairs. The value returned by SETQ is the value assigned in the last assignment. MACRO PROCEDURE SETQ(X) ; LIST('SET, LIST('QUOTE, CADR X), CADDR X) ; - 25 - HLISP Reference Manual Page 26 FUNCTIONS 21 Aug 84 * UNFLUID(IDLIST:id-list):NIL [not implemented] 3.7 Program Feature Functions These functions provide for explicit control sequencing, and the definition of blocks altering the scope of local variables. * GO(LABEL:id) [subset] Type: NOEVAL, NOSPREAD GO alters the normal flow of control within a PROG function. The next statement of a PROG function to be evaluated is immediately preceded by LABEL. A GO may only appear in the following situations: 1. At the top level of a PROG referencing a label which also appears at the top level of the same PROG. 2. As the consequent of a COND item of a COND appearing on the top level of a PROG. If LABEL does not appear at the top level of the PROG in which the GO appears, an error occurs. If the GO has been placed in a position not defined in the rules above, an error occurs. * LET(INIT:list, [FORM:any]):any [superset] Type: NOEVAL, NOSPREAD LET is a builtin macro (really an FSUBR) that translates its input arguments into a lambda expression and then evaluates it. INIT is a list of pairs of ids and initial values which specifies the formal parameters of the lambda expression and their initial values. The FORMs become the body of the lambda expression. In other words, the general form: (LET , ( ...) , , , ... ,,,) is converted into the following general form: ( , (LAMBDA - 26 - HLISP Reference Manual Page 27 FUNCTIONS 21 Aug 84 , , ( ...) , , , , , , ... , ,,,) , , , ... ,,,) , ... are atoms which become local variables, initialized by the results of evaluating the S-expressions , ... Using these local definitions, the forms , ... are evaluated. * LOOP(INIT:list, [ACT:list]):any [superset] Type: NOEVAL, NOSPREAD LOOP is an FSUBR that provides a convenient syntax for PROG-like iteration. INIT is a special list which provides for definition and initialization of local variables. The ACTs provide the actions performed during the iteration, testing for loop termination, and providing a resulting value for the LOOP form. The form of INIT is as follows: (INITIAL ...) where each is an id which becomes a local variable in the pseudo-PROG form constructed from the ACTs, and each is initialized to the value resulting from EVALuation of the corresponding S-expression . The form of each ACT is as follows: ( ...) where each is an S-expression, and the identifies the semantics of the clause, as follows: - 27 - HLISP Reference Manual Page 28 FUNCTIONS 21 Aug 84 = DO Each is evaluated in sequence = WHILE Each is evaluated until one evaluates to NIL, at that point the LOOP iteration is terminated = UNTIL Each is evaluated until one evaluates to some non-NIL value, at that point the LOOP iteration is terminated These ACTs are evaluated sequentially, then the entire sequence is repeated until either a WHILE or UNTIL clause causes the iteration to be terminated. The different types of s may appear in any order, and there may be as many of each type as desired. There is one additional type of ACT which may appear anywhere within the loop, but is not evaluated until the loop terminates: = RESULT There must be exactly one , which is EVALuated to obtain the value returned by the LOOP function. If no RESULT clause appears, the LOOP form returns NIL. Note that a future implementation might restrict the appearance of the RESULT action clause to the end of the loop. Example (LOOP , (INITIAL N 1 SUM 0) , (DO , , (SETQ SUM (PLUS SUM N)) , , (SETQ N (ADD1 N)) , ,,,) , (UNTIL (GREATERP N 5)) , (RESULT SUM) ,,,) When this form is evaluated, the result is 15. - 28 - HLISP Reference Manual Page 29 FUNCTIONS 21 Aug 84 * PROG(VARS:id-list, [PROGRAM:{id, any}]):any [standard] Type: NOEVAL, NOSPREAD VARS is a list of ids which are considered fluid. The PROG's variables are allocated space when the PROG form is invoked and are deallocated when the PROG is exited. PROG variables are initialized to NIL. The PROGRAM is a set of S-expressions to be evaluated in order of their appearance in the PROG function. Ids appearing in the top level of the PROGRAM are labels which can be referenced by GOs. The value returned by the PROG function is determined by a RETURN function, or NIL if the PROG "falls through." * PROGN([U:any]):any [standard] Type: NOEVAL, NOSPREAD U is a set of S-expressions which are evaluated sequentially. The value returned is the value of the last S-expression. * PROG1([U:any]):any [superset] Type: EVAL, NOSPREAD U is a set of S-expressions which are evaluated sequentially. The value returned is the value of the first S-expression. * PROG2([U:any]):any [superset] Type: EVAL, NOSPREAD U is a set of S-expressions which are evaluated sequentially. The value returned is the value of the second S-expression. If there is only one S-expression, its value is returned. If there are no S-expressions, NIL is returned. * REPEAT([U:any]):any [superset] Type: NOEVAL, NOSPREAD Repeatedly evaluate each of the U's until a termination test succeeds. A termination test is indicated by the presence of one of the atoms UNTIL or WHILE followed by an S-expression. The S-expression following UNTIL or WHILE is evaluated, and the termination test succeeds if the result is non-null for UNTIL or null for WHILE. The value returned is the result of the S-expression terminating the iteration. - 29 - HLISP Reference Manual Page 30 FUNCTIONS 21 Aug 84 Example (PROG (N SUM) , (SETQ N 1) , (SETQ SUM 0) , (REPEAT , , (SETQ SUM (PLUS SUM N)) , , (SETQ N (ADD1 N)) , , UNTIL (GREATERP N 5) , ,,,) , (RETURN SUM) ,,,) When this form is evaluated, the result is 15. * RETURN(U:any) [standard] Type: EVAL, SPREAD Within a PROG, RETURN terminates the evaluation of a PROG and returns U as the value of the PROG. The restrictions on the placement of RETURN are exactly those of GO. Improper placement of RETURN results in an error. RETURN may also be entered as input to the READ-EVAL-PRINT loop of BREAK, to terminate the BREAK and provide the value to be returned by BREAK [superset]. (Note that RETURN terminates a PROG function, not a defined function.) 3.8 Error Handling * ERROR(MESSAGE:string, [EXP:any]) [non-standard] Type: EVAL, SPREAD MESSAGE becomes the text of an error message which terminates execution of all functions and returns control to the top level READ-EVAL-PRINT loop. EXP is an optional S-expression which, if present, is printed with the message to indicate the context of the error. If EXP is omitted, the ERROR expression itself is printed. * ERRORSET(U:any, MSGP:boolean, TR:boolean):any [not implemented] - 30 - HLISP Reference Manual Page 31 FUNCTIONS 21 Aug 84 3.9 Vectors Vectors are structured entities in which random elements may be accessed with an integer index. A vector has a single dimension. Its maximum size is determined by the available address space, which is system dependant. Vector I/O is not supported at this time. The vector I/O syntax recommended in the Report will not be used (if and) when vector I/O is implemented because the syntax conflicts with "superbrackets" (see the section "Input and Output"). Each vector allocates one node from the node pool; the vector storage is dynamically allocated external to the node pool. * GETV(V:vector, INDEX:integer):any [standard] Type: EVAL, SPREAD Returns the value stored at position INDEX of the vector V. An error will occur if V is not a vector or INDEX is not an integer. An error will occur if INDEX does not lie in the range 0..UPBV(V), inclusive. * MKVECT(UPLIM:integer, [TYPE:{FIXNUM, FLTNUM}]):vector [superset] Type: EVAL, SPREAD Defines and allocates space for a vector with UPLIM+1 elements accessed as 0..UPLIM. If TYPE is omitted, the elements are untyped. If TYPE is present, the vector is a typed vector, and TYPE must be either (the value of) FIXNUM or FLTNUM. FIXNUM indicates that the vector must be all integers. FLTNUM indicates that the vector must be all floating point numbers. Each element is initialized to NIL if the vector is untyped, or 0 (or 0.0, as appropriate) if the vector is typed. An error occurs if UPLIM is either less than or equal to zero, or if there is insufficient virtual address space to allocate the vector. * PUTV(V:vector, INDEX:integer, VALUE:any):any [standard] Type: EVAL, SPREAD Stores VALUE into the vector V at position INDEX. If V is a typed vector, VALUE must be of the correct type or an error will result. If INDEX does not lie in the range 0..UPBV(V) an error will occur. * UPBV(U:any):{NIL, integer} [standard] Type: EVAL, SPREAD Returns the upper limit of U if U is a vector, or NIL if it is not. - 31 - HLISP Reference Manual Page 32 FUNCTIONS 21 Aug 84 3.10 Boolean Functions And Conditionals * AND([U:any]):extra-boolean [standard] Type: NOEVAL, NOSPREAD AND evaluates each U until a value of NIL is found or the end of the list is encountered. If a non-NIL value is the last value, it is returned, else NIL is returned. FEXPR PROCEDURE AND(U) ; BEGIN IF NULL U THEN RETURN T ; LOOP: IF NULL CDR U THEN RETURN EVAL CAR U ELSE IF NULL EVAL CAR U THEN RETURN NIL ; U := CDR U ; GO LOOP END ; * COND([U:cond-form]):any [standard] Type: NOEVAL, NOSPREAD The antecedents of all U's are evaluated in order of their appearance until a non-NIL value is encountered. The consequent of the selected U is evaluated and becomes the value of the COND. The consequent may contain the special functions GO and RETURN, subject to the constraints given for these functions in the section "Program Feature Functions." In these cases, COND does not have a defined value, but rather an effect. If no antecedent is non-NIL, the value of the COND is NIL. An error is detected if U is improperly formed. * NOT(U:any):boolean [standard] Type: EVAL, SPREAD If U is NIL, return T, else return NIL. This function is a synonym for the function NULL. EXPR PROCEDURE NOT(U) ; U EQ NIL ; * OR([U:any]):extra-boolean [standard] Type: NOEVAL, NOSPREAD U is any number of expression which are evaluated in order of their appearance. When one of the expressions is found to be non-NIL, it is returned as the value of the OR. If all are NIL, NIL is returned. - 32 - HLISP Reference Manual Page 33 FUNCTIONS 21 Aug 84 FEXPR PROCEDURE OR(U) ; BEGIN SCALAR X ; LOOP: IF NULL U THEN RETURN NIL ELSE IF (X := EVAL CAR U) THEN RETURN X ; U := CDR U ; GO LOOP END ; 3.11 Arithmetic Functions Conversion between numeric types are provided explicitly by the FIX and FLOAT functions and implicitly by any multi-parameter arithmetic function which receives mixed types of arguments. A conversion from fixed to floating point numbers may result in a loss of precision without a warning message being generated. Precision of integers is not unlimited as specified in the Report [subset], since they are stored as 32 bit binary numbers. If a function receives mixed types of arguments, the general rule will have the integers converted to floating point before the arithmetic operations are performed. In all cases an error occurs if the parameter to an arithmetic function is not a number. * ABS(U:number):number [standard] Type: EVAL, SPREAD Returns the absolute value of its argument. * ADD1(U:number):number [standard] Type: EVAL, SPREAD Returns the value of U plus 1 of the same type as U (fixed or floating). * DIFFERENCE(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the difference U-V. * DIVIDE(U:number, V:number):dotted-pair [standard] Type: EVAL, SPREAD The dotted pair (quotient . remainder is returned. The quotient part is computed the same as by QUOTIENT and the remainder the same as by REMAINDER. An error occurs if division by zero is attempted. EXPR PROCEDURE DIVIDE(U, V) ; (QUOTIENT(U, V) . REMAINDER(U, V)) ; - 33 - HLISP Reference Manual Page 34 FUNCTIONS 21 Aug 84 * EXPT(U:number, V:integer):number [standard] Type: EVAL, SPREAD Returns U raised to the V power. A floating point U to an integer power V does not have V changed to a floating number before exponentiation. * FIX(U:number):integer [standard] Type: EVAL, SPREAD Returns an integer which corresponds to the truncated value of U. If U is an integer, it is returned unchanged. * FLOAT(U:number):floating [standard] Type: EVAL, SPREAD The floating point number corresponding to the value of the argument U is returned. If U is a floating point number, it is returned unchanged. * GREATERP(U:number, V:number):boolean [standard] Type: EVAL, SPREAD Returns T if U is strictly greater than V, otherwise NIL. * LESSP(U:number, V:number):boolean [standard] Type: EVAL, SPREAD Returns T if U is strictly less than V, otherwise NIL. * LOGAND([V:integer]):integer [superset] Type: EVAL, NOSPREAD Each of the arguments is bitwise anded together, and the result is returned. * LOGOR([V:integer]):integer [superset] Type: EVAL, NOSPREAD Each of the arguments is bitwise ored together, and the result is returned. * MAX([U:number]):number [standard] Type: EVAL, NOSPREAD Returns the largest of the values in U. If two or more values are the same, the first is returned. - 34 - HLISP Reference Manual Page 35 FUNCTIONS 21 Aug 84 * MAX2(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the larger of U and V. If either argument is floating point, the result is floating point [non-standard]. * MIN([U:number]):number [standard] Type: EVAL, NOSPREAD Returns the smallest of the values in U. If two or more values are the same, the first is returned. * MIN2(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the smaller of its arguments. If either argument is floating point, the result is floating point [non-standard]. * MINUS(U:number):number [standard] Type: EVAL, SPREAD Returns -U. EXPR PROCEDURE MINUS(U) ; DIFFERENCE(0, U) ; * PLUS([U:number]):number [standard] Type: EVAL, NOSPREAD Returns the sum of all its arguments. * PLUS2(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the sum of U and V. * QUOTIENT(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the quotient U divided by V. * REMAINDER(U:number, V:number):number [standard] Type: EVAL, SPREAD If both U and V are integers, the result is the integer remainder of U divided by V. If either arguement is floating point, the result is the difference between U and V*(U/V), all in floating point. If either U or V are negative (but not both of them), then the result is negative. If both U and V are positive or both are negative, then the result is positive. An error occurs if V is zero. - 35 - HLISP Reference Manual Page 36 FUNCTIONS 21 Aug 84 * SQRT(U:number):float [superset] Type: EVAL, SPREAD Returns the square root of U. * SUB1(U:number):number [standard] Type: EVAL, SPREAD Returns the value of U minus 1. * TIMES([U:number]):number [standard] Type: EVAL, NOSPREAD Returns the product of all its arguments. * TIMES2(U:number, V:number):number [standard] Type: EVAL, SPREAD Returns the product of U and V. 3.12 MAP Composite Functions * MAP(X:list, FN:function):any [standard] Type: EVAL, SPREAD Applies FN to successive CDR segments of X. NIL is returned. EXPR PROCEDURE MAP(X, FN) ; WHILE X DO << FN X ; X := CDR X >> ; * MAPC(X:list, FN:function):any [standard] Type: EVAL, SPREAD Applies FN to successive CAR segments of X. NIL is returned. EXPR PROCEDURE MAPC(X, FN) ; WHILE X DO << FN CAR X ; X := CDR X >> ; * MAPCAN(X:list, FN:function):any [standard] Type: EVAL, SPREAD A concatenated list of FN applied to successive CAR elements of X is returned. EXPR PROCEDURE MAPCAN(X, FN) ; IF NULL X THEN NIL ELSE NCONC(FN CAR X, MAPCAN(CDR X, FN)) ; - 36 - HLISP Reference Manual Page 37 FUNCTIONS 21 Aug 84 * MAPCAR(X:list, FN:function):any [standard] Type: EVAL, SPREAD Returned is a constructed list of FN applied to each CAR of list X. EXPR PROCEDURE MAPCAR(X, FN) ; IF NULL X THEN NIL ELSE FN CAR X . MAPCAR(CDR X, FN) ; * MAPCON(X:list, FN:function):any [standard] Type: EVAL, SPREAD Returned is a concatenated list of FN applied to successive CDR segments of list X. EXPR PROCEDURE MAPCON(X, FN) ; IF NULL X THEN NIL ELSE NCONC(FN X, MAPCON(CDR X, FN)) ; * MAPLIST(X:list, FN:function):any [standard] Type: EVAL, SPREAD Returns a constructed list of FN applied to successive CDR segments of list X. EXPR PROCEDURE MAPLIST(X, FN) ; IF NULL X THEN NIL ELSE FN X . MAPLIST(CDR X, FN) ; 3.13 Composite Functions * APPEND([U:list]):list [superset] Type: EVAL, NOSPREAD Returns a constructed list in which each succesive argument is appended to a copy of the prior argument. Note that the last U is not copied. See also APPEND2. * APPEND1(U:list, V:any):list [superset] Type: EVAL, SPREAD Returns a constructed list in which V has been added as the last member of a copy of the list U. EXPR PROCEDURE APPEND1(U, V) ; APPEND2(U, LIST(V)) ; - 37 - HLISP Reference Manual Page 38 FUNCTIONS 21 Aug 84 * APPEND2(U:list, V:any):list [superset] Type: EVAL, SPREAD Returns a constructed list in which the last element of U is followed by the first element of V. The list U is copied, V is not. [Note that this function is equivalent to the standard APPEND as specified in the Report, and is equivalent to this implementations APPEND when there are only two arguments.] EXPR PROCEDURE APPEND2(U, V) ; IF NULL U THEN V ELSE CAR U . APPEND2(CDR U, V) ; * ASSOC(U:any, V:alist):{dotted-pair, NIL} [standard] Type: EVAL, SPREAD If U occurs as the CAR portion of an element of the alist V, the dotted-pair in which U occurred is returned, else NIL is returned. ASSOC might not detect a poorly formed alist so an invlaid construction may be detected by CAR or CDR. EXPR PROCEDURE ASSOC(U, V) ; IF NULL V THEN NIL ELSE IF ATOM CAR V THEN ERROR("Poorly formed alist") ELSE IF U = CAAR V THEN CAR V ELSE ASSOC(U, CDR V) ; * COPY(U:any):any [superset] Type: EVAL, SPREAD Returns a copy of U. Cyclic structures are not handled properly. EXPR PROCEDURE COPY(U) ; IF ATOM U THEN U ELSE COPY CAR U . COPY CDR U ; * DEFLIST(U:dlist, IND:id):list [not implemented] * DELETE(U:any, V:list):list [standard] Type: EVAL, SPREAD Returns V with the first top level occurrence of U removed from it. EXPR PROCEDURE DELETE(U, V) ; IF NULL V THEN NIL ELSE IF CAR V = U THEN CDR V ELSE CAR V . DELETE(U, CDR V) ; - 38 - HLISP Reference Manual Page 39 FUNCTIONS 21 Aug 84 * DIGIT(U:any):boolean [not implemented] * ELEMENT(U:integer, V:list):any [superset] Type: EVAL, SPREAD Return element number U from the list V. The first element is indicated by one (1). * LAST(U:list):list [superset] Type: EVAL, SPREAD Returns a list containing only the last element of U. * LENGTH(X:any):integer [standard] Type: EVAL, SPREAD The top level length of the list X is returned. EXPR PROCEDURE LENGTH(X) ; IF ATOM X THEN 0 ELSE PLUS(1, LENGTH CDR X) ; * LITER(U:any):boolean [not implemented] * MEMBER(A:any, B:list):extra-boolean [standard] Type: EVAL, SPREAD Returns NIL if A is not a member of the list B, returns the mreainder of B whose first element is A. EXPR PROCEDURE MEMBER(A, B) ; IF NULL B THEN NIL ELSE IF A = CAR B THEN B ELSE MEMBER(A, CDR B) ; * MEMQ(A:any, B:list):extra-boolean [standard] Type: EVAL, SPREAD Same as MEMBER except than an EQ check is used for comparison. EXPR PROCEDURE MEMQ(A, B) ; IF NULL B THEN NIL ELSE IF A EQ CAR B THEN B ELSE MEMQ(A, CDR B) ; - 39 - HLISP Reference Manual Page 40 FUNCTIONS 21 Aug 84 * NCONC(U:list, V:list):list [standard] Type: EVAL, SPREAD Concatenates V to U without copying U. The last CDR of U is modified to point to V. EXPR PROCEDURE NCONC(U, V) ; BEGIN SCALAR W ; IF NULL U THEN RETURN V ; W := U ; WHILE CDR W DO W := CDR W ; RPLACD(W, V) ; RETURN U END ; * PAIR(U:list, V:list):alist [not implemented] * POP(U:id):any [superset] Type: NOEVAL, NOSPREAD POP requires its argument U to be an id which points to a list. POP removes the first element from this list (as if it were a stack), returns this value, and modifies U to point to the remainder of the list. * PUSH(U:any, V:id):any [superset] Type: NOEVAL, NOSPREAD PUSH requires its argument V to be an id which points to a list. PUSH evaluates its argument U and then adds its value to the beginning of the list pointed to by V. It then modifies V to point to the new first element, and returns this new value of V. * REVERSE(U:list):list [standard] Type: EVAL, SPREAD Returns a copy of the top level of U in reverse order..LT EXPR PROCEDURE REVERSE(U) ; BEGIN SCALAR W ; WHILE U DO << W := CAR U . W ; U := CDR U >> ; RETURN W END ; - 40 - HLISP Reference Manual Page 41 FUNCTIONS 21 Aug 84 * SASSOC(U:any, V:list, FN:function):any [standard] Type: EVAL, SPREAD If U occurs as the CAR portion of an element of the alist V, the dotted-pair in which U occurred is returned. If U is not in the alist, the evaluation of the function FN is returned. SASSOC might not detect a poorly formed alist so an invlaid construction may be detected by CAR or CDR. EXPR PROCEDURE SASSOC(U, V, FN) ; IF NULL V THEN FN() ELSE IF ATOM CAR V THEN ERROR("Poorly formed alist") ELSE IF U = CAAR V THEN CAR V ELSE SASSOC(U, CDR V, FN) ; * SUBLIS(X:alist, Y:any):any [not implemented] * SUBST(U:any, V:any, W:any):any [standard] Type: EVAL, SPREAD The value returned is the result of substituting U for all occurrences of V in W. EXPR PROCEDURE SUBST(U, V, W) ; IF NULL W THEN NIL ELSE IF V = W THEN U ELSE IF ATOM W THEN W ELSE SUBST(U, V, CAR W) . SUBST(U, V, CDR W) ; 3.14 The Interpreter Execution tracing and other debugging aids are provided (see the section "System Related Functions" and the description of TRACEBUG in the section "System Variables, Constants, and Symbols") as an imbedded feature of the HLISP interpreter. The details of how these debugging features are implemented is not shown in the descriptions in this section. The details of the various mechanisms for parameter passing are also not shown in these descriptions. The HLISP interpreter also contains a special condition handler which permits the user to interrupt execution at any time by typing control-C. When garbage collection is in progress (invoked either automatically or programmatically using RECLAIM), the control-C interrupt will be temporarily disabled so that the node pool will not be corrupted. - 41 - HLISP Reference Manual Page 42 FUNCTIONS 21 Aug 84 * APPLY(FN:{id, function, funarg}, ARGS:any-list, [AL:alist]):any [superset] Type: EVAL, SPREAD Apply the function FN to the argument list ARGS. The optional alist AL provides an alternate environment of associations. At this time, the ability to use zero, one, or two formal parameters in FEXPR parameter-specs (see DF) interferes with the proper detection in APPLY of too many arguments passed to a function. EXPR PROCEDURE APPLY(FN, ARGS, [AL]) ; BEGIN SCALAR DEFN ; IF NULL AL THEN AL := { current alist } ; IF NULL FN THEN RETURN NIL ; IF ATOM FN THEN BEGIN IF NOT NULL (DEFN := GETD FN) THEN BEGIN IF CAR DEFN = 'EXPR THEN RETURN APPLY (CDR DEFN, ARGS, AL) ; IF CAR DEFN = 'SUBR THEN RETURN { Invoke CDR DEFN directly, passing ARGS as the argument list, and return the value returned by the function. } ; IF CAR DEFN = 'FSUBR OR CAR DEFN = 'FEXPR OR CAR DEFN = 'LSUBR THEN RETURN { Invoke CDR DEFN directly, passing LIST(ARGS, AL) as the argument list, and return the value returned by the function. } ; END ELSE IF NOT NULL (DEFN := ASSOC(FN, AL) THEN RETURN APPLY(CDR DEFN, ARGS, AL) ; ERROR ("Unable to find binding for the function.") END ELSE % non-atomic function FN IF CAR FN = 'LAMBDA THEN RETURN { Bind the actual parameters in ARGS to the formal parameters of the lambda expression. If the two lists are not of equal length then ERROR("Number of parameters do not match"); The value returned is EVAL(CADDR FN, AL). } ELSE IF CAR FN = 'FUNARG THEN RETURN APPLY(CADR FN, ARGS, CADDR FN) ELSE RETURN APPLY(EVAL(FN, AL), ARGS, AL) ; END ; - 42 - HLISP Reference Manual Page 43 FUNCTIONS 21 Aug 84 * ARG(U:integer):any [superset] Type: EVAL, SPREAD This function retrieves arguments by number for lambda expressions of type EVAL, NOSPREAD indicated by a single id in the place of a parameter-spec in the lambda expression. The first argument is numbered one (1). See the section "Function Types." * EVAL(U:any, [AL:alist]):any [superset] Type: EVAL, SPREAD Evaluate the S-expression U. The optional alist AL provides an alternate environment of associations. Note that the argument AL is ignored by EVAL when U is a funarg. Note also that if there is no dynamic binding for an atom on the current alist, then EVAL will attempt to obtain a static binding by checking for an APVAL property on the atom's property list. EXPR PROCEDURE EVAL(U, [AL]) ; BEGIN SCALAR FN, TEMP ; IF NULL AL THEN AL := { current alist } ; IF ATOM U THEN BEGIN IF CONSTANTP U THE RETURN U ; TEMP := ASSOC(U, AL) ; IF NOT NULL TEMP THEN RETURN CDR TEMP ELSE IF NOT NULL (TEMP := GET(U, 'APVAL)) THEN RETURN TEMP ELSE ERROR("Unable to find binding for atom") END ELSE BEGIN % U is not atomic TEMP := CAR U ; IF ATOM TEMP THEN BEGIN IF TEMP = 'QUOTE THEN RETURN CADR U ; IF TEMP = 'FUNCTION THEN RETURN LIST('FUNARG, CADR U, AL) ; IF TEMP = 'COND THEN RETURN { evaluate the cond form } ; FN := GETD TEMP ; IF NULL FN THEN FN := ASSOC(CAR U, AL) ; IF NULL FN THEN ERROR("Unable to find binding for function") ; IF CAR FN = 'EXPR THEN RETURN APPLY(CDR FN, EVLIS CDR U, AL) ; IF CAR FN EQ 'FEXPR THEN RETURN APPLY(CDR FN, LIST CDR U, AL) ; IF CAR FN EQ 'FSUBR THEN RETURN { invoke CDR FN directly, passing LIST(CDR U, AL) as the argument list, and return the value returned by the function } ; IF CAR FN EQ 'MACRO THEN RETURN EVAL APPLY(CDR FN, LIST U, AL) ; - 43 - HLISP Reference Manual Page 44 FUNCTIONS 21 Aug 84 IF CAR FN EQ 'SUBR THEN RETURN { invoke CDR FN directly, passing EVLIS CDR U as the argument list, and return the value returned by the function } ; IF CAR FN EQ 'LSUBR THEN RETURN { invoke CDR FN directly, passing LIST(EVLIS CDR U, AL) as the argument list, and return the value returned by the function } ; ERROR("Unable to find binding for function") ; END ELSE % CAR U is not atomic RETURN APPLY(CAR U, EVLIS CDR U, AL) ; END ; END ; * EVLIS(U:any-list):any-list [standard] Type: EVAL, SPREAD EVLIS returns a list of the evaluation of each element of U. EXPR PROCEDURE EVLIS(U) ; IF NULL U THEN NIL ELSE EVAL CAR U . EVLIS CDR U ; * EXPAND(L:list, FN:function):list [not implemented] * FUNCALL(FN:function, [V:any]):any [superset] Type: EVAL, NOSPREAD Evaluate the function specified by FN, passing any arguments specified by V. The result of the evaluation is returned. * FUNCTION(FN:function):function [superset] Type: NOEVAL, NOSPREAD This function suppresses evaluation of its argument in a manner similar to QUOTE. It is used when the function FN is to be passed to another function. When FUNCTION is encountered by EVAL, it generates a funarg to bind the current environment with the function so APPLY will apply the function using the current environment. * QUOTE(U:any):any [standard] Type: NOEVAL, NOSPREAD Stops evaluation and returns U unevaluated. The single quote character (') may be used as a prefix operator to quote the following S-expression. - 44 - HLISP Reference Manual Page 45 FUNCTIONS 21 Aug 84 FEXPR PROCEDURE QUOTE(U) ; CAR U ; 3.15 Input And Output The user normally communicates with LISP through "standard devices." The standard output device is SYS$OUTPUT and the standard input is SYS$INPUT, in accordance with VMS standards. In addition, the standard input device supports indirect command files, using an enhanced version of the routine GCML. (See the sections "Input Syntax" and "Input Redirection Using GCML.") (See also the discussion at the beginning of the section "The Interpreter" regarding the use of control-C.) * BREAK(U:any):any [superset] Type: EVAL, SPREAD BREAK is intended as a debugging tool. When called, TERPRI is evaluated, and a message is printed indicating that BREAK has been entered, followed by the value resulting from evaluation of U. Subsequently, all input is EVAL'd and PRINT'd, until a RETURN function is entered. At this point, the argument to the RETURN function is evaluated and is returned as the value of the BREAK expression. A message is also printed to indicate that BREAK mode has been exited. All input while using BREAK is forced to come from DBG$INPUT, as a nested command file, which is automatically exited when BREAK mode is exited. The result is that input that has been redirected via a nested indirect command file is not messed up by the presence of BREAK debugging expressions. Note that output is not redirected automatically, since the user can accomplish this using the function OUTPUT. * CLOSE(FILEHANDLE:any):any [not implemented] * CLOSELOG():NIL [superset] Turns off input/output logging initiated by the LOGIO function. * EJECT():NIL [not implemented] - 45 - HLISP Reference Manual Page 46 FUNCTIONS 21 Aug 84 * HELP([U:any]):NIL [superset] Type: NOEVAL, NOSPREAD Invokes the interactive help facility. If an argument is supplied, it is converted to a string (if necessary) and used as the initial key for searching for help in the help library. The help facility is identical to standard VMS interactive help. No more than a single argument is currently used. * LEX(CHAR:{id, string, integer}, [CLASS:integer]):{id, NIL} [superset] Type: EVAL, SPREAD Return and optionally establish a new character class for the character indicated by CHAR. If CLASS is specified, it is the new character class for CHAR, and the previous character class of CHAR is returned. CHAR may be a character string, of which only the first character is used, an atom, in which case the first character of the print name is used, or a number, in which case the number indicates the ASCII code of the character whose class is to be manipulated. The character class for the ASCII NUL character (ASCII code zero) may not be changed. CLASS is a number, for which symbolic values have been established (see the sections "System Variables, Constants, and Symbols", "Input and Output", and "Configurable Lexical Analyzer"). If an invalid class is specified, the value NIL is returned, and the class of the character is not changed. The value returned by LEX will be either an id, symbolically indicating the class of CHAR or NIL indicating an error in invoking LEX. * LINELENGTH(LEN:{integer, NIL}):integer [standard] Type: EVAL, SPREAD If LEN is an integer, the maximum line length to be printed before the print functions initiate an automatic TERPRI is set to the value of LEN. The default length is 80 characters. The previous line length is returned. When LEN is NIL, the current line length is returned but it is not reset to a new value. An error occurs if the requested line length is negative or zero. - 46 - HLISP Reference Manual Page 47 FUNCTIONS 21 Aug 84 * LOGIO(FILESPEC:{id, string}):NIL [superset] Type: EVAL, SPREAD Direct the LISP input/output system to create an output file into which all normal LISP input and output will be copied. The name of the file is indicated by FILESPEC. If FILESPEC evaluates to an atomic symbol, its print-name is used. If FILESPEC evaluates to a string, its value is used. Input lines are logged as-is. Output lines are logged with a semicolon character in column one. This permits the logfile to be read as an indirect command file to exactly reproduce the results of the session creating the logfile since a semicolon in column one causes the lines to be ignored by the input system completely (they are not even logged). Logging may be terminated by invoking CLOSELOG. The default file type is ".LOG". * LPOSN():integer [not implemented] * MSG([U:any]):NIL [superset] Type: EVAL, NOSPREAD MSG is a general output utility function. It takes an arbitrary number of arguments and treats them in the following way: - Explicit strings are printed without the string quotes. - The atom T causes a new line to be started (invokes TERPRI). - Other expressions are EVALuated and the result is printed. * OCML(FILESPEC:string):NIL [superset] Type: EVAL, SPREAD Evaluation of this function causes the next input function requiring an additional line of input to obtain it by opening the file specificied by FILESPEC as a nested indirect command file. Subsequent input continues to come from this file until the end of the file is reached, at which point the input system returns to the previous level. The default file extension is ".LSP". This function is implemented using the OCML entry point to the (more or less) standard library routine GCML. Input may be directed to the user's terminal by specifying the string "TT:". The initial input file is SYS$INPUT. - 47 - HLISP Reference Manual Page 48 FUNCTIONS 21 Aug 84 * OPEN(FILE:any, HOW:id):any [not implemented] * OUTF(FILESPEC:{id, string}, [S:any]):NIL [superset] Type: NOEVAL, NOSPREAD Redirects output to the file FILESPEC, then evaluates each S sequentially. When all arguments have been evaluated, output is reset to the file it was directed to before OUTF was invoked. If S is identically EQ to T (before evaluation), OUTF will invoke TERPRI. OUTF is builtin but not compiled. * OUTPUT(FILESPEC:{id, string}):string [superset] Type: EVAL, SPREAD Evaluation of this function causes all LISP output to be directed to the file specified by FILESPEC. If FILESPEC evaluates to an atomic symbol, its print-name is used. If FILESPEC evaluates to a string, its value is used. The returned string is the filespec of the previous output file. The default file extension is ".LIS". Initially, the output device is SYS$OUTPUT. Output may be directed to the terminal by specifying the string "TT:". * PAGELENGTH(LEN:{integer, NIL}):integer [not implemented] * POSN():integer [standard] Returns the number of characters in the output buffer. * PP(U:any):NIL [superset] Type: EVAL, SPREAD Pretty print U to the current output file. PP is builtin but not compiled. * PPAUX(U:any, START:number, LPCOUNT:number, NEWLINE:extra-boolean):NIL [superset] Type: EVAL, SPREAD PPAUX is the workhorse of the builtin pretty printing functions. It performs the actual pretty printing of U to the current output file. START indicates the character position where the first character is to appear on the output line. If START is to the left of the current position on the output line, a new line is started by evaluating TERPRI. LPCOUNT is the initial left parenthesis count, which is used to determine whether the S-expression currently being pretty printed will fit on a given - 48 - HLISP Reference Manual Page 49 FUNCTIONS 21 Aug 84 line, including the right parentheses required to complete the S-expression. Normally, LPCOUNT should be specified as zero when being called by any other routine; it is used primarily for when PPAUX calls itself recursively. If NEWLINE is non-NIL, PPAUX will force output to start on a new output line. PPAUX is builtin but not compiled. * PPAUX2(U:any):any [superset] Type: EVAL, SPREAD PPAUX2 works in conjunction with PPAUX to pretty print S-expressions. It is responsible for formatting quoted expressions. * PPD(FN:id):NIL [superset] Type: NOEVAL, NOSPREAD Pretty print the definition of the function of FN to the current output file. If FN is a compiled function, an error will result. The output is in a form suitable for input to LISP to define the function. PPD is builtin but not compiled. * PPI(U:any, START:number):NIL [superset] Type: EVAL, SPREAD Pretty print U, indented, to the current output file. START indicates the character position where the first character is to appear on the output line. If START is to the left of the current position on the output line, a new line is started by evaluating TERPRI. PPI is builtin but not compiled. * PPINT(U:any, START:number):NIL [superset] Type: EVAL, SPREAD Pretty print U, indented, to the current output file, with no final invocation of TERPRI. START indicates the character position where the first character is to appear on the output line. If START is to the left of the current position on the output line, a new line is started by evaluating TERPRI. PPINT is identical to PPI, except that PPI invokes TERPRI before terminating. PPINT is builtin but not compiled. * PPP(ID:id):NIL [superset] Type: NOEVAL, NOSPREAD Pretty print the property list of ID to the current output file. PPP is builtin but not compiled. - 49 - HLISP Reference Manual Page 50 FUNCTIONS 21 Aug 84 * PPPL(NAME:id):NIL [superset] Type: NOEVAL, NOSPREAD Pretty print the property list of NAME to the current output file. The output is in the form of a DEFPROP function call suitable for recreating the property list of NAME. PPPL is builtin but not compiled. * PRINC(U:id):id [not implemented] * PRINT(U:any):any [standard] Type: EVAL, SPREAD Displays U in READ readable format using PRIN1 and terminates the print line. The value of U is returned. The HLISP I/O system is not capable of handling vectors in the current implementation. If U is a vector, the special symbol !*!* is printed. * PRIN1(U:any):any [standard] Type: EVAL, SPREAD Displays U in READ readable format. The format of the display is the result of EXPLODE expansion; strings are enclosed in double quote characters "...", lists are displayed in list notation. Special characters are not prefixed with the escape character ! as in the standard implementation described in the Report because of the enhanced lexical capablilities of HLISP. The value of U is returned. The HLISP I/O system is not capable of handling vectors in the current implementation. If U is a vector, the special symbol !*!* is printed. * PRIN2(U:any):any [standard] Type: EVAL, SPREAD U is displayed, but output is not in READ readable format. The format of the display is the result of EXPLODE expansion; except that strings are not enclosed in double quote characters "...". Lists are displayed in list notation. Special characters are not prefixed with the escape character !. The value of U is returned. The HLISP I/O system is not capable of handling vectors in the current implementation. If U is a vector, the special symbol !*!* is printed. - 50 - HLISP Reference Manual Page 51 FUNCTIONS 21 Aug 84 * PRLENGTH(U:any, [V:any]):integer [superset] Type: EVAL, SPREAD Return the print length of U in characters. The print length of an S-expression is the number of characters that would be required to print it (using PRIN1) if it would all fit on a single output line. The optional argument V may be used to specify computing the print length based on quoted S-expressions displayed using the shorthand quote character (') notation. If V is present and non-NIL, the length will be computed assuming that quoted expressions will be displayed in the shorthand format, otherwise the long format (QUOTE ..) is assumed. Note: PRLENGTH is intended for use with simple lists only; it does not work for lists whose final CDR is non-NIL, or for lists containing items not in the normal node pool (e.g., pointers to compiled code). * PROMPTSTR(PROMPT:atom):NIL [superset] Type: EVAL, SPREAD PROMPT is converted to a string (if necessary), or if it is an atom, its print name is used, and the resulting string becomes the new prompt used by LISP when prompting for input from the terminal (using GCML). The initial prompt string is "LISP> ". * RATOM():atom [superset] This function reads and returns the next atom in the standard input stream. * READLN():string [superset] Read and return the next complete line of input in the standard input stream. If part (but not all) of the current input line has been read, the remainder is discarded and the next line is returned. * RDS(FILEHANDLE:any):any [not implemented] * READ():any [superset] Returns the next expression from the input stream. Valid input forms are: dot-notation, list-notation, numbers (fixed and floating point), function-pointers, and strings. The HLISP I/O system is not capable of handling vectors in the current implementation. See the discussion of superbrackets in the section on "Input Syntax." - 51 - HLISP Reference Manual Page 52 FUNCTIONS 21 Aug 84 * READCH():id [non-standard] Returns the next interned character from the input stream. A special case occurrs at the end of a line: the value !$EOL!$ is returned. End of file causes HLISP to terminate. * RWS(FILEHANDLE:any):any [not implemented] * TERPRI():NIL [standard] The current print line is terminated. 3.16 LISP Reader Input is read using the standard function READ, then it is EVAL'd, and the result is PRINTed. Indirect command files are also supported (using GCML) on both the DCL command line, and during interactive use. The logical name LISP_INIT also provides temporary input redirection during HLISP's initialization. (see the sections "Input and Output" and "Input Redirection Using GCML"). * EXIT() [superset] This is a non-standard synonym for QUIT. * QUIT() [standard] Causes termination of HLISP and control is returned to the operating system. 3.17 String Functions A few general rules concerning string functions: 1. Many functions requiring strings as input will accept an atom and convert it to a string. When an id is converted to a string, its print-name is used. 2. When character positions within a string must be referenced, the first character is in position one. - 52 - HLISP Reference Manual Page 53 FUNCTIONS 21 Aug 84 3. A string uses only one node in LISP memory (the node pool); the text of the string is dynamically allocated external to the node pool. * CMPSTR(U:atom, V:atom):integer [supserset] Type: EVAL, SPREAD Convert U and V to strings, if necessary, and compare them according to the ASCII collating sequence, i.e., "a" > "A". The integer returned indicates the result as follows: +1 => U > V 0 => U = V -1 => U < V If the strings are of unequal length with the shorter identical to the initial substring of the longer, the shorter is indicated as less than the longer. * CMPSTRCI(U:atom, V:atom):integer [supserset] Type: EVAL, SPREAD Convert U and V to strings, if necessary, and compare them according to the ASCII collating sequence except that upper and lower case letters are considered identical, i.e., "a" = "A". The integer returned indicates the result as follows: +1 => U > V 0 => U = V -1 => U < V If the strings are of unequal length with the shorter "equal" to the initial substring of the longer, the shorter is indicated as less than the longer. * DELSUBSTR(U:atom, START:integer, LENGTH:integer):string [superset] Type: EVAL, SPREAD Return a copy of U (as a string) with a substring deleted. U is converted to a string if necessary. The substring to be deleted is indicated by START, the starting character position of the substring, and LENGTH, the number of characters to be deleted. * DOWNCASE(STRING:string):string [superset] Type: EVAL, SPREAD Return a copy of STRING with all letters converted to lower case. - 53 - HLISP Reference Manual Page 54 FUNCTIONS 21 Aug 84 * FILLSTR(CHAR:{string, integer}, LENGTH:integer):string [supserset] Type: EVAL, SPREAD Returns a new string LENGTH characters long, filled with the character indicated by CHAR. If CHAR is a string, the first character is used. If CHAR is the null string, the new string is filled with ASCII NUL characters. If CHAR is an integer, it specifies the ASCII code for the character to fill the string. * LOCSTR(STRING:string, SUBSTR:string, BEGIN:integer):integer [superset] Type: EVAL, SPREAD Search STRING for the string SUBSTR, starting at character position BEGIN, and return the index into STRING where SUBSTR begins if it is found, else return zero. Note that the comparison distinguishes between upper and lower case letters. * STRCONS([U:atom]):string [superset] Type: EVAL, NOSPREAD Returns a string composed of strings derived from each U concatenated in the order of their appearance as arguments. Each U is converted to a string if necessary. * STRLENGTH(S:atom):integer [superset] Type: EVAL, SPREAD Return the length in characters of the string S, as it would be expanded by PRIN2. S is converted to a string, if necessary. * SUBSTR(STRING:string, INDEX:integer, LENGTH:integer):string [superset] Type: EVAL, SPREAD Return a substring of LENGTH characters, extracted from STRING starting at character position INDEX. * UPCASE(STRING:string):string [superset] Type: EVAL, SPREAD Return a copy of STRING with all letters converted to upper case. - 54 - HLISP Reference Manual Page 55 FUNCTIONS 21 Aug 84 3.18 System Related Functions * ASPAWN(CMD:{string, atom}):integer [superset] Type: EVAL, SPREAD CMD is converted to a string if necessary, and the string is used as a DCL command line which is executed in the context of a spawned subprocess. The process executes asynchronously with HLISP, and the process id of the process is returned as the result of this function. (See ATTACH, SSPAWN.) * ATTACH(PID:integer):NIL [superset] Type: EVAL, SPREAD Attach the user's terminal to the process indicated by the process id PID. This function would generally be used to attach to a process created using the SSPAWN function, and operates in a manner similar to the DCL ATTACH command. Below is a DCL command procedure which could be used to obtain the process id of a subprocess created with SSPAWN while in that process, before reattaching to the parent process: $SAVE_VERIFY = 'F$VERIFY(0) $OWNER = F$GETJPI("","OWNER") $OWNER = F$GETJPI(OWNER,"PRCNAM") $WRITE SYS$OUTPUT "Parent process name is ''OWNER'" $XPID = F$GETJPI("","PID") $PID = %X'XPID $WRITE SYS$OUTPUT "Current process ID is ",XPID," (",PID,".)" $EXIT: IF SAVE_VERIFY THEN SET VERIFY * DEBUG():NIL [supserset] Invoke the VAX/VMS symbolic debugger. Note that the use of this function is intended for debugging the HLISP system itself, and is not intended as a user function. * EDD(FNAME:id):NIL [superset] Type: NOEVAL, NOSPREAD Edit the definition of the function FNAME using the list structure editor EDL and EDLAUX. If the editor is exited with the X or XX commands, EDD will use PUTD to replace the definition of FNAME with the result of the editing session; if the editor is exited with the Q or QQ commands, the definition will not be changed. (Note that builtin functions use uninterned identifiers for their local variables, and therefore editing their definitions may produce unexpected results.) - 55 - HLISP Reference Manual Page 56 FUNCTIONS 21 Aug 84 * EDL(U:any):any [superset] Type: EVAL, SPREAD EDL is used to invoke the list structure editor EDLAUX. When the edit session is completed, the result of the editing is returned by EDL. * EDLAUX(S:any, LVL:integer, LL:any):any [superset] Type: EVAL, SPREAD EDLAUX is the performance routine for the list structure editor. EDLAUX is normally invoked using one of the functions EDD, EDL, or EDV. S is the list being edited, LVL is the recursion level used to create the prompt string, and LL is the list containing S. The commands provided by the editor are: list evaluated number repeat count for the next command or list of commands A toggle the automatic display of the current element B backup the pointer in the current list BOL move the pointer to the beginning of the list C copy the current list element to a variable (the variable name must follow the C command) CL copy the entire list being edited to a variable CV copy one variable to another (both variable names follow: source then destination) D delete the element at the pointer DB delete all elements before the pointer DE delete all elements after the pointer (to the end) DUP duplicate the element at the pointer E edit the list at the pointer (recurse) EOL move the pointer to the end of the list EV edit a variable (name follows the EV command) F move the pointer forward in the list (to next element) H help, displays this text I insert one element at the pointer (element follows) IS insert a sublist at the pointer (list follows) ISV insert a sublist at the pointer (variable name follows) - 56 - HLISP Reference Manual Page 57 FUNCTIONS 21 Aug 84 IV insert one element at the pointer (variable name follows) L print the list being edited LL print the list containing the list being edited M invoke a macro (name follows, is a variable containing a list of editor commands and data) OL print the list being edited as it was before changes P paste (insert the last thing deleted or replaced) PB print the element before the pointer PF print the element after the pointer PP print the element at the pointer PS paste sublist (an IS version of P) Q quit one level of the list editor, return original list (unless U has been performed, then return the list current at that time) QQ quit all the way out of the list editor R replace the element at the pointer (D followed by I) RS replace sublist (an IS version of R) RST restore the list (value printed by OL) RSV rsplace sublist (an ISV version of R) RV replace with a variable (an IV version of R) S search for an element EQUAL to value following command SF search using a user specified function SM search for an element with a member EQUAL to value SWAP swap the element at the pointer with the next element T toggle the macro trace (prints the value at the pointer following each command in the macro) U update the previous value of the list (used by OL and RST) X exit one level of the list editor, return edited list XX exit all the way out of the list editor, return edited list * EDP(U:id V:id):NIL [superset] Type: NOEVAL, NOSPREAD Edit the value of the property V of the variable U using the list structure editor EDL and EDLAUX. If the editor is exited with the X or XX commands, EDP will use PUT to replace the value of the property with the result of the editing session; if the editor is exited with the Q or QQ commands, the value will not be changed. - 57 - HLISP Reference Manual Page 58 FUNCTIONS 21 Aug 84 * EDV(U:id):NIL [superset] Type: NOEVAL, NOSPREAD Edit the value of the variable U using the list structure editor EDL and EDLAUX. If the editor is exited with the X or XX commands, EDV will use SET to replace the value of U with the result of the editing session; if the editor is exited with the Q or QQ commands, the value will not be changed. * HASHSTR(STR:string, RANGE:integer):integer [superset] Type: EVAL, SPREAD This function accepts a string, and returns a hash value for the string in the range from zero to RANGE-1. * GETMSG(M:integer):string [supserset] Type: EVAL, SPREAD M is interpreted as a VMS system message number. This function looks up the corresponding message in the system message file and returns the message as a string. This is useful for interpreting the status values returned from system routines and functions such as SSPAWN and E. * GROWMEM(SIZE:integer):NIL [superset] Type: EVAL, SPREAD Causes the size of the node pool to be expanded by SIZE nodes. The current size of the node pool and the amount of free space may be displayed using the function STATUS. * RECLAIM():NIL [superset] Invoke the LISP garbage collection procedure to reclaim all nodes in the node pool which have been allocated but are no longer in use. See also the system variable !*GC, and the discussion of control-C at the beginning of the section on "The Interpreter." * SSPAWN(CMD:{string, atom}):integer [superset] Type: EVAL, SPREAD CMD is converted to a string if necessary, and the string is used as a DCL command line which is executed in the context of a spawned subprocess. The process executes synchronously with HLISP, and the completion status of the process is returned as the result of this function. - 58 - HLISP Reference Manual Page 59 FUNCTIONS 21 Aug 84 * STATUS():NIL [superset] Display the HLISP system status. The size of the HLISP internal call stack is displayed, including the number of words that have never been used. This stack is used for function calling, including function arguments and saving of local data values by compiled code during recursion. Also displayed are the number of LISP symbols and nodes in the node pool, and the number of free nodes. One node is used for each LISP cell, and symbols refer to the atomic symbols on the current alist. Note that the number of free nodes displayed by this function is the number of nodes currently available for allocation. Garbage collection will usually find more nodes which have previously been allocated but are no longer in use. Use of the function RECLAIM prior to invoking STATUS will yield a more meaningful value for the number of free nodes. * TRACE([FN:id]):NIL [superset] Type: NOEVAL, NOSPREAD Instructs the LISP system to trace the invocation and arguments of the functions specified by each FN. * TRACELIST():list [superset] Return a list of all functions being traced. * UNTRACE([FN:id]):NIL [superset] Type: NOEVAL, NOSPREAD Instructs the LISP system to stop tracing the invocation and arguments of the functions specified by each FN. 4.0 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS This implementation does not presently support global variables. However, there are several system predefined variables which provide for controlling the LISP system, or provide symbolic constants. * !$EOF!$ [not implemented] - 59 - HLISP Reference Manual Page 60 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS 21 Aug 84 * !$EOL!$ [standard] The atom !$EOL!$ is returned by READCH when it reaches the end of a logical input record. * !*COMP [not implemented] * !*GC [non-standard] Initial value = NIL. This variable controls the messages generated to indicate garbage collection is in progress, whether it is invoked automatically or programmatically using RECLAIM. When this variable is set to NIL, no messages or special actions are performed associated with garbage collection. If this variable is set to T, a message is printed at the beginning and at the end of garbage collection. If this variable is set to anything else, the same messages are printed as when it is T, but in addition the APVAL property of !*GC is assumed to be an S-expression which is to be evaluated each time garbage collection completes. * !*RAISE [standard] Initial value: NIL. A builtin variable which controls conversion to upper case by the input system. If !*RAISE is non-NIL, all characters input through the input system are raised to upper case. If !*RAISE is NIL, they will be unchanged. * APVAL [superset] This is the property name of the value of an atom when the atom has a static binding (see EVAL). If an atom is not dynamic, i.e., it is not a PROG variable or the formal parameter of an active function, then SET and SETQ associate the value with the atom by binding the value on the atom's property list using the APVAL property. * CHRCLALPHA [superset] Symbolic constant for the character class for alphabetic characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. - 60 - HLISP Reference Manual Page 61 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS 21 Aug 84 * CHRCLCOMBEG [superset] Symbolic constant for the character class for comment beginning characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLCOMEND [superset] Symbolic constant for the character class for comment ending characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLFLOAT [superset] Symbolic constant for the character class for floating point numbers. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLINTID [superset] Symbolic constant for the character class for internal id characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLMONOP [superset] Symbolic constant for the character class for "monop" characters, i.e., characters which form single characters tokens. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLNULL [superset] Symbolic constant for the character class for null characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLNUMERIC [superset] Symbolic constant for the character class for numeric characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. - 61 - HLISP Reference Manual Page 62 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS 21 Aug 84 * CHRCLQUOTE [superset] Symbolic constant for the character class for quote characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLSPECIAL [superset] Symbolic constant for the character class for special characters, i.e., characters which may be combined to form multi-character special symbols. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLTERMN [superset] Symbolic constant for the character class for line terminator characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * CHRCLWHSPACE [superset] Symbolic constant for the character class for white space characters. See the sections "Configurable Lexical Analyzer", "Input and Output" and the function LEX. * EMSG!* [not implemented] * EXPR [standard] The ftype used to indicate a EVAL type function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * FEXPR [standard] The ftype used to indicate a NOEVAL type function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * FIXNUM [superset] A special atom used with the MKVECT function to designate creation of a typed vector whose values are all fixed point numbers. - 62 - HLISP Reference Manual Page 63 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS 21 Aug 84 * FLTNUM [superset] A special atom used with the MKVECT function to designate creation of a typed vector whose values are all floating point numbers. * FSUBR [standard] The ftype used to indicate a NOEVAL type compiled function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * LSUBR [superset] The ftype used to indicate a special type of EVAL type compiled function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * MACRO [superset] The ftype used to indicate a special type of NOEVAL, NOSPREAD function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * PNAME [standard] The property name used to indicate the character string defining the print name of an atom. * READMACRO [superset] A flag used on the property list of a function to indicate that it was defined as a readmacro. * SUBR [standard] The ftype used to indicate a EVAL type compiled function. See the sections "Function Descriptions", "Function Definition", and "The Interpreter". * TRACEBUG [superset] This is a special property name provided to aid debugging. This property indicates a special debug function name associated with the owner of the property. When a function is being traced (using the TRACE facility) and the function has a TRACEBUG property, the value of this property will be evaluated as a function with no arguments during the trace processing, after the traced functions name and arguments have been printed, but before the traced function is invoked. - 63 - HLISP Reference Manual Page 64 SYSTEM VARIABLES, CONSTANTS, AND SYMBOLS 21 Aug 84 For example, to use BREAK as a TRACEBUG function, define an auxilliary function with no arguments to invoke it, e.g., (DE BRK () , (BREAK , ">>> TRACEBUG BREAK, return value is ignored.") ,,,) then, add the tracebug function to the function being debugged, e.g., (DEFPROP BRK TRACEBUG) where is the name of the function. Dont forget to trace the function: (TRACE ). * VERSION [superset] Initial value = 6. This system constant indicates the current implementation version number of HLISP. - 64 - APPENDIX A FILES DELIVERED 1. LINT.DOC The documentation for LINT.EXE. 2. LINT.EXE The LISP INdenTor program. 3. LISP.DOC The HLISP installation and release notes. 4. LISP.EXE This is the executable image file for HLISP. 5. LISP.MEM This document, the HLISP Reference Manual. 6. LISP.HLB The LISP help library used by the HELP function. 7. LISPTR.TXT This file contains a list of HLISP Trouble Reports and resolutions, by HLISP version. 8. *.LSP Sample LISP source code files. - 65 - APPENDIX B REFERENCES 1. Standard LISP Report J. Marti, A. C. Hearn, M. L. Griss, C. Griss ACM SIGPLAN Notices, v.14 n.10, October 1979, p.48 2. LISP Patrick Henry Winston and Berthold Klaus Paul Horn Addison-Wesley, 1981 3. Anatomy of LISP J. Allen McGraw-Hill, 1978 4. The Little LISPer D. P. Friedman Science Research Associates, Inc, 1974 5. LISP 1.5 Primer C. Weissman Dickenson Publishing Co., 1967 - 66 - Page Index-1 21 Aug 84 INDEX ! . . . . . . . . . . . . . . . . 4, 10, 50 !$EOF!$ . . . . . . . . . . . . . 59 !$EOL!$ . . . . . . . . . . . . . 52, 60 !*COMP . . . . . . . . . . . . . . 22 to 24, 60 !*GC . . . . . . . . . . . . . . . 58, 60 !*RAISE . . . . . . . . . . . . . 60 " . . . . . . . . . . . . . . . . 4 % . . . . . . . . . . . . . . . . 10 & . . . . . . . . . . . . . . . . 13 ' . . . . . . . . . . . . . . . . 44, 51 ; . . . . . . . . . . . . . . . . 13 @ . . . . . . . . . . . . . . . . 13 [non-standard] . . . . . . . . . . 3 [not . . . . . . . . . . . . . . . 3 [not implemented] . . . . . . . . 3 [standard] . . . . . . . . . . . . 3 [subset] . . . . . . . . . . . . . 3 [superset] . . . . . . . . . . . . 3 ABS . . . . . . . . . . . . . . . 33 ADD1 . . . . . . . . . . . . . . . 33 Alist . . . . . . . . . . . . . . 6, 25, 43, 59 AND . . . . . . . . . . . . . . . 32 Antecedent . . . . . . . . . . . . 6, 32 Any . . . . . . . . . . . . . . . 6 APPEND . . . . . . . . . . . . . . 37 to 38 APPEND1 . . . . . . . . . . . . . 37 APPEND2 . . . . . . . . . . . . . 37 to 38 APPLY . . . . . . . . . . . . . . 8 to 9, 42 APVAL . . . . . . . . . . . . . . 25, 43, 60 ARG . . . . . . . . . . . . . . . 8, 43 ASCII . . . . . . . . . . . . . . 11, 53 to 54 ASPAWN . . . . . . . . . . . . . . 55 ASSOC . . . . . . . . . . . . . . 38 ATOM . . . . . . . . . . . . . . . 14 Atom . . . . . . . . . . . . . . . 6 ATOMCAR . . . . . . . . . . . . . 18 ATOMCDR . . . . . . . . . . . . . 18 ATOMLENGTH . . . . . . . . . . . . 18 ATOMSTR . . . . . . . . . . . . . 18 ATTACH . . . . . . . . . . . . . . 55 Binding . . . . . . . . . . . . . 60 Boolean . . . . . . . . . . . . . 5 BREAK . . . . . . . . . . . . . . 30, 45, 64 CAR . . . . . . . . . . . . . . . 5, 16 to 17 CDR . . . . . . . . . . . . . . . 5, 17 CHRCLALPHA . . . . . . . . . . . . 11, 60 - 67 - Page Index-2 21 Aug 84 CHRCLCOMBEG . . . . . . . . . . . 11, 61 CHRCLCOMEND . . . . . . . . . . . 11, 61 CHRCLFLOAT . . . . . . . . . . . . 12, 61 CHRCLINTID . . . . . . . . . . . . 12, 61 CHRCLMONOP . . . . . . . . . . . . 12, 61 CHRCLNULL . . . . . . . . . . . . 12, 61 CHRCLNUMERIC . . . . . . . . . . . 12, 61 CHRCLQUOTE . . . . . . . . . . . . 4, 12, 62 CHRCLSPECIAL . . . . . . . . . . . 12, 62 CHRCLTERMN . . . . . . . . . . . . 12, 62 CHRCLWHSPACE . . . . . . . . . . . 12, 62 CLOSE . . . . . . . . . . . . . . 45 CLOSELOG . . . . . . . . . . . . . 45, 47 CMPSTR . . . . . . . . . . . . . . 53 CMPSTRCI . . . . . . . . . . . . . 53 CODEP . . . . . . . . . . . . . . 14 Comments . . . . . . . . . . . . . 10 to 11 COMMON LISP . . . . . . . . . . . 2 COMPRESS . . . . . . . . . . . . . 18 COND . . . . . . . . . . . . . . . 32 Cond-form . . . . . . . . . . . . 6 Condition handler . . . . . . . . 41 CONS . . . . . . . . . . . . . . . 16 to 17 Consequent . . . . . . . . . . . . 6, 32 CONSP . . . . . . . . . . . . . . 14 Constant . . . . . . . . . . . . . 6 CONSTANTP . . . . . . . . . . . . 14 Control-C . . . . . . . . . . . . 41, 58 COPY . . . . . . . . . . . . . . . 38 Current alist . . . . . . . . . . 25, 59 DBG$INPUT . . . . . . . . . . . . 45 DCL . . . . . . . . . . . . . . . 13 DE . . . . . . . . . . . . . . . . 8 to 9, 22 DEBUG . . . . . . . . . . . . . . 55 Default file extension . . . . . . 13 DEFINE . . . . . . . . . . . . . . 8 to 9, 23 DEFLIST . . . . . . . . . . . . . 38 DEFPROP . . . . . . . . . . . . . 20, 50 DELETE . . . . . . . . . . . . . . 38 DELSUBSTR . . . . . . . . . . . . 53 DF . . . . . . . . . . . . . . . . 8, 23, 42 DIFFERENCE . . . . . . . . . . . . 33 DIGIT . . . . . . . . . . . . . . 39 DIVIDE . . . . . . . . . . . . . . 33 DM . . . . . . . . . . . . . . . . 9, 23 DO . . . . . . . . . . . . . . . . 28 Dotted-pair . . . . . . . . . . . 5, 15 to 16 DOWNCASE . . . . . . . . . . . . . 53 DRM . . . . . . . . . . . . . . . 9, 24 Dynamic binding . . . . . . . . . 43, 60 EDD . . . . . . . . . . . . . . . 55 EDL . . . . . . . . . . . . . . . 56 - 68 - Page Index-3 21 Aug 84 EDLAUX . . . . . . . . . . . . . . 56 EDP . . . . . . . . . . . . . . . 57 EDV . . . . . . . . . . . . . . . 58 EJECT . . . . . . . . . . . . . . 45 ELEMENT . . . . . . . . . . . . . 39 EMSG!* . . . . . . . . . . . . . . 62 EQ . . . . . . . . . . . . . . . . 14 to 15 EQN . . . . . . . . . . . . . . . 14 to 15 EQUAL . . . . . . . . . . . . . . 15 ERROR . . . . . . . . . . . . . . 10, 30 ERRORSET . . . . . . . . . . . . . 30 EVAL . . . . . . . . . . . . . . . 4, 7 to 9, 43, 60 EVLIS . . . . . . . . . . . . . . 44 EXIT . . . . . . . . . . . . . . . 52 EXPAND . . . . . . . . . . . . . . 44 EXPLODE . . . . . . . . . . . . . 5, 18, 50 EXPR . . . . . . . . . . . . . . . 5, 22 to 23, 62 EXPT . . . . . . . . . . . . . . . 34 Extra-boolean . . . . . . . . . . 5 FEXPR . . . . . . . . . . . . . . 5, 23, 42, 62 File specification . . . . . . . . 13 FILLSTR . . . . . . . . . . . . . 54 FIX . . . . . . . . . . . . . . . 33 to 34 FIXNUM . . . . . . . . . . . . . . 5, 31, 62 FIXP . . . . . . . . . . . . . . . 15 FLAG . . . . . . . . . . . . . . . 20 Flag . . . . . . . . . . . . . . . 63 FLAG1 . . . . . . . . . . . . . . 21 FLAGP . . . . . . . . . . . . . . 21 Flags . . . . . . . . . . . . . . 4, 20 FLOAT . . . . . . . . . . . . . . 33 to 34 Floating . . . . . . . . . . . . . 3 FLOATP . . . . . . . . . . . . . . 15 FLTNUM . . . . . . . . . . . . . . 5, 31, 63 FLUID . . . . . . . . . . . . . . 25 Fluid . . . . . . . . . . . . . . 25 FLUIDP . . . . . . . . . . . . . . 25 FSUBR . . . . . . . . . . . . . . 5, 9, 63 Ftype . . . . . . . . . . . . . . 5, 8, 62 to 63 FUNARG . . . . . . . . . . . . . . 7 Funarg . . . . . . . . . . . . . . 7, 43 to 44 FUNCALL . . . . . . . . . . . . . 44 FUNCTION . . . . . . . . . . . . . 7, 44 Function . . . . . . . . . . . . . 7 Function pointer . . . . . . . . . 5, 15 Function types . . . . . . . . . . 8 Garbage collection . . . . . . . . 41, 58 to 60 GCML . . . . . . . . . . . . . . . 13, 45, 47, 51 to 52 GENSYM . . . . . . . . . . . . . . 18 GET . . . . . . . . . . . . . . . 4, 21 GETD . . . . . . . . . . . . . . . 4, 24 GETMSG . . . . . . . . . . . . . . 58 - 69 - Page Index-4 21 Aug 84 GETP . . . . . . . . . . . . . . . 20 to 21 GETV . . . . . . . . . . . . . . . 31 GLOBAL . . . . . . . . . . . . . . 25 Global . . . . . . . . . . . . . . 25 GLOBALP . . . . . . . . . . . . . 25 GO . . . . . . . . . . . . . . . . 6, 26, 29 to 30, 32 GREATERP . . . . . . . . . . . . . 34 GROWMEM . . . . . . . . . . . . . 58 HASHSTR . . . . . . . . . . . . . 58 HELP . . . . . . . . . . . . . . . 46, A-1 HLISP . . . . . . . . . . . . . . 2 Id . . . . . . . . . . . . . . . . 4 IDP . . . . . . . . . . . . . . . 15, 19 IMPLODE . . . . . . . . . . . . . 19 Indirect command files . . . . . . 13 INITIAL . . . . . . . . . . . . . 27 Input file chaining . . . . . . . 13 Input file nesting . . . . . . . . 13 Input file specification . . . . . 13 Input redirection . . . . . . . . 13 Integer . . . . . . . . . . . . . 3 INTERLISP . . . . . . . . . . . . 2 INTERN . . . . . . . . . . . . . . 4, 19 INTERNCD . . . . . . . . . . . . . 19 INTERNCI . . . . . . . . . . . . . 19 Labels . . . . . . . . . . . . . . 26 LAMBDA . . . . . . . . . . . . . . 6, 22 Lambda . . . . . . . . . . . . . . 6, 8 to 9, 22 to 23, 26, 43 LAST . . . . . . . . . . . . . . . 39 LENGTH . . . . . . . . . . . . . . 39 LESSP . . . . . . . . . . . . . . 34 LET . . . . . . . . . . . . . . . 26 LEX . . . . . . . . . . . . . . . 4, 10 to 11, 46, 60 to 62 LINELENGTH . . . . . . . . . . . . 46 LISP_INIT . . . . . . . . . . . . 13, 52 LIST . . . . . . . . . . . . . . . 17 List . . . . . . . . . . . . . . . 6 LITER . . . . . . . . . . . . . . 39 Local . . . . . . . . . . . . . . 25 LOCSTR . . . . . . . . . . . . . . 54 LOGAND . . . . . . . . . . . . . . 34 Logical name . . . . . . . . . . . 13, 52 LOGIO . . . . . . . . . . . . . . 45, 47 LOGOR . . . . . . . . . . . . . . 34 LOOP . . . . . . . . . . . . . . . 27 LPOSN . . . . . . . . . . . . . . 47 LSUBR . . . . . . . . . . . . . . 5, 9, 63 MACLISP . . . . . . . . . . . . . 2 MACRO . . . . . . . . . . . . . . 5, 9, 23, 63 MAP . . . . . . . . . . . . . . . 36 - 70 - Page Index-5 21 Aug 84 MAPC . . . . . . . . . . . . . . . 36 MAPCAN . . . . . . . . . . . . . . 36 MAPCAR . . . . . . . . . . . . . . 37 MAPCON . . . . . . . . . . . . . . 37 MAPLIST . . . . . . . . . . . . . 37 MAX . . . . . . . . . . . . . . . 34 MAX2 . . . . . . . . . . . . . . . 35 MEMBER . . . . . . . . . . . . . . 39 MEMQ . . . . . . . . . . . . . . . 39 MIN . . . . . . . . . . . . . . . 35 MIN2 . . . . . . . . . . . . . . . 35 MINUS . . . . . . . . . . . . . . 35 MINUSP . . . . . . . . . . . . . . 15 MKATOM . . . . . . . . . . . . . . 19 MKVECT . . . . . . . . . . . . . . 31, 62 to 63 MSG . . . . . . . . . . . . . . . 47 NCONC . . . . . . . . . . . . . . 40 NIL . . . . . . . . . . . . . . . 5 Node pool . . . . . . . . . . . . 3, 31, 41, 53, 58 to 59 Nodes . . . . . . . . . . . . . . 3 NOT . . . . . . . . . . . . . . . 15, 32 NULL . . . . . . . . . . . . . . . 15 Number . . . . . . . . . . . . . . 5 NUMBERP . . . . . . . . . . . . . 15 OBLIST . . . . . . . . . . . . . . 4, 18 to 19 OCML . . . . . . . . . . . . . . . 13, 47 ONEP . . . . . . . . . . . . . . . 16 OPEN . . . . . . . . . . . . . . . 48 OR . . . . . . . . . . . . . . . . 32 OUTF . . . . . . . . . . . . . . . 48 OUTPUT . . . . . . . . . . . . . . 45, 48 PAGELENGTH . . . . . . . . . . . . 48 PAIR . . . . . . . . . . . . . . . 40 PAIRP . . . . . . . . . . . . . . 16 Parameter-spec . . . . . . . . . . 6, 8 to 9, 22 to 23, 42 to 43 PLUS . . . . . . . . . . . . . . . 35 PLUS2 . . . . . . . . . . . . . . 35 PNAME . . . . . . . . . . . . . . 63 POP . . . . . . . . . . . . . . . 40 POSN . . . . . . . . . . . . . . . 48 PP . . . . . . . . . . . . . . . . 48 PPAUX . . . . . . . . . . . . . . 48 PPAUX2 . . . . . . . . . . . . . . 49 PPD . . . . . . . . . . . . . . . 49 PPI . . . . . . . . . . . . . . . 49 PPINT . . . . . . . . . . . . . . 49 PPP . . . . . . . . . . . . . . . 49 PPPL . . . . . . . . . . . . . . . 20, 50 Pretty print . . . . . . . . . . . 48 to 50 PRIN1 . . . . . . . . . . . . . . 50 PRIN2 . . . . . . . . . . . . . . 50 - 71 - Page Index-6 21 Aug 84 PRINC . . . . . . . . . . . . . . 50 PRINT . . . . . . . . . . . . . . 50 Print name . . . . . . . . . . . . 4, 63 PRLENGTH . . . . . . . . . . . . . 51 PROG . . . . . . . . . . . . . . . 26, 29 to 30 PROG1 . . . . . . . . . . . . . . 29 PROG2 . . . . . . . . . . . . . . 29 PROGN . . . . . . . . . . . . . . 29 PROMPTSTR . . . . . . . . . . . . 13, 51 Properties . . . . . . . . . . . . 4, 20, 63 Property list . . . . . . . . . . 20, 63 PUSH . . . . . . . . . . . . . . . 40 PUT . . . . . . . . . . . . . . . 4, 21 PUTD . . . . . . . . . . . . . . . 4, 21, 24 PUTPROP . . . . . . . . . . . . . 21 PUTV . . . . . . . . . . . . . . . 31 QUIT . . . . . . . . . . . . . . . 52 QUOTE . . . . . . . . . . . . . . 44, 51 QUOTIENT . . . . . . . . . . . . . 35 RATOM . . . . . . . . . . . . . . 51 RDS . . . . . . . . . . . . . . . 51 READ . . . . . . . . . . . . . . . 4, 9 to 10, 51 READCH . . . . . . . . . . . . . . 10, 52, 60 READLN . . . . . . . . . . . . . . 51 READMACRO . . . . . . . . . . . . 9, 24, 63 RECLAIM . . . . . . . . . . . . . 41, 58 to 60 REDUCE . . . . . . . . . . . . . . 9 REMAINDER . . . . . . . . . . . . 35 REMD . . . . . . . . . . . . . . . 4, 24 REMFLAG . . . . . . . . . . . . . 22 REMFLAG1 . . . . . . . . . . . . . 22 REMOB . . . . . . . . . . . . . . 4, 19 REMPROP . . . . . . . . . . . . . 4, 22 REPEAT . . . . . . . . . . . . . . 29 Report, the . . . . . . . . . . . 2 RESULT . . . . . . . . . . . . . . 28 RETURN . . . . . . . . . . . . . . 6, 29 to 30, 32, 45 REVERSE . . . . . . . . . . . . . 40 RPLACA . . . . . . . . . . . . . . 17 RPLACD . . . . . . . . . . . . . . 17 RWS . . . . . . . . . . . . . . . 52 S-expression . . . . . . . . . . . 6 SASSOC . . . . . . . . . . . . . . 41 SET . . . . . . . . . . . . . . . 25, 60 SETQ . . . . . . . . . . . . . . . 25, 60 SQRT . . . . . . . . . . . . . . . 36 SSPAWN . . . . . . . . . . . . . . 55, 58 Static binding . . . . . . . . . . 43, 60 STATUS . . . . . . . . . . . . . . 9, 58 to 59 STRCONS . . . . . . . . . . . . . 54 String . . . . . . . . . . . . . . 4, 15 - 72 - Page Index-7 21 Aug 84 STRINGP . . . . . . . . . . . . . 16 STRLENGTH . . . . . . . . . . . . 54 SUB1 . . . . . . . . . . . . . . . 36 SUBLIS . . . . . . . . . . . . . . 41 SUBR . . . . . . . . . . . . . . . 5, 9, 63 SUBST . . . . . . . . . . . . . . 41 SUBSTR . . . . . . . . . . . . . . 54 Superbrackets . . . . . . . . . . 10, 31, 51 SYS$INPUT . . . . . . . . . . . . 45, 47 SYS$OUTPUT . . . . . . . . . . . . 45, 48 T . . . . . . . . . . . . . . . . 5 TERPRI . . . . . . . . . . . . . . 52 The Report . . . . . . . . . . . . 2 TIMES . . . . . . . . . . . . . . 36 TIMES2 . . . . . . . . . . . . . . 36 TRACE . . . . . . . . . . . . . . 59 TRACEBUG . . . . . . . . . . . . . 41, 63 TRACELIST . . . . . . . . . . . . 59 TT: . . . . . . . . . . . . . . . 47 to 48 Typed vector . . . . . . . . . . . 5, 31, 62 to 63 UNFLUID . . . . . . . . . . . . . 26 UNTIL . . . . . . . . . . . . . . 28 to 29 UNTRACE . . . . . . . . . . . . . 59 UPBV . . . . . . . . . . . . . . . 31 UPCASE . . . . . . . . . . . . . . 54 Vector . . . . . . . . . . . . . . 5, 15, 31 VECTORP . . . . . . . . . . . . . 16 VERSION . . . . . . . . . . . . . 2, 64 WHILE . . . . . . . . . . . . . . 28 to 29 ZEROP . . . . . . . . . . . . . . 16 - 73 -