home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / LISP / LISP.ZIP / XLISP.DOC next >
Encoding:
Text File  |  1985-08-06  |  41.9 KB  |  1,081 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.           XLISP: An Experimental Object Oriented Language
  12.  
  13.  
  14.  
  15.                             Version 1.2
  16.  
  17.  
  18.  
  19.                           October 11, 1984
  20.  
  21.  
  22.  
  23.  
  24.  
  25.                                  by
  26.  
  27.                              David Betz
  28.  
  29.                          114 Davenport Ave.
  30.  
  31.                        Manchester, NH  03103
  32.  
  33.  
  34.  
  35.                        (603) 625-4691 (home)
  36.  
  37.  
  38.  
  39.  
  40.  
  41.     XLISP: An Experimental Object Oriented Language                 Page 2
  42.  
  43.     TABLE OF CONTENTS
  44.  
  45.  
  46.  
  47.  
  48.  
  49.             1.0     INTRODUCTION . . . . . . . . . . . . . . . . . . . . 3
  50.  
  51.             2.0     A NOTE FROM THE AUTHOR . . . . . . . . . . . . . . . 4
  52.  
  53.             3.0     XLISP COMMAND LOOP . . . . . . . . . . . . . . . . . 5
  54.  
  55.             4.0     DATA TYPES . . . . . . . . . . . . . . . . . . . . . 6
  56.  
  57.             5.0     THE EVALUATOR  . . . . . . . . . . . . . . . . . . . 7
  58.  
  59.             6.0     LEXICAL CONVENTIONS  . . . . . . . . . . . . . . . . 8
  60.  
  61.             7.0     OBJECTS  . . . . . . . . . . . . . . . . . . . . . . 9
  62.  
  63.             8.0     SYMBOLS  . . . . . . . . . . . . . . . . . . . . .  12
  64.  
  65.             9.0     EVALUATION FUNCTIONS . . . . . . . . . . . . . . .  13
  66.  
  67.             10.0    SYMBOL FUNCTIONS . . . . . . . . . . . . . . . . .  14
  68.  
  69.             11.0    PROPERTY LIST FUNCTIONS  . . . . . . . . . . . . .  15
  70.  
  71.             12.0    LIST FUNCTIONS . . . . . . . . . . . . . . . . . .  16
  72.  
  73.             13.0    DESTRUCTIVE LIST FUNCTIONS . . . . . . . . . . . .  18
  74.  
  75.             14.0    PREDICATE FUNCTIONS  . . . . . . . . . . . . . . .  19
  76.  
  77.             15.0    CONTROL FUNCTIONS  . . . . . . . . . . . . . . . .  20
  78.  
  79.             16.0    ARITHMETIC FUNCTIONS . . . . . . . . . . . . . . .  22
  80.  
  81.             17.0    BITWISE LOGICAL FUNCTIONS  . . . . . . . . . . . .  23
  82.  
  83.             18.0    RELATIONAL FUNCTIONS . . . . . . . . . . . . . . .  24
  84.  
  85.             19.0    STRING FUNCTIONS . . . . . . . . . . . . . . . . .  25
  86.  
  87.             20.0    INPUT/OUTPUT FUNCTIONS . . . . . . . . . . . . . .  26
  88.  
  89.             21.0    FILE I/O FUNCTIONS . . . . . . . . . . . . . . . .  27
  90.  
  91.             22.0    SYSTEM FUNCTIONS . . . . . . . . . . . . . . . . .  28
  92.  
  93.  
  94.  
  95.  
  96.  
  97.     XLISP: An Experimental Object Oriented Language                 Page 3
  98.  
  99.     INTRODUCTION
  100.  
  101.  
  102.  
  103.  
  104.  
  105.     1.0  INTRODUCTION
  106.  
  107.  
  108.  
  109.     XLISP is an experimental programming language combining some
  110.  
  111.     of  the  features  of LISP with an object oriented extension
  112.  
  113.     capability.  It was  implemented  to  allow  experimentation
  114.  
  115.     with  object oriented programming on small computers.  There
  116.  
  117.     are currently implementations running on  the  PDP-11  under
  118.  
  119.     RSX-11,  RT-11, and UNIX V7, on the VAX-11 under VAX/VMS and
  120.  
  121.     Berkeley VAX/UNIX, on the Z-80 under CP/M-80, on  the  Z8000
  122.  
  123.     under UNIX V7, and on the 8088/8086 under CP/M-86 or MS-DOS.
  124.  
  125.     A version is currently being developed for the  68000  under
  126.  
  127.     CP/M-68K.   It  is  completely  written  in  the programming
  128.  
  129.     language 'C'  and  is  easily  extended  with  user  written
  130.  
  131.     built-in  functions  and classes.  It is available in source
  132.  
  133.     form free of charge to  non-commercial  users.   Prospective
  134.  
  135.     commercial users should contact the author for permission to
  136.  
  137.     use XLISP.
  138.  
  139.  
  140.  
  141.     Many traditional LISP functions are built  into  XLISP.   In
  142.  
  143.     addition,  XLISP defines the objects 'Object' and 'Class' as
  144.  
  145.     primitives.   'Object'  is  the  only  class  that  has   no
  146.  
  147.     superclass  and  hence  is  the  root of the class heirarchy
  148.  
  149.     tree.  'Class'  is  the  class  of  which  all  classes  are
  150.  
  151.     instances  (it  is  the  only  object that is an instance of
  152.  
  153.     itself).
  154.  
  155.  
  156.  
  157.     This document is intended  to  be  a  brief  description  of
  158.  
  159.     XLISP.    It   assumes  some  knowledge  of  LISP  and  some
  160.  
  161.     understanding   of   the   concepts   of   object   oriented
  162.  
  163.     programming.
  164.  
  165.  
  166.  
  167.     Version 1.2 of XLISP differs from  version  1.1  in  several
  168.  
  169.     ways.   It  supports  many  more Lisp functions.  Also, many
  170.  
  171.     version 1.1  functions  have  been  renamed  and/or  changed
  172.  
  173.     slightly  to follow traditional Lisp usage.  One of the most
  174.  
  175.     frequently reported problems in version  1.1  resulted  from
  176.  
  177.     many  functions being named after their equivilent functions
  178.  
  179.     in the C language.  This turned  out  to  be  confusing  for
  180.  
  181.     people who were trying to learn XLISP using traditional LISP
  182.  
  183.     texts as references.  Version 1.2 renames these functions to
  184.  
  185.     be compatible with more traditional dialects of LISP.
  186.  
  187.  
  188.  
  189.     A recommended text for learning LISP programming is the book
  190.  
  191.     "LISP"  by Winston and Horn and published by Addison Wesley.
  192.  
  193.     The first edition of this book is based on MacLisp  and  the
  194.  
  195.     second  edition  is based on Common Lisp.  Future version of
  196.  
  197.     XLISP will migrate towards compatiblility with Common Lisp.
  198.  
  199.  
  200.  
  201.  
  202.  
  203.     XLISP: An Experimental Object Oriented Language                 Page 4
  204.  
  205.     A NOTE FROM THE AUTHOR
  206.  
  207.  
  208.  
  209.  
  210.  
  211.     2.0  A NOTE FROM THE AUTHOR
  212.  
  213.  
  214.  
  215.     If you have any problems with XLISP, feel free to contact me
  216.  
  217.     for  help  or  advice.   Please remember that since XLISP is
  218.  
  219.     available in source form in  a  high  level  language,  many
  220.  
  221.     users  have  been  making versions available on a variety of
  222.  
  223.     machines.  If you call to report a problem with  a  specific
  224.  
  225.     version,  I may not be able to help you if that version runs
  226.  
  227.     on a machine to which I don't have access.
  228.  
  229.  
  230.  
  231.     If you find a bug  in  XLISP,  first  try  to  fix  the  bug
  232.  
  233.     yourself  using  the  source  code  provided.   If  you  are
  234.  
  235.     successful in fixing the bug, send the bug report along with
  236.  
  237.     the  fix to me.  If you don't have access to a C compiler or
  238.  
  239.     are unable to fix a bug, please send the bug  report  to  me
  240.  
  241.     and I'll try to fix it.
  242.  
  243.  
  244.  
  245.     Any suggestions for improvements  will  be  welcomed.   Feel
  246.  
  247.     free  to  extend  the  language  in  whatever way suits your
  248.  
  249.     needs.  However, PLEASE DO  NOT  RELEASE  ENHANCED  VERSIONS
  250.  
  251.     WITHOUT  CHECKING  WITH  ME  FIRST!!  I would like to be the
  252.  
  253.     clearing house for new features added to XLISP.  If you want
  254.  
  255.     to  add  features for your own personal use, go ahead.  But,
  256.  
  257.     if you want to distribute your enhanced version, contact  me
  258.  
  259.     first.  Please remember that the goal of XLISP is to provide
  260.  
  261.     a language to learn and  experiment  with  LISP  and  object
  262.  
  263.     oriented programming on small computers.  Version 1.2 barely
  264.  
  265.     fits on a 64K Z-80 running CP/M-80.
  266.  
  267.  
  268.  
  269.  
  270.  
  271.     XLISP: An Experimental Object Oriented Language                 Page 5
  272.  
  273.     XLISP COMMAND LOOP
  274.  
  275.  
  276.  
  277.  
  278.  
  279.     3.0  XLISP COMMAND LOOP
  280.  
  281.  
  282.  
  283.     When XLISP is started, it first  tries  to  load  "init.lsp"
  284.  
  285.     from  the  default directory.  It then loads any files named
  286.  
  287.     as parameters on the command line (after appending ".lsp" to
  288.  
  289.     their names).  It then issues the following prompt:
  290.  
  291.  
  292.  
  293.     >
  294.  
  295.  
  296.  
  297.     This indicates that XLISP is waiting for an expression to be
  298.  
  299.     typed.   When  an  incomplete expression has been typed (one
  300.  
  301.     where the left and right parens don't match)  XLISP  changes
  302.  
  303.     its prompt to:
  304.  
  305.  
  306.  
  307.     n>
  308.  
  309.  
  310.  
  311.     where n is an integer indicating how  many  levels  of  left
  312.  
  313.     parens remain unclosed.
  314.  
  315.  
  316.  
  317.     When a complete expression has been entered, XLISP  attempts
  318.  
  319.     to  evaluate  that  expression.  If the expression evaluates
  320.  
  321.     successfully, XLISP prints the result of the evaluation  and
  322.  
  323.     then  returns  to  the  initial  prompt  waiting for another
  324.  
  325.     expression to be typed.
  326.  
  327.  
  328.  
  329.     Input can be aborted at any time by typing the CONTROL-G key
  330.  
  331.     (it may be necessary to follow CONTROL-G by return).
  332.  
  333.  
  334.  
  335.  
  336.  
  337.     XLISP: An Experimental Object Oriented Language                 Page 6
  338.  
  339.     DATA TYPES
  340.  
  341.  
  342.  
  343.  
  344.  
  345.     4.0  DATA TYPES
  346.  
  347.  
  348.  
  349.     There are several different data types  available  to  XLISP
  350.  
  351.     programmers.
  352.  
  353.  
  354.  
  355.  
  356.  
  357.           o  lists
  358.  
  359.  
  360.  
  361.           o  symbols
  362.  
  363.  
  364.  
  365.           o  strings
  366.  
  367.  
  368.  
  369.           o  integers
  370.  
  371.  
  372.  
  373.           o  objects
  374.  
  375.  
  376.  
  377.           o  file pointers
  378.  
  379.  
  380.  
  381.           o  subrs/fsubrs (built-in functions)
  382.  
  383.  
  384.  
  385.     Another data type is the stream.  A stream is  a  list  node
  386.  
  387.     whose car points to the head of a list of integers and whose
  388.  
  389.     cdr points to the last list node  of  the  list.   An  empty
  390.  
  391.     stream  is  a  list node whose car and cdr are nil.  Each of
  392.  
  393.     the integers in the list represent characters in the stream.
  394.  
  395.     When  a  character  is read from a stream, the first integer
  396.  
  397.     from the head of the list is removed and returned.   When  a
  398.  
  399.     character  is  written to a stream, the integer representing
  400.  
  401.     the character code of the character is appended to  the  end
  402.  
  403.     of  the  list.   When  a function indicates that it takes an
  404.  
  405.     input source as a parameter, this parameter can either be an
  406.  
  407.     input  file pointer or a stream.  Similarly, when a function
  408.  
  409.     indicates that it takes an output sink as a parameter,  this
  410.  
  411.     parameter can either be an output file pointer or a stream.
  412.  
  413.  
  414.  
  415.  
  416.  
  417.     XLISP: An Experimental Object Oriented Language                 Page 7
  418.  
  419.     THE EVALUATOR
  420.  
  421.  
  422.  
  423.  
  424.  
  425.     5.0  THE EVALUATOR
  426.  
  427.  
  428.  
  429.     The process of evaluation in XLISP:
  430.  
  431.  
  432.  
  433.           o  Integers,  strings,  objects,  file  pointers,  and
  434.  
  435.              subrs evaluate to themselves
  436.  
  437.  
  438.  
  439.           o  Symbols evaluate to the value associated with their
  440.  
  441.              current binding
  442.  
  443.  
  444.  
  445.           o  Lists are evaluated by evaluating the first element
  446.  
  447.              of the list
  448.  
  449.  
  450.  
  451.               o  If it evaluates to a subr, the  remaining  list
  452.  
  453.                  elements  are  evaluated and the subr is called
  454.  
  455.                  with these evaluated expressions as arguments.
  456.  
  457.  
  458.  
  459.               o  If it evaluates  to  an  fsubr,  the  fsubr  is
  460.  
  461.                  called  using  the  remaining  list elements as
  462.  
  463.                  arguments  (they  are  evaluated  by  the  subr
  464.  
  465.                  itself if necessary)
  466.  
  467.  
  468.  
  469.               o  If it evaluates to a list and the  car  of  the
  470.  
  471.                  list  is  'lambda', the remaining list elements
  472.  
  473.                  are evaluated and the resulting expressions are
  474.  
  475.                  bound  to  the  formal  arguments of the lambda
  476.  
  477.                  expression.   The  body  of  the  function   is
  478.  
  479.                  executed within this new binding environment.
  480.  
  481.  
  482.  
  483.               o  If it evaluates to a list and the  car  of  the
  484.  
  485.                  list  is 'nlambda', the remaining list elements
  486.  
  487.                  are  bound  to  the  formal  arguments  of  the
  488.  
  489.                  nlambda  expression.   The body of the function
  490.  
  491.                  is   executed   within   this    new    binding
  492.  
  493.                  environment.
  494.  
  495.  
  496.  
  497.               o  If it evaluates to an object, the  second  list
  498.  
  499.                  element  is  evaluated  and  used  as a message
  500.  
  501.                  selector.  The message formed by combining  the
  502.  
  503.                  selector  with the values of the remaining list
  504.  
  505.                  elements is sent to the object.
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.     XLISP: An Experimental Object Oriented Language                 Page 8
  516.  
  517.     LEXICAL CONVENTIONS
  518.  
  519.  
  520.  
  521.  
  522.  
  523.     6.0  LEXICAL CONVENTIONS
  524.  
  525.  
  526.  
  527.     The following conventions are followed when  entering  XLISP
  528.  
  529.     programs:
  530.  
  531.  
  532.  
  533.     Comments in XLISP code begin with a semi-colon character and
  534.  
  535.     continue to the end of the line.
  536.  
  537.  
  538.  
  539.     Symbol names  in  XLISP  can  consist  of  any  sequence  of
  540.  
  541.     non-blank printable characters except the following:
  542.  
  543.  
  544.  
  545.             ( ) . ' " ;
  546.  
  547.  
  548.  
  549.     Upper and lower case characters are distinct.   The  symbols
  550.  
  551.     'CAR' and 'car' are not the same.  The names of all built-in
  552.  
  553.     functions are in lower case.   The  names  of  all  built-in
  554.  
  555.     objects  are  lower  case  with  an initial capital.  Symbol
  556.  
  557.     names must not begin with a digit.
  558.  
  559.  
  560.  
  561.     Integer literals consist of a sequence of digits  optionally
  562.  
  563.     beginning with a '+' or '-'.  The range of values an integer
  564.  
  565.     can represent is limited by the size of a  C  'int'  on  the
  566.  
  567.     machine that XLISP is running on.
  568.  
  569.  
  570.  
  571.     Literal strings are sequences of  characters  surrounded  by
  572.  
  573.     double  quotes.   Within quoted strings the '\' character is
  574.  
  575.     used to allow non-printable characters to be included.   The
  576.  
  577.     codes recognized are:
  578.  
  579.  
  580.  
  581.             \\      means the character '\'
  582.  
  583.             \n      means newline
  584.  
  585.             \t      means tab
  586.  
  587.             \r      means return
  588.  
  589.             \e      means escape
  590.  
  591.             \nnn    means the character whose octal code is nnn
  592.  
  593.  
  594.  
  595.     The single quote character can be used as a shorthand for  a
  596.  
  597.     call on the function 'quote':
  598.  
  599.  
  600.  
  601.                             'foo
  602.  
  603.     is equivalent to:
  604.  
  605.                             (quote foo)
  606.  
  607.  
  608.  
  609.  
  610.  
  611.     XLISP: An Experimental Object Oriented Language                 Page 9
  612.  
  613.     OBJECTS
  614.  
  615.  
  616.  
  617.  
  618.  
  619.     7.0  OBJECTS
  620.  
  621.  
  622.  
  623.     Definitions:
  624.  
  625.  
  626.  
  627.           o  selector - a symbol used to select  an  appropriate
  628.  
  629.              method
  630.  
  631.  
  632.  
  633.           o  message - a selector and a list of actual arguments
  634.  
  635.  
  636.  
  637.           o  method - the code that implements a message
  638.  
  639.  
  640.  
  641.     Since XLISP was  created  to  provide  a  simple  basis  for
  642.  
  643.     experimenting  with  object oriented programming, one of the
  644.  
  645.     primitive data types included was 'object'.   In  XLISP,  an
  646.  
  647.     object  consists of a data structure containing a pointer to
  648.  
  649.     the object's class as well as a list containing  the  values
  650.  
  651.     of the object's instance variables.
  652.  
  653.  
  654.  
  655.     Officially, there is no way to see inside an object (look at
  656.  
  657.     the  values  of  its  instance  variables).  The only way to
  658.  
  659.     communicate with an object is by sending it a message.  When
  660.  
  661.     the  XLISP  evaluator  evaluates  a  list the value of whose
  662.  
  663.     first element is an object, it interprets the value  of  the
  664.  
  665.     second  element  of the list (which must be a symbol) as the
  666.  
  667.     message selector.  The evaluator determines the class of the
  668.  
  669.     receiving object and attempts to find a method corresponding
  670.  
  671.     to the message selector in the set of messages  defined  for
  672.  
  673.     that  class.   If  the  message is not found in the object's
  674.  
  675.     class and the class has a super-class, the search  continues
  676.  
  677.     by  looking  at  the  messages  defined for the super-class.
  678.  
  679.     This process continues from  one  super-class  to  the  next
  680.  
  681.     until  a  method  for the message is found.  If no method is
  682.  
  683.     found, an error occurs.
  684.  
  685.  
  686.  
  687.     When a method is found, the evaluator  binds  the  receiving
  688.  
  689.     object  to  the  symbol 'self', binds the class in which the
  690.  
  691.     method was found to the symbol 'msgclass', and evaluates the
  692.  
  693.     method  using the remaining elements of the original list as
  694.  
  695.     arguments  to  the  method.   These  arguments  are   always
  696.  
  697.     evaluated prior to being bound to their corresponding formal
  698.  
  699.     arguments.  The result of evaluating the method becomes  the
  700.  
  701.     result of the expression.
  702.  
  703.  
  704.  
  705.  
  706.  
  707.     XLISP: An Experimental Object Oriented Language                Page 10
  708.  
  709.     OBJECTS
  710.  
  711.  
  712.  
  713.  
  714.  
  715.     Classes:
  716.  
  717.  
  718.  
  719.     Object  THE TOP OF THE CLASS HEIRARCHY
  720.  
  721.  
  722.  
  723.         Messages:
  724.  
  725.  
  726.  
  727.             show    SHOW AN OBJECT'S INSTANCE VARIABLES
  728.  
  729.                 returns     the object
  730.  
  731.  
  732.  
  733.             class   RETURN THE CLASS OF AN OBJECT
  734.  
  735.                 returns     the class of the object
  736.  
  737.  
  738.  
  739.             isnew   THE DEFAULT OBJECT INITIALIZATION ROUTINE
  740.  
  741.                 returns     the object
  742.  
  743.  
  744.  
  745.             sendsuper <sel> [<args>...] SEND SUPERCLASS A MESSAGE
  746.  
  747.                 <sel>       the message selector
  748.  
  749.                 <args>      the message arguments
  750.  
  751.                 returns     the result of sending the message
  752.  
  753.  
  754.  
  755.  
  756.  
  757.     XLISP: An Experimental Object Oriented Language                Page 11
  758.  
  759.     OBJECTS
  760.  
  761.  
  762.  
  763.  
  764.  
  765.     Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  766.  
  767.  
  768.  
  769.         Messages:
  770.  
  771.  
  772.  
  773.             new     CREATE A NEW INSTANCE OF A CLASS
  774.  
  775.                 returns     the new class object
  776.  
  777.  
  778.  
  779.             isnew [<scls>]  INITIALIZE A NEW CLASS
  780.  
  781.                 <scls>      the superclass
  782.  
  783.                 returns     the new class object
  784.  
  785.  
  786.  
  787.             answer <msg> <fargs> <code>     ADD A MESSAGE TO A CLASS
  788.  
  789.                 <msg>       the message symbol
  790.  
  791.                 <fargs>     the formal argument list
  792.  
  793.                               this list is of the form:
  794.  
  795.                                 (<farg>... [&rest <rarg>] [&aux <aux>...])
  796.  
  797.                               where
  798.  
  799.                                 <farg>      a formal argument
  800.  
  801.                                 <rarg>      bound to the rest of the arguments
  802.  
  803.                                 <aux>       a auxiliary variable
  804.  
  805.                 <code>      a list of executable expressions
  806.  
  807.                 returns     the object
  808.  
  809.  
  810.  
  811.             ivars <vars>    DEFINE THE LIST OF INSTANCE VARIABLES
  812.  
  813.                 <vars>      the list of instance variable symbols
  814.  
  815.                 returns     the object
  816.  
  817.  
  818.  
  819.             cvars <vars>    DEFINE THE LIST OF CLASS VARIABLES
  820.  
  821.                 <vars>      the list of class variable symbols
  822.  
  823.                 returns     the object
  824.  
  825.  
  826.  
  827.  
  828.  
  829.     When a new instance of a class is  created  by  sending  the
  830.  
  831.     message  'new'  to  an  existing  class, the message 'isnew'
  832.  
  833.     followed by whatever parameters were  passed  to  the  'new'
  834.  
  835.     message is sent to the newly created object.
  836.  
  837.  
  838.  
  839.     When a new class is created by sending the 'new' message  to
  840.  
  841.     the  object  'Class', an optional parameter may be specified
  842.  
  843.     indicating  the  superclass  of  the  new  class.   If  this
  844.  
  845.     parameter  is  omitted,  the new class will be a subclass of
  846.  
  847.     'Object'.  A class inherits all  instance  variables,  class
  848.  
  849.     variables, and methods from its super-class.
  850.  
  851.  
  852.  
  853.  
  854.  
  855.     XLISP: An Experimental Object Oriented Language                Page 12
  856.  
  857.     SYMBOLS
  858.  
  859.  
  860.  
  861.  
  862.  
  863.     8.0  SYMBOLS
  864.  
  865.  
  866.  
  867.  
  868.  
  869.           o  self  -  the  current  object  (within  a   message
  870.  
  871.              context)
  872.  
  873.  
  874.  
  875.           o  msgclass - the class in which  the  current  method
  876.  
  877.              was found
  878.  
  879.  
  880.  
  881.           o  *oblist* - the object list
  882.  
  883.  
  884.  
  885.           o  *standard-input* - the standard input file
  886.  
  887.  
  888.  
  889.           o  *standard-output* - the standard output file
  890.  
  891.  
  892.  
  893.           o  *tracenable* - flag controlling trace back printout
  894.  
  895.              on errors
  896.  
  897.  
  898.  
  899.           o  *unbound* - indicator for unbound symbols
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.     XLISP: An Experimental Object Oriented Language                Page 13
  908.  
  909.     EVALUATION FUNCTIONS
  910.  
  911.  
  912.  
  913.  
  914.  
  915.     9.0  EVALUATION FUNCTIONS
  916.  
  917.  
  918.  
  919.     (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  920.  
  921.         <expr>      the expression to be evaluated
  922.  
  923.         returns     the result of evaluating the expression
  924.  
  925.  
  926.  
  927.     (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  928.  
  929.         <fun>       the function to apply (or function symbol)
  930.  
  931.         <args>      the argument list
  932.  
  933.         returns     the result of applying the function to the argument list
  934.  
  935.  
  936.  
  937.     (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  938.  
  939.         <fun>       the function to call (or function symbol)
  940.  
  941.         <arg>       arguments to pass to the function
  942.  
  943.         returns     the result of calling the function with the arguments
  944.  
  945.  
  946.  
  947.     (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  948.  
  949.         <expr>      the expression to be quoted (quoted)
  950.  
  951.         returns     <expr> unevaluated
  952.  
  953.  
  954.  
  955.  
  956.  
  957.     XLISP: An Experimental Object Oriented Language                Page 14
  958.  
  959.     SYMBOL FUNCTIONS
  960.  
  961.  
  962.  
  963.  
  964.  
  965.     10.0  SYMBOL FUNCTIONS
  966.  
  967.  
  968.  
  969.     (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  970.  
  971.         <sym>       the symbol being set
  972.  
  973.         <expr>      the new value
  974.  
  975.         returns     the new value
  976.  
  977.  
  978.  
  979.     (setq <sym> <expr>)  SET THE VALUE OF A SYMBOL
  980.  
  981.         <sym>       the symbol being set (quoted)
  982.  
  983.         <expr>      the new value
  984.  
  985.         returns     the new value
  986.  
  987.  
  988.  
  989.     (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION WITH EVALUATED ARGS
  990.  
  991.     (ndefun <sym> <fargs> <expr>...)  DEFINE A FUNCTION WITH UNEVALUATED ARGS
  992.  
  993.         <sym>       symbol being defined (quoted)
  994.  
  995.         <fargs>     list of formal arguments (quoted)
  996.  
  997.                       this list is of the form:
  998.  
  999.                         (<farg>... [&rest <rarg>] [&aux <aux>...])
  1000.  
  1001.                       where
  1002.  
  1003.                         <farg>      is a formal argument
  1004.  
  1005.                         <rarg>      bound to the rest of the arguments
  1006.  
  1007.                         <aux>       is an auxiliary variable
  1008.  
  1009.         <expr>      expressions constituting the body of the
  1010.  
  1011.                     function (quoted)
  1012.  
  1013.         returns     the function symbol
  1014.  
  1015.  
  1016.  
  1017.     (gensym <tag>)  GENERATE A SYMBOL
  1018.  
  1019.         <tag>       symbol/string/number
  1020.  
  1021.         returns     the new symbol
  1022.  
  1023.  
  1024.  
  1025.     (intern <sym>)  INTERN A SYMBOL ON THE OBLIST
  1026.  
  1027.         <sym>       the symbol
  1028.  
  1029.         returns     the interned symbol
  1030.  
  1031.  
  1032.  
  1033.     (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  1034.  
  1035.         <sym>       the symbol
  1036.  
  1037.         returns     the symbol's print name
  1038.  
  1039.  
  1040.  
  1041.     (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  1042.  
  1043.         <sym>       the symbol
  1044.  
  1045.         returns     the symbol's property list
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.     XLISP: An Experimental Object Oriented Language                Page 15
  1052.  
  1053.     PROPERTY LIST FUNCTIONS
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.     11.0  PROPERTY LIST FUNCTIONS
  1060.  
  1061.  
  1062.  
  1063.     (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  1064.  
  1065.         <sym>       the symbol
  1066.  
  1067.         <prop>      the property symbol
  1068.  
  1069.         returns     the property value or nil
  1070.  
  1071.  
  1072.  
  1073.     (putprop <sym> <value> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  1074.  
  1075.         <sym>       the symbol
  1076.  
  1077.         <value>     the property value
  1078.  
  1079.         <prop>      the property symbol
  1080.  
  1081.         returns     the value
  1082.  
  1083.  
  1084.  
  1085.     (remprop <prop> <sym>)  REMOVE A PROPERTY
  1086.  
  1087.         <sym>       the symbol
  1088.  
  1089.         <prop>      the property symbol
  1090.  
  1091.         returns     nil
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.     XLISP: An Experimental Object Oriented Language                Page 16
  1098.  
  1099.     LIST FUNCTIONS
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.     12.0  LIST FUNCTIONS
  1106.  
  1107.  
  1108.  
  1109.     (car <expr>)  RETURN THE CAR OF A LIST NODE
  1110.  
  1111.         <expr>      the list node
  1112.  
  1113.         returns     the car of the list node
  1114.  
  1115.  
  1116.  
  1117.     (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  1118.  
  1119.         <expr>      the list node
  1120.  
  1121.         returns     the cdr of the list node
  1122.  
  1123.  
  1124.  
  1125.     (caar <expr>) == (car (car <expr>))
  1126.  
  1127.     (cadr <expr>) == (car (cdr <expr>))
  1128.  
  1129.     (cdar <expr>) == (cdr (car <expr>))
  1130.  
  1131.     (cddr <expr>) == (cdr (cdr <expr>))
  1132.  
  1133.  
  1134.  
  1135.     (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  1136.  
  1137.         <expr1>     the car of the new list node
  1138.  
  1139.         <expr2>     the cdr of the new list node
  1140.  
  1141.         returns     the new list node
  1142.  
  1143.  
  1144.  
  1145.     (list <expr>...)  CREATE A LIST OF VALUES
  1146.  
  1147.         <expr>      expressions to be combined into a list
  1148.  
  1149.         returns     the new list
  1150.  
  1151.  
  1152.  
  1153.     (append <expr>...)  APPEND LISTS
  1154.  
  1155.         <expr>      lists whose elements are to be appended
  1156.  
  1157.         returns     the new list
  1158.  
  1159.  
  1160.  
  1161.     (reverse <expr>)  REVERSE A LIST
  1162.  
  1163.         <expr>      the list to reverse
  1164.  
  1165.         returns     a new list in the reverse order
  1166.  
  1167.  
  1168.  
  1169.     (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  1170.  
  1171.         <list>      the list
  1172.  
  1173.         returns     the last list node in the list
  1174.  
  1175.  
  1176.  
  1177.     (member <expr> <list>)  FIND AN EXPRESSION IN A LIST
  1178.  
  1179.         <expr>      the expression to find (equal test)
  1180.  
  1181.         <list>      the list to search
  1182.  
  1183.         returns     the remainder of the list starting with the expression
  1184.  
  1185.  
  1186.  
  1187.     (memq <expr> <list>)  FIND AN EXPRESSION IN A LIST
  1188.  
  1189.         <expr>      the expression to find (eq test)
  1190.  
  1191.         <list>      the list to find it in
  1192.  
  1193.         returns     the remainder of the list starting with the expression
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.     XLISP: An Experimental Object Oriented Language                Page 17
  1200.  
  1201.     LIST FUNCTIONS
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.     (assoc <expr> <alist>)  FIND AN EXPRESSION IN AN ASSOCIATION LIST
  1208.  
  1209.         <expr>      the expression to find (equal test)
  1210.  
  1211.         <alist>     the association list
  1212.  
  1213.         returns     the alist entry or nil
  1214.  
  1215.  
  1216.  
  1217.     (assq <expr> <alist>)  FIND AN EXPRESSION IN AN ASSOCIATION LIST
  1218.  
  1219.         <expr>      the expression to find (eq test)
  1220.  
  1221.         <alist>     the association list
  1222.  
  1223.         returns     the alist entry or nil
  1224.  
  1225.  
  1226.  
  1227.     (length <expr>)  FIND THE LENGTH OF A LIST
  1228.  
  1229.         <expr>      the list
  1230.  
  1231.         returns     the length of the list
  1232.  
  1233.  
  1234.  
  1235.     (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  1236.  
  1237.         <n>         the number of the element to return (zero origin)
  1238.  
  1239.         <list>      the list
  1240.  
  1241.         returns     the nth element or nil if the list isn't that long
  1242.  
  1243.  
  1244.  
  1245.     (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  1246.  
  1247.         <n>         the number of the element to return (zero origin)
  1248.  
  1249.         <list>      the list
  1250.  
  1251.         returns     the nth cdr or nil if the list isn't that long
  1252.  
  1253.  
  1254.  
  1255.     (mapcar <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CARS
  1256.  
  1257.         <fcn>       the function or function name
  1258.  
  1259.         <list1..n>  a list for each argument of the function
  1260.  
  1261.         returns     the list of values returned by each function invocation
  1262.  
  1263.  
  1264.  
  1265.     (maplist <fcn> <list1>...<listn>)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1266.  
  1267.         <fcn>       the function or function name
  1268.  
  1269.         <list1..n>  a list for each argument of the function
  1270.  
  1271.         returns     the list of values returned by each function invocation
  1272.  
  1273.  
  1274.  
  1275.     (subst <to> <from> <expr>)  SUBSTITUTE ONE EXPRESSION FOR ANOTHER
  1276.  
  1277.         <to>        the new expression
  1278.  
  1279.         <from>      the old expression
  1280.  
  1281.         <expr>      the expression in which to do the substitutions
  1282.  
  1283.         returns     the expression with substitutions
  1284.  
  1285.  
  1286.  
  1287.     (sublis <alist> <expr>)  SUBSTITUTE USING AN ASSOCIATION LIST
  1288.  
  1289.         <alist>     the association list
  1290.  
  1291.         <expr>      the expression in which to do the substitutions
  1292.  
  1293.         returns     the expression with substitutions
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.     XLISP: An Experimental Object Oriented Language                Page 18
  1300.  
  1301.     DESTRUCTIVE LIST FUNCTIONS
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.     13.0  DESTRUCTIVE LIST FUNCTIONS
  1308.  
  1309.  
  1310.  
  1311.     (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  1312.  
  1313.         <list>      the list node
  1314.  
  1315.         <expr>      the new value for the car of the list node
  1316.  
  1317.         returns     the list node after updating the car
  1318.  
  1319.  
  1320.  
  1321.     (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  1322.  
  1323.         <list>      the list node
  1324.  
  1325.         <expr>      the new value for the cdr of the list node
  1326.  
  1327.         returns     the list node after updating the cdr
  1328.  
  1329.  
  1330.  
  1331.     (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  1332.  
  1333.         <list>      lists to concatenate
  1334.  
  1335.         returns     the result of concatenating the lists
  1336.  
  1337.  
  1338.  
  1339.     (delete <expr> <list>)  DELETE OCCURANCES OF AN EXPRESSION FROM A LIST
  1340.  
  1341.         <expr>      the expression to delete (equal test)
  1342.  
  1343.         <list>      the list
  1344.  
  1345.         returns     the list with the matching expressions deleted
  1346.  
  1347.  
  1348.  
  1349.     (delq <expr> <list>)  DELETE OCCURANCES OF AN EXPRESSION FROM A LIST
  1350.  
  1351.         <expr>      the expression to delete (eq test)
  1352.  
  1353.         <list>      the list
  1354.  
  1355.         returns     the list with the matching expressions deleted
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.     XLISP: An Experimental Object Oriented Language                Page 19
  1362.  
  1363.     PREDICATE FUNCTIONS
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.     14.0  PREDICATE FUNCTIONS
  1370.  
  1371.  
  1372.  
  1373.     (atom <expr>)  IS THIS AN ATOM?
  1374.  
  1375.         <expr>      the expression to check
  1376.  
  1377.         returns     t if the value is an atom, nil otherwise
  1378.  
  1379.  
  1380.  
  1381.     (symbolp <expr>)  IS THIS A SYMBOL?
  1382.  
  1383.         <expr>      the expression to check
  1384.  
  1385.         returns     t if the expression is a symbol, nil otherwise
  1386.  
  1387.  
  1388.  
  1389.     (numberp <expr>)  IS THIS A NUMBER?
  1390.  
  1391.         <expr>      the expression to check
  1392.  
  1393.         returns     t if the expression is a symbol, nil otherwise
  1394.  
  1395.  
  1396.  
  1397.     (null <expr>)  IS THIS AN EMPTY LIST?
  1398.  
  1399.         <expr>      the list to check
  1400.  
  1401.         returns     t if the list is empty, nil otherwise
  1402.  
  1403.  
  1404.  
  1405.     (not <expr>)  IS THIS FALSE?
  1406.  
  1407.         <expr>      the expression to check
  1408.  
  1409.         return      t if the expression is nil, nil otherwise
  1410.  
  1411.  
  1412.  
  1413.     (listp <expr>)  IS THIS A LIST?
  1414.  
  1415.         <expr>      the expression to check
  1416.  
  1417.         returns     t if the value is a list node or nil, nil otherwise
  1418.  
  1419.  
  1420.  
  1421.     (consp <expr>)  IS THIS A NON-EMPTY LIST?
  1422.  
  1423.         <expr>      the expression to check
  1424.  
  1425.         returns     t if the value is a list node, nil otherwise
  1426.  
  1427.  
  1428.  
  1429.     (boundp <sym>)  IS THIS A BOUND SYMBOL?
  1430.  
  1431.         <sym>       the symbol
  1432.  
  1433.         returns     t if a value is bound to the symbol, nil otherwise
  1434.  
  1435.  
  1436.  
  1437.     (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1438.  
  1439.         <expr1>     the first expression
  1440.  
  1441.         <expr2>     the second expression
  1442.  
  1443.         returns     t if they are equal, nil otherwise
  1444.  
  1445.  
  1446.  
  1447.     (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1448.  
  1449.         <expr1>     the first expression
  1450.  
  1451.         <expr2>     the second expression
  1452.  
  1453.         returns     t if they are equal, nil otherwise
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.     XLISP: An Experimental Object Oriented Language                Page 20
  1460.  
  1461.     CONTROL FUNCTIONS
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.     15.0  CONTROL FUNCTIONS
  1468.  
  1469.  
  1470.  
  1471.     (cond <pair>...)  EVALUATE CONDITIONALLY
  1472.  
  1473.         <pair>      pair consisting of:
  1474.  
  1475.                         (<pred> <expr>...)
  1476.  
  1477.                       where
  1478.  
  1479.                         <pred>      is a predicate expression
  1480.  
  1481.                         <expr>      evaluated if the predicate
  1482.  
  1483.                                     is not nil
  1484.  
  1485.         returns     the value of the first expression whose predicate
  1486.  
  1487.                     is not nil
  1488.  
  1489.  
  1490.  
  1491.     (let (<binding>...) <expr>...)  BIND SYMBOLS AND EVALUATE EXPRESSIONS
  1492.  
  1493.         <binding>   the variable bindings each of which is either:
  1494.  
  1495.                     1)  a symbol (which is initialized to nil)
  1496.  
  1497.                     2)  a list whose car is a symbol and whose cadr
  1498.  
  1499.                             is an initialization expression
  1500.  
  1501.         <expr>...   the expressions to be evaluated with the specified bindings
  1502.  
  1503.         returns     the value of the last expression
  1504.  
  1505.  
  1506.  
  1507.     (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1508.  
  1509.         <expr>...   the expressions to be ANDed
  1510.  
  1511.         returns     nil if any expression evaluates to nil,
  1512.  
  1513.                     otherwise the value of the last expression
  1514.  
  1515.                     (evaluation of expressions stops after the first
  1516.  
  1517.                      expression that evaluates to nil)
  1518.  
  1519.  
  1520.  
  1521.     (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1522.  
  1523.         <expr>...   the expressions to be ORed
  1524.  
  1525.         returns     nil if all expressions evaluate to nil,
  1526.  
  1527.                     otherwise the value of the first non-nil expression
  1528.  
  1529.                     (evaluation of expressions stops after the first
  1530.  
  1531.                      expression that does not evaluate to nil)
  1532.  
  1533.  
  1534.  
  1535.     (if <texpr> <expr1> [<expr2>])  EXECUTE EXPRESSIONS CONDITIONALLY
  1536.  
  1537.         <texpr>     the test expression
  1538.  
  1539.         <expr1>     the expression to be evaluated if texpr is non-nil
  1540.  
  1541.         <expr2>     the expression to be evaluated if texpr is nil
  1542.  
  1543.         returns     the value of the selected expression
  1544.  
  1545.  
  1546.  
  1547.     (progn <expr>...)  EXECUTE EXPRESSIONS SEQUENTIALLY
  1548.  
  1549.         <expr>...   the expressions to evaluate
  1550.  
  1551.         returns     the value of the last expression
  1552.  
  1553.  
  1554.  
  1555.     (while <texpr> <expr>...)  ITERATE WHILE AN EXPRESSION IS TRUE
  1556.  
  1557.         <texpr>     the test expression evaluated at start of each iteration
  1558.  
  1559.         <expr>...   the expressions evaluated as long as <texpr> evaluates to
  1560.  
  1561.                     non-nil
  1562.  
  1563.         returns     the value of the last expression
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.     XLISP: An Experimental Object Oriented Language                Page 21
  1570.  
  1571.     CONTROL FUNCTIONS
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.     (repeat <iexpr> <expr>...)  ITERATE USING A REPEAT COUNT
  1578.  
  1579.         <iexpr>     the integer expression indicating the repeat count
  1580.  
  1581.         <expr>...   the expressions evaluated <iexpr> times
  1582.  
  1583.         returns     the value of the last expression
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.     XLISP: An Experimental Object Oriented Language                Page 22
  1590.  
  1591.     ARITHMETIC FUNCTIONS
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.     16.0  ARITHMETIC FUNCTIONS
  1598.  
  1599.  
  1600.  
  1601.     (+ <expr>...)  ADD A LIST OF NUMBERS
  1602.  
  1603.         <expr>...   the numbers
  1604.  
  1605.         returns     the result of the addition
  1606.  
  1607.  
  1608.  
  1609.     (- <expr>...)  SUBTRACT A LIST OF NUMBERS
  1610.  
  1611.         <expr>...   the numbers
  1612.  
  1613.         returns     the result of the subtraction
  1614.  
  1615.  
  1616.  
  1617.     (* <expr>...)  MULTIPLY A LIST OF NUMBERS
  1618.  
  1619.         <expr>...   the numbers
  1620.  
  1621.         returns     the result of the multiplication
  1622.  
  1623.  
  1624.  
  1625.     (/ <expr>...)  DIVIDE A LIST OF NUMBERS
  1626.  
  1627.         <expr>...   the numbers
  1628.  
  1629.         returns     the result of the division
  1630.  
  1631.  
  1632.  
  1633.     (1+ <expr>)  ADD ONE TO A NUMBER
  1634.  
  1635.         <expr>      the number
  1636.  
  1637.         returns     the number plus one
  1638.  
  1639.  
  1640.  
  1641.     (1- <expr>)  SUBTRACT ONE FROM A NUMBER
  1642.  
  1643.         <expr>      the number
  1644.  
  1645.         returns     the number minus one
  1646.  
  1647.  
  1648.  
  1649.     (rem <expr>...)  REMAINDER OF A LIST OF NUMBERS
  1650.  
  1651.         <expr>...   the numbers
  1652.  
  1653.         returns     the result of the remainder operation
  1654.  
  1655.  
  1656.  
  1657.     (minus <expr>)  NEGATE A NUMBER
  1658.  
  1659.         <expr>      the number
  1660.  
  1661.         returns     the number negated
  1662.  
  1663.  
  1664.  
  1665.     (min <expr>...)  THE SMALLEST OF A LIST OF NUMBERS
  1666.  
  1667.         <expr>...   the expressions to be checked
  1668.  
  1669.         returns     the smallest number in the list
  1670.  
  1671.  
  1672.  
  1673.     (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  1674.  
  1675.         <expr>...   the expressions to be checked
  1676.  
  1677.         returns     the largest number in the list
  1678.  
  1679.  
  1680.  
  1681.     (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  1682.  
  1683.         <expr>      the number
  1684.  
  1685.         returns     the absolute value of the number
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.     XLISP: An Experimental Object Oriented Language                Page 23
  1692.  
  1693.     BITWISE LOGICAL FUNCTIONS
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.     17.0  BITWISE LOGICAL FUNCTIONS
  1700.  
  1701.  
  1702.  
  1703.     (bit-and <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  1704.  
  1705.         <expr>      the numbers
  1706.  
  1707.         returns     the result of the and operation
  1708.  
  1709.  
  1710.  
  1711.     (bit-ior <expr...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  1712.  
  1713.         <expr>      the numbers
  1714.  
  1715.         returns     the result of the inclusive or operation
  1716.  
  1717.  
  1718.  
  1719.     (bit-xor <expr...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  1720.  
  1721.         <expr>      the numbers
  1722.  
  1723.         returns     the result of the exclusive or operation
  1724.  
  1725.  
  1726.  
  1727.     (bit-not <expr>)  THE BITWISE NOT OF A NUMBER
  1728.  
  1729.         <expr>      the number
  1730.  
  1731.         returns     the bitwise inversion of number
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.     XLISP: An Experimental Object Oriented Language                Page 24
  1738.  
  1739.     RELATIONAL FUNCTIONS
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.     18.0  RELATIONAL FUNCTIONS
  1746.  
  1747.  
  1748.  
  1749.     The relational functions can be used to compare integers  or
  1750.  
  1751.     strings.   The  functions  '='  and '/=' can also be used to
  1752.  
  1753.     compare other types.  The result  of  these  comparisons  is
  1754.  
  1755.     computed the same way as for 'eq'.
  1756.  
  1757.  
  1758.  
  1759.     (< <e1> <e2>)  TEST FOR LESS THAN
  1760.  
  1761.         <e1>        the left operand of the comparison
  1762.  
  1763.         <e2>        the right operand of the comparison
  1764.  
  1765.         returns     the result of comparing <e1> with <e2>
  1766.  
  1767.  
  1768.  
  1769.     (<= <e1> <e2>)  TEST FOR LESS THAN OR EQUAL TO
  1770.  
  1771.         <e1>        the left operand of the comparison
  1772.  
  1773.         <e2>        the right operand of the comparison
  1774.  
  1775.         returns     the result of comparing <e1> with <e2>
  1776.  
  1777.  
  1778.  
  1779.     (= <e1> <e2>)  TEST FOR EQUAL TO
  1780.  
  1781.         <e1>        the left operand of the comparison
  1782.  
  1783.         <e2>        the right operand of the comparison
  1784.  
  1785.         returns     the result of comparing <e1> with <e2>
  1786.  
  1787.  
  1788.  
  1789.     (/= <e1> <e2>)  TEST FOR NOT EQUAL TO
  1790.  
  1791.         <e1>        the left operand of the comparison
  1792.  
  1793.         <e2>        the right operand of the comparison
  1794.  
  1795.         returns     the result of comparing <e1> with <e2>
  1796.  
  1797.  
  1798.  
  1799.     (>= <e1> <e2>)  TEST FOR GREATER THAN OR EQUAL TO
  1800.  
  1801.         <e1>        the left operand of the comparison
  1802.  
  1803.         <e2>        the right operand of the comparison
  1804.  
  1805.         returns     the result of comparing <e1> with <e2>
  1806.  
  1807.  
  1808.  
  1809.     (> <e1> <e2>)  TEST FOR GREATER THAN
  1810.  
  1811.         <e1>        the left operand of the comparison
  1812.  
  1813.         <e2>        the right operand of the comparison
  1814.  
  1815.         returns     the result of comparing <e1> with <e2>
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.     XLISP: An Experimental Object Oriented Language                Page 25
  1822.  
  1823.     STRING FUNCTIONS
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.     19.0  STRING FUNCTIONS
  1830.  
  1831.  
  1832.  
  1833.     (strcat <expr>...)  CONCATENATE STRINGS
  1834.  
  1835.         <expr>...   the strings to concatenate
  1836.  
  1837.         returns     the result of concatenating the strings
  1838.  
  1839.  
  1840.  
  1841.     (strlen <expr>)  COMPUTE THE LENGTH OF A STRING
  1842.  
  1843.         <expr>      the string
  1844.  
  1845.         returns     the length of the string
  1846.  
  1847.  
  1848.  
  1849.     (substr <expr> <sexpr> [<lexpr>]) EXTRACT A SUBSTRING
  1850.  
  1851.         <expr>      the string
  1852.  
  1853.         <sexpr>     the starting position
  1854.  
  1855.         <lexpr>     the length (default is rest of string)
  1856.  
  1857.         returns     substring starting at <sexpr> for <lexpr>
  1858.  
  1859.  
  1860.  
  1861.     (ascii <expr>)  NUMERIC VALUE OF CHARACTER
  1862.  
  1863.         <expr>      the string
  1864.  
  1865.         returns     the ascii code of the first character
  1866.  
  1867.  
  1868.  
  1869.     (chr <expr>)  CHARACTER EQUIVALENT OF ASCII VALUE
  1870.  
  1871.         <expr>      the numeric expression
  1872.  
  1873.         returns     a one character string whose first character is <expr>
  1874.  
  1875.  
  1876.  
  1877.     (atoi <expr>)  CONVERT AN ASCII STRING TO AN INTEGER
  1878.  
  1879.         <expr>      the string
  1880.  
  1881.         returns     the integer value of the string expression
  1882.  
  1883.  
  1884.  
  1885.     (itoa <expr>)  CONVERT AN INTEGER TO AN ASCII STRING
  1886.  
  1887.         <expr>      the integer
  1888.  
  1889.         returns     the string representation of the integer value
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.     XLISP: An Experimental Object Oriented Language                Page 26
  1896.  
  1897.     INPUT/OUTPUT FUNCTIONS
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.     20.0  INPUT/OUTPUT FUNCTIONS
  1904.  
  1905.  
  1906.  
  1907.     (read [<source>[<eof>]])  READ AN XLISP EXPRESSION
  1908.  
  1909.         <source>    the input source (default is standard input)
  1910.  
  1911.         <eof>       the value to return on end of file (default is nil)
  1912.  
  1913.         returns     the expression read
  1914.  
  1915.  
  1916.  
  1917.     (print <expr> [<sink>])  PRINT A LIST OF VALUES ON A NEW LINE
  1918.  
  1919.         <expr>      the expressions to be printed
  1920.  
  1921.         <sink>      the output sink (default is standard output)
  1922.  
  1923.         returns     nil
  1924.  
  1925.  
  1926.  
  1927.     (prin1 <expr> [<sink>])  PRINT A LIST OF VALUES
  1928.  
  1929.         <expr>      the expressions to be printed
  1930.  
  1931.         <sink>      the output sink (default is standard output)
  1932.  
  1933.         returns     nil
  1934.  
  1935.  
  1936.  
  1937.     (princ <expr> [<sink>])  PRINT A LIST OF VALUES WITHOUT QUOTING
  1938.  
  1939.         <expr>      the expressions to be printed
  1940.  
  1941.         <sink>      the output sink (default is standard output)
  1942.  
  1943.         returns     nil
  1944.  
  1945.  
  1946.  
  1947.     (terpri [<sink>])  TERMINATE THE CURRENT PRINT LINE
  1948.  
  1949.         <sink>      the output sink (default is standard output)
  1950.  
  1951.         returns     nil
  1952.  
  1953.  
  1954.  
  1955.     (flatsize <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRIN1
  1956.  
  1957.         <expr>      the expression
  1958.  
  1959.         returns     the length
  1960.  
  1961.  
  1962.  
  1963.     (flatc <expr>)  LENGTH OF PRINTED REPRESENTATION USING PRINC
  1964.  
  1965.         <expr>      the expression
  1966.  
  1967.         returns     the length
  1968.  
  1969.  
  1970.  
  1971.     (explode <expr>)  CHARACTERS IN PRINTED REPRESENTATION USING PRIN1
  1972.  
  1973.         <expr>      the expression
  1974.  
  1975.         returns     the list of characters
  1976.  
  1977.  
  1978.  
  1979.     (explodec <expr>)  CHARACTERS IN PRINTED REPRESENTATION USING PRINC
  1980.  
  1981.         <expr>      the expression
  1982.  
  1983.         returns     the list of characters
  1984.  
  1985.  
  1986.  
  1987.     (maknam <list>)  BUILD AN UNINTERNED SYMBOL FROM A LIST OF CHARACTERS
  1988.  
  1989.         <list>      list of characters in symbol name
  1990.  
  1991.         returns     the symbol
  1992.  
  1993.  
  1994.  
  1995.     (implode <list>)  BUILD AN INTERNED SYMBOL FROM A LIST OF CHARACTERS
  1996.  
  1997.         <list>      list of characters in symbol name
  1998.  
  1999.         returns     the symbol
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.     XLISP: An Experimental Object Oriented Language                Page 27
  2006.  
  2007.     FILE I/O FUNCTIONS
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.     21.0  FILE I/O FUNCTIONS
  2014.  
  2015.  
  2016.  
  2017.     (openi <fname>)  OPEN AN INPUT FILE
  2018.  
  2019.         <fname>     the file name string
  2020.  
  2021.         returns     a file pointer
  2022.  
  2023.  
  2024.  
  2025.     (openo <fname>)  OPEN AN OUTPUT FILE
  2026.  
  2027.         <fname>     the file name string
  2028.  
  2029.         returns     a file pointer
  2030.  
  2031.  
  2032.  
  2033.     (close <fp>)  CLOSE A FILE
  2034.  
  2035.         <fp>        the file pointer
  2036.  
  2037.         returns     nil
  2038.  
  2039.  
  2040.  
  2041.     (read-char [<source>])  READ A CHARACTER FROM A FILE OR STREAM
  2042.  
  2043.         <source>    the input source (default is standard input)
  2044.  
  2045.         returns     the character (integer)
  2046.  
  2047.  
  2048.  
  2049.     (peek-char [<flag> [<source>]])  PEEK AT THE NEXT CHARACTER
  2050.  
  2051.         <flag>      flag for skipping white space (default is nil)
  2052.  
  2053.         <source>    the input source (default is standard input)
  2054.  
  2055.         returns     the character (integer)
  2056.  
  2057.  
  2058.  
  2059.     (write-char <ch> [<sink>])  WRITE A CHARACTER TO A FILE OR STREAM
  2060.  
  2061.         <ch>        the character to put (integer)
  2062.  
  2063.         <sink>      the output sink (default is standard output)
  2064.  
  2065.         returns     the character (integer)
  2066.  
  2067.  
  2068.  
  2069.     (readline [<source>])  READ A LINE FROM A FILE OR STREAM
  2070.  
  2071.         <source>    the input source (default is standard input)
  2072.  
  2073.         returns     the input string
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.     XLISP: An Experimental Object Oriented Language                Page 28
  2080.  
  2081.     SYSTEM FUNCTIONS
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.     22.0  SYSTEM FUNCTIONS
  2088.  
  2089.  
  2090.  
  2091.     (load <fname>)  LOAD AN XLISP SOURCE FILE
  2092.  
  2093.         <fname>     the filename string (".lsp" is appended)
  2094.  
  2095.         returns     the filename
  2096.  
  2097.  
  2098.  
  2099.     (gc)  FORCE GARBAGE COLLECTION
  2100.  
  2101.         returns     nil
  2102.  
  2103.  
  2104.  
  2105.     (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  2106.  
  2107.         <num>       the number of segments to add
  2108.  
  2109.         returns     the number of segments added
  2110.  
  2111.  
  2112.  
  2113.     (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  2114.  
  2115.         <num>       the number of nodes to allocate
  2116.  
  2117.         returns     the old number of nodes to allocate
  2118.  
  2119.  
  2120.  
  2121.     (mem)  SHOW MEMORY ALLOCATION STATISTICS
  2122.  
  2123.         returns     nil
  2124.  
  2125.  
  2126.  
  2127.     (type <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  2128.  
  2129.         <expr>      the expression to return the type of
  2130.  
  2131.         returns     nil if the value is nil otherwise one of the symbols:
  2132.  
  2133.                         SYM   for symbols
  2134.  
  2135.                         OBJ   for objects
  2136.  
  2137.                         LIST  for list nodes
  2138.  
  2139.                         SUBR  for subroutine nodes with evaluated arguments
  2140.  
  2141.                         FSUBR for subroutine nodes with unevaluated arguments
  2142.  
  2143.                         STR   for string nodes
  2144.  
  2145.                         INT   for integer nodes
  2146.  
  2147.                         FPTR  for file pointer nodes
  2148.  
  2149.  
  2150.  
  2151.     (exit)  EXIT XLISP
  2152.  
  2153.         returns     never returns
  2154.  
  2155. d
  2156.  
  2157.         returns     the number of segments added
  2158.  
  2159.  
  2160.  
  2161.     (