home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd4.lzh / DOC / xlisp.doc < prev   
Text File  |  1990-03-11  |  81KB  |  3,245 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          XLISP: An Object-oriented Lisp
  8.  
  9.                                   Version 2.0
  10.  
  11.                                 February 6, 1988
  12.  
  13.  
  14.                                        by
  15.                                David Michael Betz
  16.                                 127 Taylor Road
  17.                              Peterborough, NH 03458
  18.  
  19.                              (603) 924-6936 (home)
  20.                              (603) 882-1599 (BBS)
  21.  
  22.                    Copyright (c) 1988, by David Michael Betz
  23.                               All Rights Reserved
  24.            Permission is granted for unrestricted non-commercial use
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.         XLISP                  TABLE OF CONTENTS                  Page 2
  71.  
  72.  
  73.                                Table of Contents
  74.  
  75.  
  76.                 TABLE OF CONTENTS                        2
  77.  
  78.                 INTRODUCTION                             4
  79.  
  80.                 A NOTE FROM THE AUTHOR                   5
  81.  
  82.                 XLISP COMMAND LOOP                       6
  83.  
  84.                 BREAK COMMAND LOOP                       7
  85.  
  86.                 DATA TYPES                               8
  87.  
  88.                 THE EVALUATOR                            9
  89.  
  90.                 LEXICAL CONVENTIONS                     10
  91.  
  92.                 READTABLES                              11
  93.  
  94.                 LAMBDA LISTS                            12
  95.  
  96.                 OBJECTS                                 14
  97.  
  98.                 SYMBOLS                                 17
  99.  
  100.                 EVALUATION FUNCTIONS                    18
  101.  
  102.                 SYMBOL FUNCTIONS                        19
  103.  
  104.                 PROPERTY LIST FUNCTIONS                 21
  105.  
  106.                 ARRAY FUNCTIONS                         22
  107.  
  108.                 LIST FUNCTIONS                          23
  109.  
  110.                 DESTRUCTIVE LIST FUNCTIONS              26
  111.  
  112.                 PREDICATE FUNCTIONS                     27
  113.  
  114.                 CONTROL CONSTRUCTS                      29
  115.  
  116.                 LOOPING CONSTRUCTS                      31
  117.  
  118.                 THE PROGRAM FEATURE                     32
  119.  
  120.                 DEBUGGING AND ERROR HANDLING            33
  121.  
  122.                 ARITHMETIC FUNCTIONS                    34
  123.  
  124.                 BITWISE LOGICAL FUNCTIONS               36
  125.  
  126.                 STRING FUNCTIONS                        37
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.         XLISP                  TABLE OF CONTENTS                  Page 3
  137.  
  138.  
  139.                 CHARACTER FUNCTIONS                     39
  140.  
  141.                 INPUT/OUTPUT FUNCTIONS                  41
  142.  
  143.                 THE FORMAT FUNCTION                     42
  144.  
  145.                 FILE I/O FUNCTIONS                      43
  146.  
  147.                 STRING STREAM FUNCTIONS                 44
  148.  
  149.                 SYSTEM FUNCTIONS                        45
  150.  
  151.                 EXAMPLES                                47
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.         XLISP                     INTRODUCTION                    Page 4
  203.  
  204.  
  205.         INTRODUCTION
  206.  
  207.         XLISP is an experimental programming language combining some of
  208.         the features of Common Lisp with an object-oriented extension
  209.         capability.  It was implemented to allow experimentation with
  210.         object-oriented programming on small computers.
  211.  
  212.         There are currently implementations of XLISP running on the IBM-
  213.         PC and clones under MS-DOS, on the Macintosh, the Atari-ST and
  214.         the Amiga.  It is completely written in the programming language
  215.         'C' and is easily extended with user written built-in functions
  216.         and classes.  It is available in source form to non-commercial
  217.         users.
  218.  
  219.         Many Common Lisp functions are built into XLISP.  In addition,
  220.         XLISP defines the objects 'Object' and 'Class' as primitives.
  221.         'Object' is the only class that has no superclass and hence is
  222.         the root of the class heirarchy tree.  'Class' is the class of
  223.         which all classes are instances (it is the only object that is
  224.         an instance of itself).
  225.  
  226.         This document is a brief description of XLISP.  It assumes some
  227.         knowledge of LISP and some understanding of the concepts of
  228.         object-oriented programming.
  229.  
  230.         I recommend the book "LISP" by Winston and Horn and published by
  231.         Addison Wesley for learning Lisp.  The first edition of this
  232.         book is based on MacLisp and the second edition is based on
  233.         Common Lisp.  XLISP will continue to migrate towards
  234.         compatibility with Common Lisp.
  235.  
  236.         You will probably also need a copy of "Common Lisp: The
  237.         Language" by Guy L. Steele, Jr., published by Digital Press to
  238.         use as a reference for some of the Common Lisp functions that
  239.         are described only briefly in this document.
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.         XLISP                A NOTE FROM THE AUTHOR               Page 5
  269.  
  270.  
  271.         A NOTE FROM THE AUTHOR
  272.  
  273.         If you have any problems with XLISP, feel free to contact me for
  274.         help or advice.  Please remember that since XLISP is available
  275.         in source form in a high level language, many users have been
  276.         making versions available on a variety of machines.  If you call
  277.         to report a problem with a specific version, I may not be able
  278.         to help you if that version runs on a machine to which I don't
  279.         have access.  Please have the version number of the version that
  280.         you are running readily accessible before calling me.
  281.  
  282.         If you find a bug in XLISP, first try to fix the bug yourself
  283.         using the source code provided.  If you are successful in fixing
  284.         the bug, send the bug report along with the fix to me.  If you
  285.         don't have access to a C compiler or are unable to fix a bug,
  286.         please send the bug report to me and I'll try to fix it.
  287.  
  288.         Any suggestions for improvements will be welcomed.  Feel free to
  289.         extend the language in whatever way suits your needs.  However,
  290.         PLEASE DO NOT RELEASE ENHANCED VERSIONS WITHOUT CHECKING WITH ME
  291.         FIRST!!  I would like to be the clearing house for new features
  292.         added to XLISP.  If you want to add features for your own
  293.         personal use, go ahead.  But, if you want to distribute your
  294.         enhanced version, contact me first.  Please remember that the
  295.         goal of XLISP is to provide a language to learn and experiment
  296.         with LISP and object-oriented programming on small computers.  I
  297.         don't want it to get so big that it requires megabytes of memory
  298.         to run.
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.         XLISP                 XLISP COMMAND LOOP                  Page 6
  335.  
  336.  
  337.         XLISP COMMAND LOOP
  338.  
  339.         When XLISP is started, it first tries to load the workspace
  340.         "xlisp.wks" from the current directory.  If that file doesn't
  341.         exist, XLISP builds an initial workspace, empty except for the
  342.         built-in functions and symbols.
  343.  
  344.         Then XLISP attempts to load "init.lsp" from the current
  345.         directory.  It then loads any files named as parameters on the
  346.         command line (after appending ".lsp" to their names).
  347.  
  348.         XLISP then issues the following prompt:
  349.  
  350.         >
  351.  
  352.         This indicates that XLISP is waiting for an expression to be
  353.         typed.
  354.  
  355.         When a complete expression has been entered, XLISP attempts to
  356.         evaluate that expression.  If the expression evaluates
  357.         successfully, XLISP prints the result and then returns to the
  358.         initial prompt waiting for another expression to be typed.
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.         XLISP                 BREAK COMMAND LOOP                  Page 7
  401.  
  402.  
  403.         BREAK COMMAND LOOP
  404.  
  405.         When XLISP encounters an error while evaluating an expression,
  406.         it attempts to handle the error in the following way:
  407.  
  408.         If the symbol '*breakenable*' is true, the message corresponding
  409.         to the error is printed.  If the error is correctable, the
  410.         correction message is printed.
  411.  
  412.         If the symbol '*tracenable*' is true, a trace back is printed.
  413.         The number of entries printed depends on the value of the symbol
  414.         '*tracelimit*'.  If this symbol is set to something other than a
  415.         number, the entire trace back stack is printed.
  416.  
  417.         XLISP then enters a read/eval/print loop to allow the user to
  418.         examine the state of the interpreter in the context of the
  419.         error.  This loop differs from the normal top-level
  420.         read/eval/print loop in that if the user invokes the function
  421.         'continue', XLISP will continue from a correctable error.  If
  422.         the user invokes the function 'clean-up', XLISP will abort the
  423.         break loop and return to the top level or the next lower
  424.         numbered break loop.  When in a break loop, XLISP prefixes the
  425.         break level to the normal prompt.
  426.  
  427.         If the symbol '*breakenable*' is nil, XLISP looks for a
  428.         surrounding errset function.  If one is found, XLISP examines
  429.         the value of the print flag.  If this flag is true, the error
  430.         message is printed.  In any case, XLISP causes the errset
  431.         function call to return nil.
  432.  
  433.         If there is no surrounding errset function, XLISP prints the
  434.         error message and returns to the top level.
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.         XLISP                      DATA TYPES                     Page 8
  467.  
  468.  
  469.         DATA TYPES
  470.  
  471.         There are several different data types available to XLISP
  472.         programmers.
  473.  
  474.             o lists
  475.             o symbols
  476.             o strings
  477.             o integers
  478.             o characters
  479.             o floats
  480.             o objects
  481.             o arrays
  482.             o streams
  483.             o subrs (built-in functions)
  484.             o fsubrs (special forms)
  485.             o closures (user defined functions)
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.         XLISP                    THE EVALUATOR                    Page 9
  533.  
  534.  
  535.         THE EVALUATOR
  536.  
  537.         The process of evaluation in XLISP:
  538.  
  539.         Strings, integers, characters, floats, objects, arrays, streams,
  540.         subrs, fsubrs and closures evaluate to themselves.
  541.  
  542.         Symbols act as variables and are evaluated by retrieving the
  543.         value associated with their current binding.
  544.  
  545.         Lists are evaluated by examining the first element of the list
  546.         and then taking one of the following actions:
  547.  
  548.             If it is a symbol, the functional binding of the symbol is
  549.             retrieved.
  550.  
  551.             If it is a lambda expression, a closure is constructed for
  552.             the function described by the lambda expression.
  553.  
  554.             If it is a subr, fsubr or closure, it stands for itself.
  555.  
  556.             Any other value is an error.
  557.  
  558.         Then, the value produced by the previous step is examined:
  559.  
  560.             If it is a subr or closure, the remaining list elements are
  561.             evaluated and the subr or closure is called with these
  562.             evaluated expressions as arguments.
  563.  
  564.             If it is an fsubr, the fsubr is called using the remaining
  565.             list elements as arguments (unevaluated).
  566.  
  567.             If it is a macro, the macro is expanded using the remaining
  568.             list elements as arguments (unevaluated).  The macro
  569.             expansion is then evaluated in place of the original macro
  570.             call.
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.         XLISP                 LEXICAL CONVENTIONS                Page 10
  599.  
  600.  
  601.         LEXICAL CONVENTIONS
  602.  
  603.         The following conventions must be followed when entering XLISP
  604.         programs:
  605.  
  606.         Comments in XLISP code begin with a semi-colon character and
  607.         continue to the end of the line.
  608.  
  609.         Symbol names in XLISP can consist of any sequence of non-blank
  610.         printable characters except the following:
  611.  
  612.                 ( ) ' ` , " ;
  613.  
  614.         Uppercase and lowercase characters are not distinguished within
  615.         symbol names.  All lowercase characters are mapped to uppercase
  616.         on input.
  617.  
  618.         Integer literals consist of a sequence of digits optionally
  619.         beginning with a '+' or '-'.  The range of values an integer can
  620.         represent is limited by the size of a C 'long' on the machine on
  621.         which XLISP is running.
  622.  
  623.         Floating point literals consist of a sequence of digits
  624.         optionally beginning with a '+' or '-' and including an embedded
  625.         decimal point.  The range of values a floating point number can
  626.         represent is limited by the size of a C 'float' ('double' on
  627.         machines with 32 bit addresses) on the machine on which XLISP is
  628.         running.
  629.  
  630.         Literal strings are sequences of characters surrounded by double
  631.         quotes.  Within quoted strings the '\' character is used to
  632.         allow non-printable characters to be included.  The codes
  633.         recognized are:
  634.  
  635.                 \\        means the character '\'
  636.                 \n       means newline
  637.                 \t       means tab
  638.                 \r       means return
  639.                 \f       means form feed
  640.                 \nnn     means the character whose octal code is nnn
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.         XLISP                      READTABLES                    Page 11
  665.  
  666.  
  667.         READTABLES
  668.  
  669.         The behaviour of the reader is controlled by a data structure
  670.         called a "readtable".  The reader uses the symbol *READTABLE* to
  671.         locate the current readtable.  This table controls the
  672.         interpretation of input characters.  It is an array with 128
  673.         entries, one for each of the ASCII character codes.  Each entry
  674.         contains one of the following things:
  675.  
  676.                 NIL             Indicating an invalid character
  677.                 :CONSTITUENT    Indicating a symbol constituent
  678.                 :WHITE-SPACE    Indicating a whitespace character
  679.                 (:TMACRO . fun) Terminating readmacro
  680.                 (:NMACRO . fun) Non-terminating readmacro
  681.                 :SESCAPE        Single escape character ('\')
  682.                 :MESCAPE        Multiple escape character ('|')
  683.  
  684.         In the case of :TMACRO and :NMACRO, the "fun" component is a
  685.         function.  This can either be a built-in readmacro function or a
  686.         lambda expression.  The function should take two parameters.
  687.         The first is the input stream and the second is the character
  688.         that caused the invocation of the readmacro.  The readmacro
  689.         function should return NIL to indicate that the character should
  690.         be treated as white space or a value consed with NIL to indicate
  691.         that the readmacro should be treated as an occurance of the
  692.         specified value.  Of course, the readmacro code is free to read
  693.         additional characters from the input stream.
  694.  
  695.         XLISP defines several useful read macros:
  696.  
  697.                 '<expr>         == (quote <expr>)
  698.                 #'<expr>        == (function <expr>)
  699.                 #(<expr>...)    == an array of the specified expressions
  700.                 #x<hdigits>     == a hexadecimal number (0-9,A-F)
  701.                 #o<odigits>     == an octal number (0-7)
  702.                 #b<bdigits>     == a binary number (0-1)
  703.                 #\<char> == the ASCII code of the character
  704.                 #| ... |#       == a comment
  705.                 #:<symbol>      == an uninterned symbol
  706.                 `<expr>         == (backquote <expr>)
  707.                 ,<expr>         == (comma <expr>)
  708.                 ,@<expr>        == (comma-at <expr>)
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.         XLISP                     LAMBDA LISTS                   Page 12
  731.  
  732.  
  733.         LAMBDA LISTS
  734.  
  735.         There are several forms in XLISP that require that a "lambda
  736.         list" be specified.  A lambda list is a definition of the
  737.         arguments accepted by a function.  There are four different
  738.         types of arguments.
  739.  
  740.         The lambda list starts with required arguments.  Required
  741.         arguments must be specified in every call to the function.
  742.  
  743.         The required arguments are followed by the &optional arguments.
  744.         Optional arguments may be provided or omitted in a call.  An
  745.         initialization expression may be specified to provide a default
  746.         value for an &optional argument if it is omitted from a call.
  747.         If no initialization expression is specified, an omitted
  748.         argument is initialized to NIL.  It is also possible to provide
  749.         the name of a 'supplied-p' variable that can be used to
  750.         determine if a call provided a value for the argument or if the
  751.         initialization expression was used.  If specified, the supplied-
  752.         p variable will be bound to T if a value was specified in the
  753.         call and NIL if the default value was used.
  754.  
  755.         The &optional arguments are followed by the &rest argument.  The
  756.         &rest argument gets bound to the remainder of the argument list
  757.         after the required and &optional arguments have been removed.
  758.  
  759.         The &rest argument is followed by the &key arguments.  When a
  760.         keyword argument is passed to a function, a pair of values
  761.         appears in the argument list.  The first expression in the pair
  762.         should evaluate to a keyword symbol (a symbol that begins with a
  763.         ':').  The value of the second expression is the value of the
  764.         keyword argument.  Like &optional arguments, &key arguments can
  765.         have initialization expressions and supplied-p variables.  In
  766.         addition, it is possible to specify the keyword to be used in a
  767.         function call.  If no keyword is specified, the keyword obtained
  768.         by adding a ':' to the beginning of the keyword argument symbol
  769.         is used.  In other words, if the keyword argument symbol is
  770.         'foo', the keyword will be ':foo'.
  771.  
  772.         The &key arguments are followed by the &aux variables.  These
  773.         are local variables that are bound during the evaluation of the
  774.         function body.  It is possible to have initialization
  775.         expressions for the &aux variables.
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.         XLISP                     LAMBDA LISTS                   Page 13
  797.  
  798.  
  799.         Here is the complete syntax for lambda lists:
  800.  
  801.                 (<rarg>...
  802.                  [&optional [<oarg> | (<oarg> [<init> [<svar>]])]...]
  803.                  [&rest <rarg>]
  804.                  [&key
  805.                    [<karg> | ([<karg> | (<key> <karg>)] [<init> [<svar>]])]...
  806.                    &allow-other-keys]
  807.                  [&aux
  808.                    [<aux> | (<aux> [<init>])]...])
  809.  
  810.             where:
  811.  
  812.                 <rarg>  is a required argument symbol
  813.                 <oarg>  is an &optional argument symbol
  814.                 <rarg>  is the &rest argument symbol
  815.                 <karg>  is a &key argument symbol
  816.                 <key>   is a keyword symbol
  817.                 <aux>   is an auxiliary variable symbol
  818.                 <init>  is an initialization expression
  819.                 <svar>  is a supplied-p variable symbol
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.         XLISP                       OBJECTS                      Page 14
  863.  
  864.  
  865.         OBJECTS
  866.  
  867.         Definitions:
  868.  
  869.             o selector - a symbol used to select an appropriate method
  870.             o message - a selector and a list of actual arguments
  871.             o method - the code that implements a message
  872.  
  873.         Since XLISP was created to provide a simple basis for
  874.         experimenting with object-oriented programming, one of the
  875.         primitive data types included is 'object'.  In XLISP, an object
  876.         consists of a data structure containing a pointer to the
  877.         object's class as well as an array containing the values of the
  878.         object's instance variables.
  879.  
  880.         Officially, there is no way to see inside an object (look at the
  881.         values of its instance variables).  The only way to communicate
  882.         with an object is by sending it a message.
  883.  
  884.         You can send a message to an object using the 'send' function.
  885.         This function takes the object as its first argument, the
  886.         message selector as its second argument (which must be a symbol)
  887.         and the message arguments as its remaining arguments.
  888.  
  889.         The 'send' function determines the class of the receiving object
  890.         and attempts to find a method corresponding to the message
  891.         selector in the set of messages defined for that class.  If the
  892.         message is not found in the object's class and the class has a
  893.         super-class, the search continues by looking at the messages
  894.         defined for the super-class.  This process continues from one
  895.         super-class to the next until a method for the message is found.
  896.         If no method is found, an error occurs.
  897.  
  898.         A message can also be sent from the body of a method by using
  899.         the current object, but the method lookup starts with the
  900.         object's superclass rather than its class.  This allows a
  901.         subclass to invoke a standard method in its parent class even
  902.         though it overrides that method with its own specialized
  903.         version.
  904.  
  905.         When a method is found, the evaluator binds the receiving object
  906.         to the symbol 'self' and evaluates the method using the
  907.         remaining elements of the original list as arguments to the
  908.         method.  These arguments are always evaluated prior to being
  909.         bound to their corresponding formal arguments.  The result of
  910.         evaluating the method becomes the result of the expression.
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.         XLISP                       OBJECTS                      Page 15
  929.  
  930.  
  931.         THE 'Object' CLASS
  932.  
  933.         Classes:
  934.  
  935.         Object  THE TOP OF THE CLASS HEIRARCHY
  936.  
  937.             Messages:
  938.  
  939.                 :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  940.                     returns     the object
  941.  
  942.                 :class  RETURN THE CLASS OF AN OBJECT
  943.                     returns     the class of the object
  944.  
  945.                 :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  946.                     returns     the object
  947.  
  948.                 :sendsuper <sel> <args>...  SEND SUPERCLASS A MESSAGE
  949.                     <sel>       the message selector
  950.                     <args>      the message arguments
  951.                     returns     the result of sending the message
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.         XLISP                       OBJECTS                      Page 16
  995.  
  996.  
  997.         THE 'Class' CLASS
  998.  
  999.         Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  1000.  
  1001.             Messages:
  1002.  
  1003.                 :new  CREATE A NEW INSTANCE OF A CLASS
  1004.                     returns     the new class object
  1005.  
  1006.                 :isnew <ivars> [<cvars> [<super>]]  INITIALIZE A NEW CLASS
  1007.                     <ivars>     the list of instance variable symbols
  1008.                     <cvars>     the list of class variable symbols
  1009.                     <super>     the superclass (default is Object)
  1010.                     returns     the new class object
  1011.  
  1012.                 :answer <msg> <fargs> <code>  ADD A MESSAGE TO A CLASS
  1013.                     <msg>       the message symbol
  1014.                     <fargs>     the formal argument list (lambda list)
  1015.                     <code>      a list of executable expressions
  1016.                     returns     the object
  1017.  
  1018.  
  1019.         When a new instance of a class is created by sending the message
  1020.         ':new' to an existing class, the message ':isnew' followed by
  1021.         whatever parameters were passed to the ':new' message is sent to
  1022.         the newly created object.
  1023.  
  1024.         When a new class is created by sending the ':new' message to the
  1025.         object 'Class', an optional parameter may be specified
  1026.         indicating the superclass of the new class.  If this parameter
  1027.         is omitted, the new class will be a subclass of 'Object'.  A
  1028.         class inherits all instance variables, class variables, and
  1029.         methods from its super-class.
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.         XLISP                       SYMBOLS                      Page 17
  1061.  
  1062.  
  1063.         SYMBOLS
  1064.  
  1065.             o self - the current object (within a method context)
  1066.             o *obarray* - the object hash table
  1067.             o *standard-input* - the standard input stream
  1068.             o *standard-output* - the standard output stream
  1069.             o *error-output* - the error output stream
  1070.             o *trace-output* - the trace output stream
  1071.             o *debug-io* - the debug i/o stream
  1072.             o *breakenable* - flag controlling entering break loop on errors
  1073.             o *tracelist* - list of names of functions to trace
  1074.             o *tracenable* - enable trace back printout on errors
  1075.             o *tracelimit* - number of levels of trace back information
  1076.             o *evalhook* - user substitute for the evaluator function
  1077.             o *applyhook* - (not yet implemented)
  1078.             o *readtable* - the current readtable
  1079.             o *unbound* - indicator for unbound symbols
  1080.             o *gc-flag* - controls the printing of gc messages
  1081.             o *gc-hook* - function to call after garbage collection
  1082.             o *integer-format* - format for printing integers ("%d" or "%ld")
  1083.             o *float-format* - format for printing floats ("%g")
  1084.             o *print-case* - symbol output case (:upcase or :downcase)
  1085.  
  1086.         There are several symbols maintained by the read/eval/print
  1087.         loop.  The symbols '+', '++', and '+++' are bound to the most
  1088.         recent three input expressions.  The symbols '*', '**' and '***'
  1089.         are bound to the most recent three results.  The symbol '-' is
  1090.         bound to the expression currently being evaluated.  It becomes
  1091.         the value of '+' at the end of the evaluation.
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.         XLISP                 EVALUATION FUNCTIONS               Page 18
  1127.  
  1128.  
  1129.         EVALUATION FUNCTIONS
  1130.  
  1131.         (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  1132.             <expr>      the expression to be evaluated
  1133.             returns     the result of evaluating the expression
  1134.  
  1135.         (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  1136.             <fun>       the function to apply (or function symbol)
  1137.             <args>      the argument list
  1138.             returns     the result of applying the function to the arguments
  1139.  
  1140.         (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  1141.             <fun>       the function to call (or function symbol)
  1142.             <arg>       arguments to pass to the function
  1143.             returns     the result of calling the function with the arguments
  1144.  
  1145.         (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  1146.             <expr>      the expression to be quoted (quoted)
  1147.             returns     <expr> unevaluated
  1148.  
  1149.         (function <expr>)  GET THE FUNCTIONAL INTERPRETATION
  1150.             <expr>      the symbol or lambda expression (quoted)
  1151.             returns     the functional interpretation
  1152.  
  1153.         (backquote <expr>)  FILL IN A TEMPLATE
  1154.             <expr>      the template
  1155.             returns     a copy of the template with comma and comma-at
  1156.                         expressions expanded
  1157.  
  1158.         (lambda <args> <expr>...)  MAKE A FUNCTION CLOSURE
  1159.             <args>      formal argument list (lambda list) (quoted)
  1160.             <expr>      expressions of the function body
  1161.             returns     the function closure
  1162.  
  1163.         (get-lambda-expression <closure>)  GET THE LAMBDA EXPRESSION
  1164.             <closure>   the closure
  1165.             returns     the original lambda expression
  1166.  
  1167.         (macroexpand <form>)  RECURSIVELY EXPAND MACRO CALLS
  1168.             <form>      the form to expand
  1169.             returns     the macro expansion
  1170.  
  1171.         (macroexpand-1 <form>)  EXPAND A MACRO CALL
  1172.             <form>      the macro call form
  1173.             returns     the macro expansion
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.         XLISP                   SYMBOL FUNCTIONS                 Page 19
  1193.  
  1194.  
  1195.         SYMBOL FUNCTIONS
  1196.  
  1197.         (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  1198.             <sym>       the symbol being set
  1199.             <expr>      the new value
  1200.             returns     the new value
  1201.  
  1202.         (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  1203.             <sym>       the symbol being set (quoted)
  1204.             <expr>      the new value
  1205.             returns     the new value
  1206.  
  1207.         (psetq [<sym> <expr>]...)  PARALLEL VERSION OF SETQ
  1208.             <sym>       the symbol being set (quoted)
  1209.             <expr>      the new value
  1210.             returns     the new value
  1211.  
  1212.         (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  1213.             <place>     the field specifier (quoted):
  1214.                           <sym>                   set value of a symbol
  1215.                           (car <expr>)            set car of a cons node
  1216.                           (cdr <expr>)            set cdr of a cons node
  1217.                           (nth <n> <expr>)        set nth car of a list
  1218.                           (aref <expr> <n>)       set nth element of an array
  1219.                           (get <sym> <prop>)      set value of a property
  1220.                           (symbol-value <sym>)    set value of a symbol
  1221.                           (symbol-function <sym>) set functional value of a
  1222. symbol
  1223.                           (symbol-plist <sym>)    set property list of a symbol
  1224.             <value>     the new value
  1225.             returns     the new value
  1226.  
  1227.         (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION
  1228.         (defmacro <sym> <fargs> <expr>...)  DEFINE A MACRO
  1229.             <sym>       symbol being defined (quoted)
  1230.             <fargs>     formal argument list (lambda list) (quoted)
  1231.             <expr>      expressions constituting the body of the
  1232.                         function (quoted)
  1233.             returns     the function symbol
  1234.  
  1235.         (gensym [<tag>])  GENERATE A SYMBOL
  1236.             <tag>       string or number
  1237.             returns     the new symbol
  1238.  
  1239.         (intern <pname>)  MAKE AN INTERNED SYMBOL
  1240.             <pname>     the symbol's print name string
  1241.             returns     the new symbol
  1242.  
  1243.         (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  1244.             <pname>     the symbol's print name string
  1245.             returns     the new symbol
  1246.  
  1247.         (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  1248.             <sym>       the symbol
  1249.             returns     the symbol's print name
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.         XLISP                   SYMBOL FUNCTIONS                 Page 20
  1260.  
  1261.  
  1262.         (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  1263.             <sym>       the symbol
  1264.             returns     the symbol's value
  1265.  
  1266.         (symbol-function <sym>)  GET THE FUNCTIONAL VALUE OF A SYMBOL
  1267.             <sym>       the symbol
  1268.             returns     the symbol's functional value
  1269.  
  1270.         (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  1271.             <sym>       the symbol
  1272.             returns     the symbol's property list
  1273.  
  1274.         (hash <sym> <n>)  COMPUTE THE HASH INDEX FOR A SYMBOL
  1275.             <sym>       the symbol or string
  1276.             <n>         the table size (integer)
  1277.             returns     the hash index (integer)
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.         XLISP               PROPERTY LIST FUNCTIONS              Page 21
  1326.  
  1327.  
  1328.         PROPERTY LIST FUNCTIONS
  1329.  
  1330.         (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  1331.             <sym>       the symbol
  1332.             <prop>      the property symbol
  1333.             returns     the property value or nil
  1334.  
  1335.         (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  1336.             <sym>       the symbol
  1337.             <val>       the property value
  1338.             <prop>      the property symbol
  1339.             returns     the property value
  1340.  
  1341.         (remprop <sym> <prop>)  REMOVE A PROPERTY
  1342.             <sym>       the symbol
  1343.             <prop>      the property symbol
  1344.             returns     nil
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.         XLISP                   ARRAY FUNCTIONS                  Page 22
  1392.  
  1393.  
  1394.         ARRAY FUNCTIONS
  1395.  
  1396.         (aref <array> <n>)  GET THE NTH ELEMENT OF AN ARRAY
  1397.             <array>     the array
  1398.             <n>         the array index (integer)
  1399.             returns     the value of the array element
  1400.  
  1401.         (make-array <size>)  MAKE A NEW ARRAY
  1402.             <size>      the size of the new array (integer)
  1403.             returns     the new array
  1404.  
  1405.         (vector <expr>...)  MAKE AN INITIALIZED VECTOR
  1406.             <expr>      the vector elements
  1407.             returns     the new vector
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.         XLISP                    LIST FUNCTIONS                  Page 23
  1458.  
  1459.  
  1460.         LIST FUNCTIONS
  1461.  
  1462.         (car <expr>)  RETURN THE CAR OF A LIST NODE
  1463.             <expr>      the list node
  1464.             returns     the car of the list node
  1465.  
  1466.         (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  1467.             <expr>      the list node
  1468.             returns     the cdr of the list node
  1469.  
  1470.         (cxxr <expr>)  ALL CxxR COMBINATIONS
  1471.         (cxxxr <expr>)  ALL CxxxR COMBINATIONS
  1472.         (cxxxxr <expr>)  ALL CxxxxR COMBINATIONS
  1473.  
  1474.         (first <expr>)   A SYNONYM FOR CAR
  1475.         (second <expr>)  A SYNONYM FOR CADR
  1476.         (third <expr>)   A SYNONYM FOR CADDR
  1477.         (fourth <expr>)  A SYNONYM FOR CADDDR
  1478.         (rest <expr>)    A SYNONYM FOR CDR
  1479.  
  1480.         (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  1481.             <expr1>     the car of the new list node
  1482.             <expr2>     the cdr of the new list node
  1483.             returns     the new list node
  1484.  
  1485.         (list <expr>...)  CREATE A LIST OF VALUES
  1486.             <expr>      expressions to be combined into a list
  1487.             returns     the new list
  1488.  
  1489.         (append <expr>...)  APPEND LISTS
  1490.             <expr>      lists whose elements are to be appended
  1491.             returns     the new list
  1492.  
  1493.         (reverse <expr>)  REVERSE A LIST
  1494.             <expr>      the list to reverse
  1495.             returns     a new list in the reverse order
  1496.  
  1497.         (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  1498.             <list>      the list
  1499.             returns     the last list node in the list
  1500.  
  1501.         (member <expr> <list> &key :test :test-not)  FIND AN EXPRESSION IN A
  1502. LIST
  1503.             <expr>      the expression to find
  1504.             <list>      the list to search
  1505.             :test       the test function (defaults to eql)
  1506.             :test-not   the test function (sense inverted)
  1507.             returns     the remainder of the list starting with the expression
  1508.  
  1509.         (assoc <expr> <alist> &key :test :test-not)  FIND AN EXPRESSION IN AN
  1510. A-LIST
  1511.             <expr>      the expression to find
  1512.             <alist>     the association list
  1513.             :test       the test function (defaults to eql)
  1514.             :test-not   the test function (sense inverted)
  1515.             returns     the alist entry or nil
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.         XLISP                    LIST FUNCTIONS                  Page 24
  1526.  
  1527.  
  1528.         (remove <expr> <list> &key :test :test-not)  REMOVE ELEMENTS FROM A
  1529. LIST
  1530.             <expr>      the element to remove
  1531.             <list>      the list
  1532.             :test       the test function (defaults to eql)
  1533.             :test-not   the test function (sense inverted)
  1534.             returns     copy of list with matching expressions removed
  1535.  
  1536.         (remove-if <test> <list>)  REMOVE ELEMENTS THAT PASS TEST
  1537.             <test>      the test predicate
  1538.             <list>      the list
  1539.             returns     copy of list with matching elements removed
  1540.  
  1541.         (remove-if-not <test> <list>)  REMOVE ELEMENTS THAT FAIL TEST
  1542.             <test>      the test predicate
  1543.             <list>      the list
  1544.             returns     copy of list with non-matching elements removed
  1545.  
  1546.         (length <expr>)  FIND THE LENGTH OF A LIST, VECTOR OR STRING
  1547.             <expr>      the list, vector or string
  1548.             returns     the length of the list, vector or string
  1549.  
  1550.         (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  1551.             <n>         the number of the element to return (zero origin)
  1552.             <list>      the list
  1553.             returns     the nth element or nil if the list isn't that long
  1554.  
  1555.         (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  1556.             <n>         the number of the element to return (zero origin)
  1557.             <list>      the list
  1558.             returns     the nth cdr or nil if the list isn't that long
  1559.  
  1560.         (mapc <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1561.             <fcn>       the function or function name
  1562.             <listn>     a list for each argument of the function
  1563.             returns     the first list of arguments
  1564.  
  1565.         (mapcar <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1566.             <fcn>       the function or function name
  1567.             <listn>     a list for each argument of the function
  1568.             returns     a list of the values returned
  1569.  
  1570.         (mapl <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1571.             <fcn>       the function or function name
  1572.             <listn>     a list for each argument of the function
  1573.             returns     the first list of arguments
  1574.  
  1575.         (maplist <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1576.             <fcn>       the function or function name
  1577.             <listn>     a list for each argument of the function
  1578.             returns     a list of the values returned
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.         XLISP                    LIST FUNCTIONS                  Page 25
  1593.  
  1594.  
  1595.         (subst <to> <from> <expr> &key :test :test-not)  SUBSTITUTE EXPRESSIONS
  1596.             <to>        the new expression
  1597.             <from>      the old expression
  1598.             <expr>      the expression in which to do the substitutions
  1599.             :test       the test function (defaults to eql)
  1600.             :test-not   the test function (sense inverted)
  1601.             returns     the expression with substitutions
  1602.  
  1603.         (sublis <alist> <expr> &key :test :test-not)  SUBSTITUTE WITH AN A-LIST
  1604.             <alist>     the association list
  1605.             <expr>      the expression in which to do the substitutions
  1606.             :test       the test function (defaults to eql)
  1607.             :test-not   the test function (sense inverted)
  1608.             returns     the expression with substitutions
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.         XLISP              DESTRUCTIVE LIST FUNCTIONS            Page 26
  1618.  
  1619.  
  1620.         DESTRUCTIVE LIST FUNCTIONS
  1621.  
  1622.         (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  1623.             <list>      the list node
  1624.             <expr>      the new value for the car of the list node
  1625.             returns     the list node after updating the car
  1626.  
  1627.         (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  1628.             <list>      the list node
  1629.             <expr>      the new value for the cdr of the list node
  1630.             returns     the list node after updating the cdr
  1631.  
  1632.         (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  1633.             <list>      lists to concatenate
  1634.             returns     the result of concatenating the lists
  1635.  
  1636.         (delete <expr> &key :test :test-not)  DELETE ELEMENTS FROM A LIST
  1637.             <expr>      the element to delete
  1638.             <list>      the list
  1639.             :test       the test function (defaults to eql)
  1640.             :test-not   the test function (sense inverted)
  1641.             returns     the list with the matching expressions deleted
  1642.  
  1643.         (delete-if <test> <list>)  DELETE ELEMENTS THAT PASS TEST
  1644.             <test>      the test predicate
  1645.             <list>      the list
  1646.             returns     the list with matching elements deleted
  1647.  
  1648.         (delete-if-not <test> <list>)  DELETE ELEMENTS THAT FAIL TEST
  1649.             <test>      the test predicate
  1650.             <list>      the list
  1651.             returns     the list with non-matching elements deleted
  1652.  
  1653.         (sort <list> <test>)  SORT A LIST
  1654.             <list>      the list to sort
  1655.             <test>      the comparison function
  1656.             returns     the sorted list
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.         XLISP                 PREDICATE FUNCTIONS                Page 27
  1684.  
  1685.  
  1686.         PREDICATE FUNCTIONS
  1687.  
  1688.         (atom <expr>)  IS THIS AN ATOM?
  1689.             <expr>      the expression to check
  1690.             returns     t if the value is an atom, nil otherwise
  1691.  
  1692.         (symbolp <expr>)  IS THIS A SYMBOL?
  1693.             <expr>      the expression to check
  1694.             returns     t if the expression is a symbol, nil otherwise
  1695.  
  1696.         (numberp <expr>)  IS THIS A NUMBER?
  1697.             <expr>      the expression to check
  1698.             returns     t if the expression is a number, nil otherwise
  1699.  
  1700.         (null <expr>)  IS THIS AN EMPTY LIST?
  1701.             <expr>      the list to check
  1702.             returns     t if the list is empty, nil otherwise
  1703.  
  1704.         (not <expr>)  IS THIS FALSE?
  1705.             <expr>      the expression to check
  1706.             return      t if the value is nil, nil otherwise
  1707.  
  1708.         (listp <expr>)  IS THIS A LIST?
  1709.             <expr>      the expression to check
  1710.             returns     t if the value is a cons or nil, nil otherwise
  1711.  
  1712.         (endp <list>)  IS THIS THE END OF A LIST
  1713.             <list>      the list
  1714.             returns     t if the value is nil, nil otherwise
  1715.  
  1716.         (consp <expr>)  IS THIS A NON-EMPTY LIST?
  1717.             <expr>      the expression to check
  1718.             returns     t if the value is a cons, nil otherwise
  1719.  
  1720.         (integerp <expr>)  IS THIS AN INTEGER?
  1721.             <expr>      the expression to check
  1722.             returns     t if the value is an integer, nil otherwise
  1723.  
  1724.         (floatp <expr>)  IS THIS A FLOAT?
  1725.             <expr>      the expression to check
  1726.             returns     t if the value is a float, nil otherwise
  1727.  
  1728.         (stringp <expr>)  IS THIS A STRING?
  1729.             <expr>      the expression to check
  1730.             returns     t if the value is a string, nil otherwise
  1731.  
  1732.         (characterp <expr>)  IS THIS A CHARACTER?
  1733.             <expr>      the expression to check
  1734.             returns     t if the value is a character, nil otherwise
  1735.  
  1736.         (arrayp <expr>)  IS THIS AN ARRAY?
  1737.             <expr>      the expression to check
  1738.             returns     t if the value is an array, nil otherwise
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.         XLISP                 PREDICATE FUNCTIONS                Page 28
  1750.  
  1751.  
  1752.         (streamp <expr>)  IS THIS A STREAM?
  1753.             <expr>      the expression to check
  1754.             returns     t if the value is a stream, nil otherwise
  1755.  
  1756.         (objectp <expr>)  IS THIS AN OBJECT?
  1757.             <expr>      the expression to check
  1758.             returns     t if the value is an object, nil otherwise
  1759.  
  1760.         (boundp <sym>)  IS A VALUE BOUND TO THIS SYMBOL?
  1761.             <sym>       the symbol
  1762.             returns     t if a value is bound to the symbol, nil otherwise
  1763.  
  1764.         (fboundp <sym>)  IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
  1765.             <sym>       the symbol
  1766.             returns     t if a functional value is bound to the symbol,
  1767.                         nil otherwise
  1768.  
  1769.         (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  1770.             <expr>      the number to test
  1771.             returns     t if the number is negative, nil otherwise
  1772.  
  1773.         (zerop <expr>)  IS THIS NUMBER ZERO?
  1774.             <expr>      the number to test
  1775.             returns     t if the number is zero, nil otherwise
  1776.  
  1777.         (plusp <expr>)  IS THIS NUMBER POSITIVE?
  1778.             <expr>      the number to test
  1779.             returns     t if the number is positive, nil otherwise
  1780.  
  1781.         (evenp <expr>)  IS THIS INTEGER EVEN?
  1782.             <expr>      the integer to test
  1783.             returns     t if the integer is even, nil otherwise
  1784.  
  1785.         (oddp <expr>)  IS THIS INTEGER ODD?
  1786.             <expr>      the integer to test
  1787.             returns     t if the integer is odd, nil otherwise
  1788.  
  1789.         (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1790.             <expr1>     the first expression
  1791.             <expr2>     the second expression
  1792.             returns     t if they are equal, nil otherwise
  1793.  
  1794.         (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1795.                                 (WORKS WITH ALL NUMBERS)
  1796.             <expr1>     the first expression
  1797.             <expr2>     the second expression
  1798.             returns     t if they are equal, nil otherwise
  1799.  
  1800.         (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1801.             <expr1>     the first expression
  1802.             <expr2>     the second expression
  1803.             returns     t if they are equal, nil otherwise
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.         XLISP                  CONTROL CONSTRUCTS                Page 29
  1816.  
  1817.  
  1818.         CONTROL CONSTRUCTS
  1819.  
  1820.         (cond <pair>...)  EVALUATE CONDITIONALLY
  1821.             <pair>      pair consisting of:
  1822.                             (<pred> <expr>...)
  1823.                           where
  1824.                             <pred>      is a predicate expression
  1825.                             <expr>      evaluated if the predicate
  1826.                                         is not nil
  1827.             returns     the value of the first expression whose predicate
  1828.                         is not nil
  1829.  
  1830.         (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1831.             <expr>      the expressions to be ANDed
  1832.             returns     nil if any expression evaluates to nil,
  1833.                         otherwise the value of the last expression
  1834.                         (evaluation of expressions stops after the first
  1835.                          expression that evaluates to nil)
  1836.  
  1837.         (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1838.             <expr>      the expressions to be ORed
  1839.             returns     nil if all expressions evaluate to nil,
  1840.                         otherwise the value of the first non-nil expression
  1841.                         (evaluation of expressions stops after the first
  1842.                          expression that does not evaluate to nil)
  1843.  
  1844.         (if <texpr> <expr1> [<expr2>])  EVALUATE EXPRESSIONS CONDITIONALLY
  1845.             <texpr>     the test expression
  1846.             <expr1>     the expression to be evaluated if texpr is non-nil
  1847.             <expr2>     the expression to be evaluated if texpr is nil
  1848.             returns     the value of the selected expression
  1849.  
  1850.         (when <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS TRUE
  1851.             <texpr>     the test expression
  1852.             <expr>      the expression(s) to be evaluted if texpr is non-nil
  1853.             returns     the value of the last expression or nil
  1854.  
  1855.         (unless <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS FALSE
  1856.             <texpr>     the test expression
  1857.             <expr>      the expression(s) to be evaluated if texpr is nil
  1858.             returns     the value of the last expression or nil
  1859.  
  1860.           (case <expr> <case>...)  SELECT BY CASE
  1861.             <expr>      the selection expression
  1862.             <case>      pair consisting of:
  1863.                             (<value> <expr>...)
  1864.                           where:
  1865.                             <value>     is a single expression or a list of
  1866.                                         expressions (unevaluated)
  1867.                             <expr>      are expressions to execute if the
  1868.                                         case matches
  1869.             returns     the value of the last expression of the matching case
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.         XLISP                  CONTROL CONSTRUCTS                Page 30
  1882.  
  1883.  
  1884.         (let (<binding>...) <expr>...)  CREATE LOCAL BINDINGS
  1885.         (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  1886.             <binding>   the variable bindings each of which is either:
  1887.                         1)  a symbol (which is initialized to nil)
  1888.                         2)  a list whose car is a symbol and whose cadr
  1889.                                 is an initialization expression
  1890.             <expr>      the expressions to be evaluated
  1891.             returns     the value of the last expression
  1892.  
  1893.         (flet (<binding>...) <expr>...)  CREATE LOCAL FUNCTIONS
  1894.         (labels (<binding>...) <expr>...)  FLET WITH RECURSIVE FUNCTIONS
  1895.         (macrolet (<binding>...) <expr>...)  CREATE LOCAL MACROS
  1896.             <binding>   the function bindings each of which is:
  1897.                           (<sym> <fargs> <expr>...)
  1898.                         where:
  1899.                             <sym>       the function/macro name
  1900.                             <fargs>     formal argument list (lambda list)
  1901.                             <expr>      expressions constituting the body of
  1902.                                         the function/macro
  1903.             <expr>      the expressions to be evaluated
  1904.             returns     the value of the last expression
  1905.  
  1906.         (catch <sym> <expr>...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  1907.             <sym>       the catch tag
  1908.             <expr>      expressions to evaluate
  1909.             returns     the value of the last expression the throw expression
  1910.  
  1911.         (throw <sym> [<expr>])  THROW TO A CATCH
  1912.             <sym>       the catch tag
  1913.             <expr>      the value for the catch to return (defaults to nil)
  1914.             returns     never returns
  1915.  
  1916.         (unwind-protect <expr> <cexpr>...)  PROTECT EVALUATION OF AN EXPRESSION
  1917.             <expr>      the expression to protect
  1918.             <cexpr>     the cleanup expressions
  1919.             returns     the value of the expression
  1920.           Note:  unwind-protect guarantees to execute the cleanup expressions
  1921.                  even if a non-local exit terminates the evaluation of the
  1922.                  protected expression
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.         XLISP                  LOOPING CONSTRUCTS                Page 31
  1948.  
  1949.  
  1950.         LOOPING CONSTRUCTS
  1951.  
  1952.         (loop <expr>...)  BASIC LOOPING FORM
  1953.             <expr>      the body of the loop
  1954.             returns     never returns (must use non-local exit)
  1955.  
  1956.         (do (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1957.         (do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1958.             <binding>   the variable bindings each of which is either:
  1959.                         1)  a symbol (which is initialized to nil)
  1960.                         2)  a list of the form: (<sym> <init> [<step>])
  1961.                             where:
  1962.                                 <sym>  is the symbol to bind
  1963.                                 <init> is the initial value of the symbol
  1964.                                 <step> is a step expression
  1965.             <texpr>     the termination test expression
  1966.             <rexpr>     result expressions (the default is nil)
  1967.             <expr>      the body of the loop (treated like an implicit prog)
  1968.             returns     the value of the last result expression
  1969.  
  1970.         (dolist (<sym> <expr> [<rexpr>]) <expr>...)  LOOP THROUGH A LIST
  1971.             <sym>       the symbol to bind to each list element
  1972.             <expr>      the list expression
  1973.             <rexpr>     the result expression (the default is nil)
  1974.             <expr>      the body of the loop (treated like an implicit prog)
  1975.  
  1976.         (dotimes (<sym> <expr> [<rexpr>]) <expr>...)  LOOP FROM ZERO TO N-1
  1977.             <sym>       the symbol to bind to each value from 0 to n-1
  1978.             <expr>      the number of times to loop
  1979.             <rexpr>     the result expression (the default is nil)
  1980.             <expr>      the body of the loop (treated like an implicit prog)
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.         XLISP                 THE PROGRAM FEATURE                Page 32
  2014.  
  2015.  
  2016.         THE PROGRAM FEATURE
  2017.  
  2018.         (prog (<binding>...) <expr>...)  THE PROGRAM FEATURE
  2019.         (prog* (<binding>...) <expr>...)  PROG WITH SEQUENTIAL BINDING
  2020.             <binding>   the variable bindings each of which is either:
  2021.                         1)  a symbol (which is initialized to nil)
  2022.                         2)  a list whose car is a symbol and whose cadr
  2023.                                 is an initialization expression
  2024.             <expr>      expressions to evaluate or tags (symbols)
  2025.             returns     nil or the argument passed to the return function
  2026.  
  2027.         (block <name> <expr>...)  NAMED BLOCK
  2028.             <name>      the block name (symbol)
  2029.             <expr>      the block body
  2030.             returns     the value of the last expression
  2031.  
  2032.         (return [<expr>])  CAUSE A PROG CONSTRUCT TO RETURN A VALUE
  2033.             <expr>      the value (defaults to nil)
  2034.             returns     never returns
  2035.  
  2036.         (return-from <name> [<value>])  RETURN FROM A NAMED BLOCK
  2037.             <name>      the block name (symbol)
  2038.             <value>     the value to return (defaults to nil)
  2039.             returns     never returns
  2040.  
  2041.         (tagbody <expr>...)  BLOCK WITH LABELS
  2042.             <expr>      expression(s) to evaluate or tags (symbols)
  2043.             returns     nil
  2044.  
  2045.         (go <sym>)  GO TO A TAG WITHIN A TAGBODY OR PROG
  2046.             <sym>       the tag (quoted)
  2047.             returns     never returns
  2048.  
  2049.         (progv <slist> <vlist> <expr>...)  DYNAMICALLY BIND SYMBOLS
  2050.             <slist>     list of symbols
  2051.             <vlist>     list of values to bind to the symbols
  2052.             <expr>      expression(s) to evaluate
  2053.             returns     the value of the last expression
  2054.  
  2055.         (prog1 <expr1> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2056.             <expr1>     the first expression to evaluate
  2057.             <expr>      the remaining expressions to evaluate
  2058.             returns     the value of the first expression
  2059.  
  2060.         (prog2 <expr1> <expr2> <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2061.             <expr1>     the first expression to evaluate
  2062.             <expr2>     the second expression to evaluate
  2063.             <expr>      the remaining expressions to evaluate
  2064.             returns     the value of the second expression
  2065.  
  2066.         (progn <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  2067.             <expr>      the expressions to evaluate
  2068.             returns     the value of the last expression (or nil)
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.         XLISP             DEBUGGING AND ERROR HANDLING           Page 33
  2080.  
  2081.  
  2082.         DEBUGGING AND ERROR HANDLING
  2083.  
  2084.         (trace <sym>)  ADD A FUNCTION TO THE TRACE LIST
  2085.             <sym>       the function to add (quoted)
  2086.             returns     the trace list
  2087.  
  2088.         (untrace <sym>)  REMOVE A FUNCTION FROM THE TRACE LIST
  2089.             <sym>       the function to remove (quoted)
  2090.             returns     the trace list
  2091.  
  2092.         (error <emsg> [<arg>])  SIGNAL A NON-CORRECTABLE ERROR
  2093.             <emsg>      the error message string
  2094.             <arg>       the argument expression (printed after the message)
  2095.             returns     never returns
  2096.  
  2097.         (cerror <cmsg> <emsg> [<arg>])  SIGNAL A CORRECTABLE ERROR
  2098.             <cmsg>      the continue message string
  2099.             <emsg>      the error message string
  2100.             <arg>       the argument expression (printed after the message)
  2101.             returns     nil when continued from the break loop
  2102.  
  2103.         (break [<bmsg> [<arg>]])  ENTER A BREAK LOOP
  2104.             <bmsg>      the break message string (defaults to "**BREAK**")
  2105.             <arg>       the argument expression (printed after the message)
  2106.             returns     nil when continued from the break loop
  2107.  
  2108.         (clean-up)  CLEAN-UP AFTER AN ERROR
  2109.             returns     never returns
  2110.  
  2111.         (top-level)  CLEAN-UP AFTER AN ERROR AND RETURN TO THE TOP LEVEL
  2112.             returns     never returns
  2113.  
  2114.         (continue)  CONTINUE FROM A CORRECTABLE ERROR
  2115.             returns     never returns
  2116.  
  2117.         (errset <expr> [<pflag>])  TRAP ERRORS
  2118.             <expr>      the expression to execute
  2119.             <pflag>     flag to control printing of the error message
  2120.             returns     the value of the last expression consed with nil
  2121.                         or nil on error
  2122.  
  2123.         (baktrace [<n>])  PRINT N LEVELS OF TRACE BACK INFORMATION
  2124.             <n>         the number of levels (defaults to all levels)
  2125.             returns     nil
  2126.  
  2127.         (evalhook <expr> <ehook> <ahook> [<env>])  EVALUATE WITH HOOKS
  2128.             <expr>      the expression to evaluate
  2129.             <ehook>     the value for *evalhook*
  2130.             <ahook>     the value for *applyhook*
  2131.             <env>       the environment (default is nil)
  2132.             returns     the result of evaluating the expression
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.         XLISP                 ARITHMETIC FUNCTIONS               Page 34
  2146.  
  2147.  
  2148.         ARITHMETIC FUNCTIONS
  2149.  
  2150.         (truncate <expr>)  TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
  2151.             <expr>      the number
  2152.             returns     the result of truncating the number
  2153.  
  2154.         (float <expr>)  CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
  2155.             <expr>      the number
  2156.             returns     the result of floating the integer
  2157.  
  2158.         (+ <expr>...)  ADD A LIST OF NUMBERS
  2159.             <expr>      the numbers
  2160.             returns     the result of the addition
  2161.  
  2162.         (- <expr>...)  SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
  2163.             <expr>      the numbers
  2164.             returns     the result of the subtraction
  2165.  
  2166.         (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  2167.             <expr>      the numbers
  2168.             returns     the result of the multiplication
  2169.  
  2170.         (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  2171.             <expr>      the numbers
  2172.             returns     the result of the division
  2173.  
  2174.         (1+ <expr>)  ADD ONE TO A NUMBER
  2175.             <expr>      the number
  2176.             returns     the number plus one
  2177.  
  2178.         (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  2179.             <expr>      the number
  2180.             returns     the number minus one
  2181.  
  2182.         (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  2183.             <expr>      the numbers
  2184.             returns     the result of the remainder operation
  2185.  
  2186.         (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  2187.             <expr>      the expressions to be checked
  2188.             returns     the smallest number in the list
  2189.  
  2190.         (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  2191.             <expr>      the expressions to be checked
  2192.             returns     the largest number in the list
  2193.  
  2194.         (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  2195.             <expr>      the number
  2196.             returns     the absolute value of the number
  2197.  
  2198.         (gcd <n1> <n2>...)  COMPUTE THE GREATEST COMMON DIVISOR
  2199.             <n1>        the first number (integer)
  2200.             <n2>        the second number(s) (integer)
  2201.             returns     the greatest common divisor
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.         XLISP                 ARITHMETIC FUNCTIONS               Page 35
  2212.  
  2213.  
  2214.         (random <n>)  COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
  2215.             <n>         the upper bound (integer)
  2216.             returns     a random number
  2217.  
  2218.         (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  2219.             <expr>      the floating point number
  2220.             returns     the sine of the number
  2221.  
  2222.         (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  2223.             <expr>      the floating point number
  2224.             returns     the cosine of the number
  2225.  
  2226.         (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  2227.             <expr>      the floating point number
  2228.             returns     the tangent of the number
  2229.  
  2230.         (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  2231.             <x-expr>    the floating point number
  2232.             <y-expr>    the floating point exponent
  2233.             returns     x to the y power
  2234.  
  2235.         (exp <x-expr>)  COMPUTE E TO THE X POWER
  2236.             <x-expr>    the floating point number
  2237.             returns     e to the x power
  2238.  
  2239.         (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  2240.             <expr>      the floating point number
  2241.             returns     the square root of the number
  2242.  
  2243.         (< <n1> <n2>...)  TEST FOR LESS THAN
  2244.         (<= <n1> <n2>...)  TEST FOR LESS THAN OR EQUAL TO
  2245.         (= <n1> <n2>...)  TEST FOR EQUAL TO
  2246.         (/= <n1> <n2>...)  TEST FOR NOT EQUAL TO
  2247.         (>= <n1> <n2>...)  TEST FOR GREATER THAN OR EQUAL TO
  2248.         (> <n1> <n2>...)  TEST FOR GREATER THAN
  2249.             <n1>        the first number to compare
  2250.             <n2>        the second number to compare
  2251.             returns     the result of comparing <n1> with <n2>...
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.         XLISP              BITWISE LOGICAL FUNCTIONS             Page 36
  2278.  
  2279.  
  2280.         BITWISE LOGICAL FUNCTIONS
  2281.  
  2282.         (logand <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  2283.             <expr>      the numbers
  2284.             returns     the result of the and operation
  2285.  
  2286.         (logior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  2287.             <expr>      the numbers
  2288.             returns     the result of the inclusive or operation
  2289.  
  2290.         (logxor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  2291.             <expr>      the numbers
  2292.             returns     the result of the exclusive or operation
  2293.  
  2294.         (lognot <expr>)  THE BITWISE NOT OF A NUMBER
  2295.             <expr>      the number
  2296.             returns     the bitwise inversion of number
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.  
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.  
  2335.  
  2336.  
  2337.  
  2338.  
  2339.  
  2340.  
  2341.  
  2342.  
  2343.         XLISP                   STRING FUNCTIONS                 Page 37
  2344.  
  2345.  
  2346.         STRING FUNCTIONS
  2347.  
  2348.         (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  2349.             <expr>      the integer
  2350.             returns     a one character string
  2351.  
  2352.         (string-trim <bag> <str>)  TRIM BOTH ENDS OF A STRING
  2353.             <bag>       a string containing characters to trim
  2354.             <str>       the string to trim
  2355.             returns     a trimed copy of the string
  2356.  
  2357.         (string-left-trim <bag> <str>)  TRIM THE LEFT END OF A STRING
  2358.             <bag>       a string containing characters to trim
  2359.             <str>       the string to trim
  2360.             returns     a trimed copy of the string
  2361.  
  2362.         (string-right-trim <bag> <str>)  TRIM THE RIGHT END OF A STRING
  2363.             <bag>       a string containing characters to trim
  2364.             <str>       the string to trim
  2365.             returns     a trimed copy of the string
  2366.  
  2367.         (string-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2368.             <str>       the string
  2369.             :start      the starting offset
  2370.             :end        the ending offset + 1
  2371.             returns     a converted copy of the string
  2372.  
  2373.         (string-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2374.             <str>       the string
  2375.             :start      the starting offset
  2376.             :end        the ending offset + 1
  2377.             returns     a converted copy of the string
  2378.  
  2379.         (nstring-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2380.             <str>       the string
  2381.             :start      the starting offset
  2382.             :end        the ending offset + 1
  2383.             returns     the converted string (not a copy)
  2384.  
  2385.         (nstring-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2386.             <str>       the string
  2387.             :start      the starting offset
  2388.             :end        the ending offset + 1
  2389.             returns     the converted string (not a copy)
  2390.  
  2391.         (strcat <expr>...)  CONCATENATE STRINGS
  2392.             <expr>      the strings to concatenate
  2393.             returns     the result of concatenating the strings
  2394.  
  2395.         (subseq <string> <start> [<end>]) EXTRACT A SUBSTRING
  2396.             <string>    the string
  2397.             <start>     the starting position (zero origin)
  2398.             <end>       the ending position + 1 (defaults to end)
  2399.             returns     substring between <start> and <end>
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.         XLISP                   STRING FUNCTIONS                 Page 38
  2410.  
  2411.  
  2412.         (string< <str1> <str2> &key :start1 :end1 :start2 :end2)
  2413.         (string<= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2414.         (string= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2415.         (string/= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2416.         (string>= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2417.         (string> <str1> <str2> &key :start1 :end1 :start2 :end2)
  2418.             <str1>      the first string to compare
  2419.             <str2>      the second string to compare
  2420.             :start1     first substring starting offset
  2421.             :end1       first substring ending offset + 1
  2422.             :start2     second substring starting offset
  2423.             :end2       second substring ending offset + 1
  2424.             returns     t if predicate is true, nil otherwise
  2425.           Note: case is significant with these comparison functions.
  2426.  
  2427.         (string-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2428.         (string-not-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2429.         (string-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2430.         (string-not-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2431.         (string-not-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2432.         (string-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2433.             <str1>      the first string to compare
  2434.             <str2>      the second string to compare
  2435.             :start1     first substring starting offset
  2436.             :end1       first substring ending offset + 1
  2437.             :start2     second substring starting offset
  2438.             :end2       second substring ending offset + 1
  2439.             returns     t if predicate is true, nil otherwise
  2440.           Note: case is not significant with these comparison functions.
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.         XLISP                 CHARACTER FUNCTIONS                Page 39
  2476.  
  2477.  
  2478.         CHARACTER FUNCTIONS
  2479.  
  2480.         (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  2481.             <string>    the string
  2482.             <index>     the string index (zero relative)
  2483.             returns     the ascii code of the character
  2484.  
  2485.         (upper-case-p <chr>)  IS THIS AN UPPER CASE CHARACTER?
  2486.             <chr>       the character
  2487.             returns     true if the character is upper case, nil otherwise
  2488.  
  2489.         (lower-case-p <chr>)  IS THIS A LOWER CASE CHARACTER?
  2490.             <chr>       the character
  2491.             returns     true if the character is lower case, nil otherwise
  2492.  
  2493.         (both-case-p <chr>)  IS THIS AN ALPHABETIC (EITHER CASE) CHARACTER?
  2494.             <chr>       the character
  2495.             returns     true if the character is alphabetic, nil otherwise
  2496.  
  2497.         (digit-char-p <chr>)  IS THIS A DIGIT CHARACTER?
  2498.             <chr>       the character
  2499.             returns     the digit weight if character is a digit, nil otherwise
  2500.  
  2501.         (char-code <chr>)  GET THE ASCII CODE OF A CHARACTER
  2502.             <chr>       the character
  2503.             returns     the ASCII character code (integer)
  2504.  
  2505.         (code-char <code>)  GET THE CHARACTER WITH A SPECFIED ASCII CODE
  2506.             <code>      the ASCII code (integer)
  2507.             returns     the character with that code or nil
  2508.  
  2509.         (char-upcase <chr>)  CONVERT A CHARACTER TO UPPER CASE
  2510.             <chr>       the character
  2511.             returns     the upper case character
  2512.  
  2513.         (char-downcase <chr>)  CONVERT A CHARACTER TO LOWER CASE
  2514.             <chr>       the character
  2515.             returns     the lower case character
  2516.  
  2517.         (digit-char <n>)  CONVERT A DIGIT WEIGHT TO A DIGIT
  2518.             <n>         the digit weight (integer)
  2519.             returns     the digit character or nil
  2520.  
  2521.         (char-int <chr>) CONVERT A CHARACTER TO AN INTEGER
  2522.             <chr>       the character
  2523.             returns     the ASCII character code
  2524.  
  2525.         (int-char <int>) CONVERT AN INTEGER TO A CHARACTER
  2526.             <int>       the ASCII character code
  2527.             returns     the character with that code
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.         XLISP                 CHARACTER FUNCTIONS                Page 40
  2542.  
  2543.  
  2544.         (char< <chr1> <chr2>...)
  2545.         (char<= <chr1> <chr2>...)
  2546.         (char= <chr1> <chr2>...)
  2547.         (char/= <chr1> <chr2>...)
  2548.         (char>= <chr1> <chr2>...)
  2549.         (char> <chr1> <chr2>...)
  2550.             <chr1>      the first character to compare
  2551.             <chr2>      the second character(s) to compare
  2552.             returns     t if predicate is true, nil otherwise
  2553.           Note: case is significant with these comparison functions.
  2554.  
  2555.         (char-lessp <chr1> <chr2>...)
  2556.         (char-not-greaterp <chr1> <chr2>...)
  2557.         (char-equalp <chr1> <chr2>...)
  2558.         (char-not-equalp <chr1> <chr2>...)
  2559.         (char-not-lessp <chr1> <chr2>...)
  2560.         (char-greaterp <chr1> <chr2>...)
  2561.             <chr1>      the first string to compare
  2562.             <chr2>      the second string(s) to compare
  2563.             returns     t if predicate is true, nil otherwise
  2564.           Note: case is not significant with these comparison functions.
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.         XLISP                INPUT/OUTPUT FUNCTIONS              Page 41
  2608.  
  2609.  
  2610.         INPUT/OUTPUT FUNCTIONS
  2611.  
  2612.         (read [<stream> [<eof> [<rflag>]]])  READ AN EXPRESSION
  2613.             <stream>    the input stream (default is standard input)
  2614.             <eof>       the value to return on end of file (default is nil)
  2615.             <rflag>     recursive read flag (default is nil)
  2616.             returns     the expression read
  2617.  
  2618.         (print <expr> [<stream>])  PRINT AN EXPRESSION ON A NEW LINE
  2619.             <expr>      the expression to be printed
  2620.             <stream>    the output stream (default is standard output)
  2621.             returns     the expression
  2622.  
  2623.         (prin1 <expr> [<stream>])  PRINT AN EXPRESSION
  2624.             <expr>      the expression to be printed
  2625.             <stream>    the output stream (default is standard output)
  2626.             returns     the expression
  2627.  
  2628.         (princ <expr> [<stream>])  PRINT AN EXPRESSION WITHOUT QUOTING
  2629.             <expr>      the expressions to be printed
  2630.             <stream>    the output stream (default is standard output)
  2631.             returns     the expression
  2632.  
  2633.         (pprint <expr> [<stream>])  PRETTY PRINT AN EXPRESSION
  2634.             <expr>      the expressions to be printed
  2635.             <stream>    the output stream (default is standard output)
  2636.             returns     the expression
  2637.  
  2638.         (terpri [<stream>])  TERMINATE THE CURRENT PRINT LINE
  2639.             <stream>    the output stream (default is standard output)
  2640.             returns     nil
  2641.  
  2642.         (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  2643.             <expr>      the expression
  2644.             returns     the length
  2645.  
  2646.         (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  2647.             <expr>      the expression
  2648.             returns     the length
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.         XLISP                 THE FORMAT FUNCTION                Page 42
  2674.  
  2675.  
  2676.         THE FORMAT FUNCTION
  2677.  
  2678.         (format <stream> <fmt> <arg>...)  DO FORMATTED OUTPUT
  2679.             <stream>    the output stream
  2680.             <fmt>       the format string
  2681.             <arg>       the format arguments
  2682.             returns     output string if <stream> is nil, nil otherwise
  2683.  
  2684.         The format string can contain characters that should be copied
  2685.         directly to the output and formatting directives.  The
  2686.         formatting directives are:
  2687.  
  2688.             ~A          print next argument using princ
  2689.             ~S          print next argument using prin1
  2690.             ~%          start a new line
  2691.             ~~          print a tilde character
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.         XLISP                  FILE I/O FUNCTIONS                Page 43
  2740.  
  2741.  
  2742.         FILE I/O FUNCTIONS
  2743.  
  2744.         (open <fname> &key :direction)  OPEN A FILE STREAM
  2745.             <fname>     the file name string or symbol
  2746.             :direction  :input or :output (default is :input)
  2747.             returns     a stream
  2748.  
  2749.         (close <stream>)  CLOSE A FILE STREAM
  2750.             <stream>    the stream
  2751.             returns     nil
  2752.  
  2753.         (read-char [<stream>])  READ A CHARACTER FROM A STREAM
  2754.             <stream>    the input stream (default is standard input)
  2755.             returns     the character
  2756.  
  2757.         (peek-char [<flag> [<stream>]])  PEEK AT THE NEXT CHARACTER
  2758.             <flag>      flag for skipping white space (default is nil)
  2759.             <stream>    the input stream (default is standard input)
  2760.             returns     the character (integer)
  2761.  
  2762.         (write-char <ch> [<stream>])  WRITE A CHARACTER TO A STREAM
  2763.             <ch>        the character to write
  2764.             <stream>    the output stream (default is standard output)
  2765.             returns     the character
  2766.  
  2767.         (read-line [<stream>])  READ A LINE FROM A STREAM
  2768.             <stream>    the input stream (default is standard input)
  2769.             returns     the string
  2770.  
  2771.         (read-byte [<stream>])  READ A BYTE FROM A STREAM
  2772.             <stream>    the input stream (default is standard input)
  2773.             returns     the byte (integer)
  2774.  
  2775.         (write-byte <byte> [<stream>])  WRITE A BYTE TO A STREAM
  2776.             <byte>      the byte to write (integer)
  2777.             <stream>    the output stream (default is standard output)
  2778.             returns     the byte (integer)
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.         XLISP               STRING STREAM FUNCTIONS              Page 44
  2806.  
  2807.  
  2808.         STRING STREAM FUNCTIONS
  2809.  
  2810.         These functions operate on unnamed streams.  An unnamed output
  2811.         stream collects characters sent to it when it is used as the
  2812.         destination of any output function.  The functions 'get-output-
  2813.         stream-string' and string or a list of characters.
  2814.  
  2815.         An unnamed input stream is setup with the 'make-string-input-
  2816.         stream' function and returns each character of the string when
  2817.         it is used as the source of any input function.
  2818.  
  2819.         (make-string-input-stream <str> [<start> [<end>]])
  2820.             <str>       the string
  2821.             <start>     the starting offset
  2822.             <end>       the ending offset + 1
  2823.             returns     an unnamed stream that reads from the string
  2824.  
  2825.         (make-string-output-stream)
  2826.             returns     an unnamed output stream
  2827.  
  2828.         (get-output-stream-string <stream>)
  2829.             <stream>    the output stream
  2830.             returns     the output so far as a string
  2831.           Note:  the output stream is emptied by this function
  2832.  
  2833.         (get-output-stream-list <stream>)
  2834.             <stream>    the output stream
  2835.             returns     the output so far as a list
  2836.           Note:  the output stream is emptied by this function
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.  
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.  
  2860.  
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866.  
  2867.  
  2868.  
  2869.  
  2870.  
  2871.         XLISP                   SYSTEM FUNCTIONS                 Page 45
  2872.  
  2873.  
  2874.         SYSTEM FUNCTIONS
  2875.  
  2876.         (load <fname> &key :verbose :print)  LOAD A SOURCE FILE
  2877.             <fname>     the filename string or symbol
  2878.             :verbose    the verbose flag (default is t)
  2879.             :print      the print flag (default is nil)
  2880.             returns     the filename
  2881.  
  2882.         (save <fname>) SAVE WORKSPACE TO A FILE
  2883.             <fname>     the filename string or symbol
  2884.             returns     t if workspace was written, nil otherwise
  2885.  
  2886.         (restore <fname>) RESTORE WORKSPACE FROM A FILE
  2887.             <fname>     the filename string or symbol
  2888.             returns     nil on failure, otherwise never returns
  2889.  
  2890.         (dribble [<fname>])  CREATE A FILE WITH A TRANSCRIPT OF A SESSION
  2891.             <fname>     file name string or symbol
  2892.                         (if missing, close current transcript)
  2893.             returns     t if the transcript is opened, nil if it is closed
  2894.  
  2895.         (gc)  FORCE GARBAGE COLLECTION
  2896.             returns     nil
  2897.  
  2898.         (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  2899.             <num>       the number of segments to add
  2900.             returns     the number of segments added
  2901.  
  2902.         (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  2903.             <num>       the number of nodes to allocate
  2904.             returns     the old number of nodes to allocate
  2905.  
  2906.         (room)  SHOW MEMORY ALLOCATION STATISTICS
  2907.             returns     nil
  2908.  
  2909.         (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  2910.             <expr>      the expression to return the type of
  2911.             returns     nil if the value is nil otherwise one of the symbols:
  2912.                           SYMBOL          for symbols
  2913.                           OBJECT          for objects
  2914.                           CONS            for conses
  2915.                           SUBR            for built-in functions
  2916.                           FSUBR           for special forms
  2917.                           CLOSURE         for defined functions
  2918.                           STRING          for strings
  2919.                           FIXNUM          for integers
  2920.                           FLONUM          for floating point numbers
  2921.                           CHARACTER       for characters
  2922.                           FILE-STREAM     for file pointers
  2923.                           UNNAMED-STREAM  for unnamed streams
  2924.                           ARRAY           for arrays
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.         XLISP                   SYSTEM FUNCTIONS                 Page 46
  2938.  
  2939.  
  2940.         (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  2941.             <addrs>     the address to peek at (integer)
  2942.             returns     the value at the specified address (integer)
  2943.  
  2944.         (poke <addrs> <value>)  POKE A VALUE INTO MEMORY
  2945.             <addrs>     the address to poke (integer)
  2946.             <value>     the value to poke into the address (integer)
  2947.             returns     the value
  2948.  
  2949.         (address-of <expr>)  GET THE ADDRESS OF AN XLISP NODE
  2950.             <expr>      the node
  2951.             returns     the address of the node (integer)
  2952.  
  2953.         (exit)  EXIT XLISP
  2954.             returns     never returns
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.  
  2978.  
  2979.  
  2980.  
  2981.  
  2982.  
  2983.  
  2984.  
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.  
  2992.  
  2993.  
  2994.  
  2995.  
  2996.  
  2997.  
  2998.  
  2999.  
  3000.  
  3001.  
  3002.  
  3003.         XLISP                       EXAMPLES                     Page 47
  3004.  
  3005.  
  3006.         FILE I/O FUNCTIONS
  3007.  
  3008.         Input from a File
  3009.  
  3010.         To open a file for input, use the OPEN function with the keyword
  3011.         argument :DIRECTION set to :INPUT.  To open a file for output,
  3012.         use the OPEN function with the keyword argument :DIRECTION set
  3013.         to :OUTPUT.  The OPEN function takes a single required argument
  3014.         which is the name of the file to be opened.  This name can be in
  3015.         the form of a string or a symbol.  The OPEN function returns an
  3016.         object of type FILE-STREAM if it succeeds in opening the
  3017.         specified file.  It returns the value NIL if it fails.  In order
  3018.         to manipulate the file, it is necessary to save the value
  3019.         returned by the OPEN function.  This is usually done by
  3020.         assigning it to a variable with the SETQ special form or by
  3021.         binding it using LET or LET*.  Here is an example:
  3022.  
  3023.             (setq fp (open "init.lsp" :direction :input))
  3024.  
  3025.         Evaluating this expression will result in the file "init.lsp"
  3026.         being opened.  The file object that will be returned by the OPEN
  3027.         function will be assigned to the variable "fp".
  3028.  
  3029.         It is now possible to use the file for input.  To read an
  3030.         expression from the file, just supply the value of the "fp"
  3031.         variable as the optional "stream" argument to READ.
  3032.  
  3033.             (read fp)
  3034.  
  3035.         Evaluating this expression will result in reading the first
  3036.         expression from the file "init.lsp".  The expression will be
  3037.         returned as the result of the READ function.  More expressions
  3038.         can be read from the file using further calls to the READ
  3039.         function.  When there are no more expressions to read, the READ
  3040.         function will return NIL (or whatever value was supplied as the
  3041.         second argument to READ).
  3042.  
  3043.         Once you are done reading from the file, you should close it.
  3044.         To close the file, use the following expression:
  3045.  
  3046.             (close fp)
  3047.  
  3048.         Evaluating this expression will cause the file to be closed.
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.         XLISP                       EXAMPLES                     Page 48
  3070.  
  3071.  
  3072.         Output to a File
  3073.  
  3074.         Writing to a file is pretty much the same as reading from one.
  3075.         You need to open the file first.  This time you should use the
  3076.         OPEN function to indicate that you will do output to the file.
  3077.         For example:
  3078.  
  3079.             (setq fp (open "test.dat" :direction :output))
  3080.  
  3081.         Evaluating this expression will open the file "test.dat" for
  3082.         output.  If the file already exists, its current contents will
  3083.         be discarded.  If it doesn't already exist, it will be created.
  3084.         In any case, a FILE-STREAM object will be returned by the OPEN
  3085.         function.  This file object will be assigned to the "fp"
  3086.         variable.
  3087.  
  3088.         It is now possible to write to this file by supplying the value
  3089.         of the "fp" variable as the optional "stream" parameter in the
  3090.         PRINT function.
  3091.  
  3092.             (print "Hello there" fp)
  3093.  
  3094.         Evaluating this expression will result in the string "Hello
  3095.         there" being written to the file "test.dat".  More data can be
  3096.         written to the file using the same technique.
  3097.  
  3098.         Once you are done writing to the file, you should close it.
  3099.         Closing an output file is just like closing an input file.
  3100.  
  3101.             (close fp)
  3102.  
  3103.         Evaluating this expression will close the output file and make
  3104.         it permanent.
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.         XLISP                       EXAMPLES                     Page 49
  3136.  
  3137.  
  3138.         A Slightly More Complicated File Example
  3139.  
  3140.         This example shows how to open a file, read each Lisp expression
  3141.         from the file and print it.  It demonstrates the use of files
  3142.         and the use of the optional "stream" argument to the READ
  3143.         function.
  3144.  
  3145.             (do* ((fp (open "test.dat" :direction :input))
  3146.                   (ex (read fp) (read fp)))
  3147.                  ((null ex) nil)
  3148.               (print ex))
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.  
  3213.  
  3214.  
  3215.  
  3216.  
  3217.  
  3218.  
  3219.  
  3220.  
  3221.  
  3222.  
  3223.  
  3224.  
  3225.  
  3226.  
  3227.  
  3228.  
  3229.  
  3230.  
  3231.  
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.  
  3245.