home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / os2 / impnotes.txt < prev    next >
Encoding:
Text File  |  1994-08-28  |  64.8 KB  |  1,808 lines

  1.                 Implementation Notes for CLISP
  2.                 ==============================
  3.                 Last modified: 13 August 1994.
  4.  
  5. This implementation is mostly compatible to the standard reference
  6.  
  7.        Guy L. Steele Jr.: Common Lisp - The Language (1st ed.).
  8.        Digital Press 1984, 465 pages.
  9.        ("CLtL1" for short)
  10.  
  11. and to the older parts of
  12.  
  13.        Guy L. Steele Jr.: Common Lisp - The Language (2nd ed.).
  14.        Digital Press 1990, 1032 pages.
  15.        ("CLtL2" for short)
  16.  
  17.  
  18. These notes document the differences of the CLISP implementation of Common
  19. Lisp to the standard CLtL1, and some implementation details.
  20.  
  21. The differences between CLtL1 and CLtL2 are made up of X3J13 votes. CLISP's
  22. position with respect to these votes is listed in cltl2.txt.
  23.  
  24.  
  25.                       CHAPTER 1: Introduction
  26.                       -----------------------
  27.  
  28. No notes.
  29.  
  30.  
  31.                        CHAPTER 2: Data Types
  32.                        ---------------------
  33.  
  34. All the data types are implemented: numbers, characters, symbols, lists,
  35. arrays, hash tables, readtables, packages, pathnames, streams, random
  36. states, structures and functions.
  37.  
  38. 2.1.3.
  39. ------
  40.  
  41. There are four floating point types: short-float, single-float, double-float
  42. and long-float:
  43.                   sign    mantissa   exponent
  44.    short-float    1 bit   16+1 bits   8 bits
  45.    single-float   1 bit   23+1 bits   8 bits   CLISP uses IEEE format
  46.    double-float   1 bit   52+1 bits  11 bits   CLISP uses IEEE format
  47.    long-float     1 bit   >=64 bits  32 bits
  48.  
  49. The single and double float formats are those of the IEEE standard (1981),
  50. except that CLISP does not support features like +0, -0, +inf, -inf, gradual
  51. underflow, NaN, etc. (Common Lisp does not make use of these features.)
  52.  
  53. Long floats have variable mantissa length, which is a multiple of 16 (or 32,
  54. depending on the word size of the processor). The default length used when
  55. long floats are read is given by the place (LONG-FLOAT-DIGITS). It can be
  56. set by (SETF (LONG-FLOAT-DIGITS) nnn), where nnn is a positive integer.
  57.  
  58. 2.1.4.
  59. ------
  60.  
  61. Complex numbers can have a real part and an imaginary part of different
  62. types. For example, (SQRT -9.0) evaluates to the number #C(0 3.0), which has
  63. a real part of exactly 0, not only 0.0 (which would mean "approximately 0").
  64. The type specifier for this is (COMPLEX INTEGER SINGLE-FLOAT), and
  65.  
  66.            (COMPLEX type-of-real-part type-of-imaginary-part)
  67.  
  68. in general.
  69. The type specifier (COMPLEX type) is equivalent to (COMPLEX type type).
  70.  
  71. 2.2.1.
  72. ------
  73.  
  74. The characters are ordered according to the ASCII encoding.
  75.  
  76. More precisely, CLISP uses the IBM PC character set (code page 437):
  77.              $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $A $B $C $D $E $F
  78.          $00 **                   ** ** ** ** ** ** **  ╢  º
  79.          $10                               ** **            
  80.          $20     !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /
  81.          $30  0  1  2  3  4  5  6  7  8  9  :  ;  <  =  >  ?
  82.          $40  @  A  B  C  D  E  F  G  H  I  J  K  L  M  N  O
  83.          $50  P  Q  R  S  T  U  V  W  X  Y  Z  [  \  ]  ^  _
  84.          $60  `  a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
  85.          $70  p  q  r  s  t  u  v  w  x  y  z  {  |  }  ~  
  86.          $80  ╟  ⁿ  Θ  Γ  Σ  α  σ  τ  Ω  δ  Φ  ∩  ε  ∞  ─  ┼
  87.          $90  ╔  µ  ╞  ⌠  ÷  ≥  √  ∙     ╓  ▄  ó  ú  Ñ      
  88.          $A0  ß  φ  ≤  ·  ±  ╤  ¬  ║  ┐     ¼  ╜  ╝  í  ½  ╗
  89.          $B0                                                
  90.          $C0                                                
  91.          $D0                                                
  92.          $E0     ▀              ╡                           
  93.          $F0     ▒              ≈     ░     ╖        ▓      
  94. Here ** are control characters, not graphic characters. (The characters left
  95. blank here cannot be represented in this character set).
  96.  
  97. The following are standard characters:
  98.   #\Space               $20
  99.   #\Newline             $0A
  100. The following are semi-standard characters:
  101.   #\Backspace           $08
  102.   #\Tab                 $09
  103.   #\Linefeed            $0A
  104.   #\Page                $0C
  105.   #\Return              $0D
  106.   #\Rubout              $08
  107.  
  108. 2.2.2.
  109. ------
  110.  
  111. #\Newline is the delimiter between lines.
  112.  
  113. When writing to a file, #\Newline is converted to CR/LF. (This is the usual
  114. convention on ATARI and DOS.) For example, #\Return #\Newline is written
  115. as CR/CR/LF.
  116. When reading from a file, CR/LF is converted to #\Newline, and CR not
  117. followed by LF is read as #\Return.
  118.  
  119. 2.2.3.
  120. ------
  121.  
  122. There are the following additional characters with names:
  123.   #\Null                $00
  124.   #\Bell                $07
  125.   #\Escape              $1B
  126.  
  127. 2.2.4.
  128. ------
  129.  
  130. The code of a character is >=0, <256. CHAR-CODE-LIMIT = 256.
  131.  
  132. There are fonts 0 to 15, and CHAR-FONT-LIMIT = 16. But the system itself
  133. uses only font 0.
  134.  
  135. The following bits attributes are implemented: :CONTROL, :META, :SUPER,
  136. :HYPER. Therefore CHAR-BITS-LIMIT = 16.
  137. The system itself uses these bits only to mention special keys and
  138. Control/Alternate/Shift key status on return from
  139. (READ-CHAR *KEYBOARD-INPUT*).
  140.  
  141. 2.5.
  142. ----
  143.  
  144. The maximum rank (number of dimensions) of an array is 65535 on 16-bit
  145. processors, 4294967295 on 32-bit processors.
  146.  
  147. 2.13.
  148. -----
  149.  
  150. All the functions built by FUNCTION, COMPILE and the like are atoms. There
  151. are built-in functions written in C, compiled functions (both of type
  152. COMPILED-FUNCTION) and interpreted functions (of type FUNCTION).
  153. The possible function names (CLtL1 p. 59) are symbols and lambda expressions.
  154.  
  155. 2.14.
  156. -----
  157.  
  158. This is the list of objects whose external representation can not be
  159. meaningfully read in:
  160.   * all structures lacking a keyword constructor.
  161.   * all arrays except strings, if *PRINT-ARRAY* = NIL.
  162.   * #<SYSTEM-FUNCTION name>     built-in function written in C
  163.   * #<SPECIAL-FORM name>        special form handler
  164.   * #<COMPILED-CLOSURE name>    compiled function, if *PRINT-CLOSURE* = NIL
  165.   * #<CLOSURE name ...>         interpreted function
  166.   * #<FRAME-POINTER #x...>      pointer to a stack frame
  167.   * #<DISABLED POINTER>         frame pointer which has become invalid on
  168.                                 exit from the corresponding BLOCK or TAGBODY
  169.   * #<...-STREAM ...>           stream
  170.   * #<PACKAGE name>             package
  171.   * #<HASH-TABLE #x...>         hash table, if *PRINT-ARRAY* = NIL
  172.   * #<READTABLE #x...>          readtable
  173.   * #<UNBOUND>                  "value" of a symbol without value, "value"
  174.                                 of an unsupplied optional or keyword argument
  175.   * #<SPECIAL REFERENCE>        environment marker for variables declared
  176.                                 SPECIAL
  177.   * #<DOT>                      internal READ result for "."
  178.   * #<END OF FILE>              internal READ result, when the end of file
  179.                                 is reached
  180.   * #<READ-LABEL ...>           intermediate READ result for #n#
  181.   * #<ADDRESS #x...>            machine address, should not occur
  182.   * #<SYSTEM-POINTER #x...>     should not occur
  183.  
  184. 2.15.
  185. -----
  186.  
  187. The type NUMBER is the disjoint union of the types REAL and COMPLEX. (CLtL
  188. wording: "exhaustive partition")
  189. The type REAL is the disjoint union of the types RATIONAL and FLOAT.
  190. The type RATIONAL is the disjoint union of the types INTEGER and RATIO.
  191. The type INTEGER is the disjoint union of the types FIXNUM and BIGNUM.
  192. The type FLOAT is the disjoint union of the types SHORT-FLOAT, SINGLE-FLOAT,
  193. DOUBLE-FLOAT and LONG-FLOAT.
  194.  
  195.  
  196.                      CHAPTER 3: Scope and Extent
  197.                      ---------------------------
  198.  
  199. is implemented as described.
  200.  
  201.  
  202.                       CHAPTER 4: Type Specifiers
  203.                       --------------------------
  204.  
  205. 4.4.
  206. ----
  207.  
  208. The CLtL2 type specifier (EQL object) denotes the singleton set {object}.
  209.  
  210. 4.5.
  211. ----
  212.  
  213. The general form of the COMPLEX type specifier is
  214. (COMPLEX type-of-real-part type-of-imaginary-part).
  215. The type specifier (COMPLEX type) is equivalent to (COMPLEX type type).
  216.  
  217. 4.6.
  218. ----
  219.  
  220. The CLtL2 type specifier (REAL low high) denotes the real numbers between low
  221. and high.
  222.  
  223. 4.7.
  224. ----
  225.  
  226. DEFTYPE lambda lists are subject to destructuring (nested lambda lists are
  227. allowed, as in DEFMACRO) and may contain a &WHOLE marker, but no
  228. &ENVIRONMENT marker.
  229.  
  230. 4.9.
  231. ----
  232.  
  233. The possible results of TYPE-OF are:
  234.  CONS
  235.  SYMBOL NULL
  236.  FIXNUM BIGNUM RATIO SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT COMPLEX
  237.  CHARACTER
  238.  (ARRAY element-type dimensions), (SIMPLE-ARRAY element-type dimensions)
  239.  (VECTOR T size), (SIMPLE-VECTOR size)
  240.  (STRING size), (SIMPLE-STRING size)
  241.  (BIT-VECTOR size), (SIMPLE-BIT-VECTOR size)
  242.  FUNCTION COMPILED-FUNCTION
  243.  STREAM PACKAGE HASH-TABLE READTABLE PATHNAME RANDOM-STATE
  244.  BYTE LOAD-TIME-EVAL SYMBOL-MACRO READ-LABEL FRAME-POINTER SYSTEM-INTERNAL
  245.  ADDRESS (should not occur)
  246.  any other symbol (structure types or CLOS classes)
  247.  a class (CLOS classes without proper name)
  248.  
  249.  
  250.                        CHAPTER 5: Program Structure
  251.                        ----------------------------
  252.  
  253. 5.1.3.
  254. ------
  255.  
  256. In addition to the 24 special forms listed on p. 57 (CLtL2: p. 73), the
  257. CLtL2 special forms LOCALLY, SYMBOL-MACROLET, LOAD-TIME-VALUE are implemented,
  258. and the macros
  259. PSETQ, PROG1, PROG2, WHEN, UNLESS, COND, MULTIPLE-VALUE-LIST,
  260. MULTIPLE-VALUE-BIND, MULTIPLE-VALUE-SETQ, AND, OR
  261. are implemented as special forms.
  262.  
  263. Constants may not be bound dynamically or lexically.
  264.  
  265. 5.2.2.
  266. ------
  267.  
  268. LAMBDA-LIST-KEYWORDS =
  269.     (&OPTIONAL &REST &KEY &ALLOW-OTHER-KEYS &AUX &BODY &WHOLE &ENVIRONMENT)
  270.  
  271. LAMBDA-PARAMETERS-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  272. processors.
  273.  
  274. 5.3.
  275. ----
  276.  
  277. DEFUN and DEFMACRO are allowed in non-toplevel positions.
  278. As an example, consider the definition of GENSYM:
  279. (let ((gensym-prefix "G")
  280.       (gensym-count 1))
  281.   (defun gensym (&optional (x nil s))
  282.     (when s
  283.       (cond ((stringp x) (setq gensym-prefix x))
  284.             ((integerp x)
  285.              (if (minusp x)
  286.                (error "~S: index ~S is negative" 'gensym x)
  287.                (setq gensym-count x)
  288.             ))
  289.             (t (error "~S: argument ~S of wrong type" 'gensym x))
  290.     ) )
  291.     (prog1
  292.       (make-symbol
  293.         (concatenate 'string
  294.           gensym-prefix
  295.           (write-to-string gensym-count :base 10 :radix nil)
  296.       ) )
  297.       (incf gensym-count)
  298. ) )
  299.  
  300. 5.3.2.
  301. ------
  302.  
  303. (PROCLAIM '(SPECIAL var)) declarations may not be undone. The same holds
  304. for DEFVAR, DEFPARAMETER and DEFCONSTANT declarations.
  305.  
  306. It is an error if a DEFCONSTANT variable is bound at the moment the
  307. DEFCONSTANT is executed, but DEFCONSTANT does not check this.
  308.  
  309. Constants may not be bound dynamically or lexically.
  310.  
  311.  
  312.                       CHAPTER 6: Predicates
  313.                       ---------------------
  314.  
  315. 6.2.2.
  316. ------
  317.  
  318. REALP returns T is its argument is a real number, NIL otherwise.
  319.  
  320. COMPILED-FUNCTION-P returns T on built-in functions written in C, compiled
  321. functions and special form handlers. Therefore COMPILED-FUNCTION is not a
  322. subtype of FUNCTION.
  323.  
  324. 6.3.
  325. ----
  326.  
  327. EQ compares characters and fixnums as EQL does. No unnecessary copies are
  328. made of characters and numbers. Nevertheless, one should use EQL.
  329.  
  330. (let ((x y)) (eq x x)) always returns T, regardless of y.
  331.  
  332. 6.4.
  333. ----
  334.  
  335. AND and OR are implemented as special forms and, as such, rather efficient.
  336.  
  337.  
  338.                       CHAPTER 7: Control Structure
  339.                       ----------------------------
  340.  
  341. 7.1.1.
  342. ------
  343.  
  344. (FUNCTION symbol) returns the local function definition established by FLET
  345. or LABELS, if it exists, otherwise the global function definition.
  346.  
  347. The CLtL2 place (FDEFINITION function-name) is implemented.
  348.  
  349. (SPECIAL-FORM-P symbol) returns NIL or T. If it returns T, then
  350. (SYMBOL-FUNCTION symbol) returns the (useless) special form handler.
  351.  
  352. 7.1.2.
  353. ------
  354.  
  355. PSETQ is implemented as a special form and, as such, rather efficient.
  356.  
  357. 7.2.
  358. ----
  359.  
  360. (SETF (SYMBOL-FUNCTION symbol) object) requires object to be either a
  361. function, a SYMBOL-FUNCTION return value or a lambda expression. A lambda
  362. expression is thereby immediately converted to a function.
  363.  
  364. SETF also accepts places yielding multiple values.
  365.  
  366. Additional places:
  367.  
  368. * FUNCALL:
  369.   (SETF (FUNCALL #'symbol ...) object) and
  370.   (SETF (FUNCALL 'symbol ...) object)
  371.   are equivalent to (SETF (symbol ...) object).
  372.  
  373. * GET-DISPATCH-MACRO-CHARACTER:
  374.   (SETF (GET-DISPATCH-MACRO-CHARACTER ...) ...)
  375.   performs a SET-DISPATCH-MACRO-CHARACTER.
  376.  
  377. * LONG-FLOAT-DIGITS:
  378.   (SETF (LONG-FLOAT-DIGITS) digits) sets the default mantissa length of long
  379.   floats to digits bits.
  380.  
  381. * VALUES:
  382.   (SETF (VALUES place1 ... placek) form)
  383.   is approximately equivalent to
  384.      (MULTIPLE-VALUE-BIND (dummy1 ... dummyk) form
  385.        (SETF place1 dummy1 ... placek dummyk)
  386.        (VALUES dummy1 ... dummyk)
  387.      )
  388.   Example:
  389.     (SETF (VALUES A B) (VALUES B A)) interchanges the values of A and B.
  390.  
  391. * VALUES-LIST:
  392.   (SETF (VALUES-LIST list) form)  is equivalent to
  393.   (VALUES-LIST (SETF list (MULTIPLE-VALUE-LIST form)))
  394.  
  395. &KEY markers in DEFSETF lambda lists are supported, but the corresponding
  396. keywords must appear literally in the program text.
  397.  
  398. (GET-SETF-METHOD form &optional env) and
  399. (GET-SETF-METHOD-MULTIPLE-VALUE form &optional env)
  400. receives as optional argument the environment necessary for macro expansions.
  401. In DEFINE-SETF-METHOD lambda lists, one can specify &ENVIRONMENT and a
  402. variable, which will be bound to the environment. This environment should be
  403. passed to all calls of GET-SETF-METHOD and GET-SETF-METHOD-MULTIPLE-VALUE.
  404. If this is done, even local macros will be interpreted as places correctly.
  405.  
  406. 7.3.
  407. ----
  408.  
  409. CALL-ARGUMENTS-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  410. processors.
  411.  
  412. 7.4.
  413. ----
  414.  
  415. PROG1 and PROG2 are implemented as special forms and, as such, rather
  416. efficient.
  417.  
  418. 7.5.
  419. ----
  420.  
  421. The CLtL2 special form SYMBOL-MACROLET is implemented.
  422.  
  423. The macro DEFINE-SYMBOL-MACRO establishes symbol macros with global scope
  424. (as opposed to symbol macros defined with SYMBOL-MACROLET, which have local
  425. scope): (DEFINE-SYMBOL-MACRO symbol expansion). Calling BOUNDP, SYMBOL-VALUE
  426. or MAKUNBOUND on symbols defined as symbol macros is not allowed.
  427.  
  428. If using the optional package MACROS3:
  429.   The macros LETF and LETF* are like LET and LET*, resp., except that they
  430.   can bind places, even places with multiple values.
  431.   Example:
  432.   (LETF (((VALUES A B) form)) ...)
  433.     is equivalent to
  434.     (MULTIPLE-VALUE-BIND (A B) form ...)
  435.   (LETF (((FIRST L) 7)) ...)
  436.     is approximately equivalent to
  437.     (LET* ((#:G1 L) (#:G2 (FIRST #:G1)))
  438.       (UNWIND-PROTECT (PROGN (SETF (FIRST #:G1) 7) ...)
  439.                       (SETF (FIRST #:G1) #:G2)
  440.     ) )
  441.  
  442. 7.6.
  443. ----
  444.  
  445. WHEN, UNLESS, COND are implemented as special forms and, as such, rather
  446. efficient.
  447.  
  448. 7.8.4.
  449. ------
  450.  
  451. The function MAPCAP is like MAPCAN, except that it concatenates the
  452. resulting lists with APPEND instead of NCONC:
  453.   (MAPCAP fun x1 ... xn) == (apply #'append (mapcar fun x1 ... xn))
  454. (Actually a bit more efficient that this would be.)
  455.  
  456. The function MAPLAP is like MAPCON, except that it concatenates the
  457. resulting lists with APPEND instead of NCONC:
  458.   (MAPLAP fun x1 ... xn) = (apply #'append (maplist fun x1 ... xn))
  459. (Actually a bit more efficient that this would be.)
  460.  
  461. 7.9.1.
  462. ------
  463.  
  464. MULTIPLE-VALUES-LIMIT = 128
  465.  
  466. MULTIPLE-VALUE-LIST, MULTIPLE-VALUE-BIND, MULTIPLE-VALUE-SETQ are
  467. implemented as special forms and, as such, rather efficient.
  468.  
  469. The macro NTH-VALUE:
  470. (NTH-VALUE n form) returns the (n+1)st value (n>=0) of form.
  471.  
  472.  
  473.                         CHAPTER 8: Macros
  474.                         -----------------
  475.  
  476. 8.3.
  477. ----
  478.  
  479. The CLtL2 macro DESTRUCTURING-BIND is implemented. It does not perform full
  480. error checking.
  481.  
  482.  
  483.                      CHAPTER 9: Declarations
  484.                      -----------------------
  485.  
  486. 9.1.
  487. ----
  488.  
  489. The CLtL2 macro DECLAIM is implemented.
  490.  
  491. 9.2.
  492. ----
  493.  
  494. The declarations (TYPE type var ...), (FTYPE type fun ...),
  495. (FUNCTION name arglist result-type), (OPTIMIZE (quality value) ...)
  496. are ignored by the interpreter and the compiler.
  497.  
  498. The CLtL2 declaration (OPTIMIZE (DEBUG ...)) is legal.
  499.  
  500. Additional declarations:
  501.  
  502. * The declaration (COMPILE) has the effect that the current form is compiled
  503.   prior to execution.
  504.   Examples:
  505.   (LOCALLY (DECLARE (COMPILE)) form)
  506.   executes a compiled version of form.
  507.   (let ((x 0))
  508.     (flet ((inc () (declare (compile)) (incf x))
  509.            (dec () (decf x)))
  510.       (values #'inc #'dec)
  511.   ) )
  512.   returns two functions. The first is compiled and increments x, the second
  513.   is interpreted (slower) and decrements the same x.
  514.  
  515. 9.3.
  516. ----
  517.  
  518. The type assertion (THE value-type form) enforces a type check in
  519. interpreted code. No type check is done in compiled code.
  520.  
  521. If using the optional package MACROS3:
  522. (ETHE value-type form) enforces a type check in both interpreted and
  523. compiled code.
  524.  
  525.  
  526.                          CHAPTER 10: Symbols
  527.                          -------------------
  528.  
  529. No notes.
  530.  
  531.  
  532.                          CHAPTER 11: Packages
  533.                          --------------------
  534.  
  535. 11.6.
  536. -----
  537.  
  538. The package SYSTEM has the nicknames "SYS" and, additionally, "COMPILER".
  539.  
  540. The CLtL2 packages
  541. * COMMON-LISP with nickname "CL" and
  542. * COMMON-LISP-USER with nickname "CL-USER"
  543. are implemented. The package COMMON-LISP exports only those symbols
  544. from the proposed ANSI CL draft that are actually implemented.
  545.  
  546. 11.7.
  547. -----
  548.  
  549. The CLtL2 macro DEFPACKAGE is implemented.
  550.  
  551. 11.8.
  552. -----
  553.  
  554. The function REQUIRE receives as optional argument either a pathname or a
  555. list of pathnames: files to be loaded if the required module is not already
  556. in memory.
  557.  
  558.  
  559.                            CHAPTER 12: Numbers
  560.                            -------------------
  561.  
  562. The single and double float formats are those of the IEEE standard (1981),
  563. except that CLISP does not support features like +0, -0, +inf, -inf, gradual
  564. underflow, NaN, etc. (Common Lisp does not make use of these features.)
  565.  
  566. The default number of mantissa bits in long floats is given by the place
  567. (LONG-FLOAT-DIGITS).
  568. Example: (SETF (LONG-FLOAT-DIGITS) 3322) sets the default precision of long
  569. floats to 1000 decimal digits.
  570.  
  571. 12.1.
  572. -----
  573.  
  574. Complex numbers can have a real part and an imaginary part of different
  575. types. If the imaginary part is EQL to 0, the number is automatically
  576. converted to a real number. (Cf. CLtL1 p. 195)
  577. This has the advantage that  (let ((x (sqrt -9.0))) (* x x))
  578. - instead of evaluting to #C(-9.0 0.0), with x = #C(0.0 3.0) -
  579. evaluates to #C(-9.0 0) = -9.0, with x = #C(0 3.0).
  580.  
  581. Coercions on operations involving different types:
  582. The result of an arithmetic operation whose arguments are of different float
  583. types is rounded to the float format of the shortest (least precise) of the
  584. arguments.
  585.     rational -> long float -> double float -> single float -> short float
  586. (in contrast to CLtL1 p. 195!)
  587. Rationale:
  588.   See it mathematically. Add intervals:
  589.   {1.0 +/- 1e-8} + {1.0 +/- 1e-16} = {2.0 +/- 1e-8}
  590.   So, if we add 1.0s0 and 1.0d0, we should get 2.0s0.
  591. Shortly:
  592.   Do not suggest accuracy of a result by giving it a precision that is
  593.   greater than its accuracy.
  594. Example:
  595.   (- (+ 1.7 pi) pi)  should not return  1.700000726342836417234L0,
  596.   it should return 1.7f0 (or 1.700001f0 if there were rounding errors).
  597. Experience:
  598.   If in a computation using thousands of short floats, a long float (like pi)
  599.   happens to be used, the long precision should not propagate throughout all
  600.   the intermediate values. Otherwise, the long result would look precise,
  601.   but its accuracy is only that of a short float; furthermore much
  602.   computation time would be lost by calculating with long floats when only
  603.   short floats would be needed.
  604.  
  605. When rational numbers are to be converted to floats (due to FLOAT, COERCE,
  606. SQRT or a transcendental function), the result type is given by the variable
  607. *DEFAULT-FLOAT-FORMAT*.
  608.  
  609. The macro WITHOUT-FLOATING-POINT-UNDERFLOW:
  610.   (without-floating-point-underflow {form}*)
  611. executes the forms, with errors of type FLOATING-POINT-UNDERFLOW inhibited.
  612. Floating point operations will silently return zero instead of signalling
  613. an error of type FLOATING-POINT-UNDERFLOW.
  614.  
  615. 12.4.
  616. -----
  617.  
  618. (LCM), called without arguments, returns 1, which is the neutral element of
  619. composition with LCM.
  620.  
  621. (! n) returns the factorial of n, n a nonnegative integer.
  622.  
  623. (EXQUO x y) returns the quotient x/y of two integers x,y, and checks that it
  624. is an integer. (This is more efficient than /.)
  625.  
  626. (XGCD x1 ... xn) returns the values g, c1, ..., cn, where
  627. g is the greatest common divisor of the integers x1,...,xn,
  628. and c1,...,cn are integer coefficients such that
  629.   g = (GCD x1 ... xn) = (+ (* c1 x1) ... (* cn xn))
  630.  
  631. 12.5.1.
  632. -------
  633.  
  634. (EXPT base exponent) is not very precise if exponent has large absolute
  635. value.
  636.  
  637. (LOG number base) signals an error if base = 1.
  638.  
  639. 12.5.2.
  640. -------
  641.  
  642. The value of PI is a long float with the precision given by
  643. (LONG-FLOAT-DIGITS). When this precision is changed, the value of PI is
  644. automatically recomputed. Therefore PI is a variable, not a constant.
  645.  
  646. 12.6.
  647. -----
  648.  
  649. FLOAT-RADIX always returns 2.
  650.  
  651. (FLOAT-DIGITS number digits) coerces `number' (a real number) to a floating
  652. point number with at least `digits' mantissa digits. The following holds:
  653.    (>= (FLOAT-DIGITS (FLOAT-DIGITS number digits)) digits)
  654.  
  655. 12.7.
  656. -----
  657.  
  658. BOOLE-CLR   =  0
  659. BOOLE-SET   = 15
  660. BOOLE-1     = 10
  661. BOOLE-2     = 12
  662. BOOLE-C1    =  5
  663. BOOLE-C2    =  3
  664. BOOLE-AND   =  8
  665. BOOLE-IOR   = 14
  666. BOOLE-XOR   =  6
  667. BOOLE-EQV   =  9
  668. BOOLE-NAND  =  7
  669. BOOLE-NOR   =  1
  670. BOOLE-ANDC1 =  4
  671. BOOLE-ANDC2 =  2
  672. BOOLE-ORC1  = 13
  673. BOOLE-ORC2  = 11
  674.  
  675. 12.10.
  676. ------
  677.  
  678. MOST-POSITIVE-FIXNUM = 2^24-1 = 16777215
  679. MOST-NEGATIVE-FIXNUM = -2^24 = -16777216
  680.  
  681. Together with PI, the other long float constants MOST-POSITIVE-LONG-FLOAT,
  682. LEAST-POSITIVE-LONG-FLOAT, LEAST-NEGATIVE-LONG-FLOAT,
  683. MOST-NEGATIVE-LONG-FLOAT, LONG-FLOAT-EPSILON, LONG-FLOAT-NEGATIVE-EPSILON
  684. are recomputed whenever (LONG-FLOAT-DIGITS) is changed. They are variables,
  685. not constants.
  686.  
  687.  
  688.                          CHAPTER 13: Characters
  689.                          ----------------------
  690.  
  691. See first above: 2.2.
  692.  
  693. 13.1.
  694. -----
  695.  
  696. CHAR-CODE-LIMIT = 256
  697. CHAR-FONT-LIMIT = 16
  698. CHAR-BITS-LIMIT = 16
  699.  
  700. 13.2.
  701. -----
  702.  
  703. String-chars are those characters with font = 0 and bits = 0.
  704.  
  705. The graphic characters have been described above.
  706.  
  707. The standard characters are #\Newline and those graphic characters with a
  708. code between 32 and 126 (inclusive).
  709.  
  710. The alphabetic characters are these string-chars:
  711.              ABCDEFGHIJKLMNOPQRSTUVWXYZ
  712.              abcdefghijklmnopqrstuvwxyz
  713. and the international alphabetic characters from the character set:
  714.              ╟ⁿΘΓΣαστΩδΦ∩ε∞─┼╔µ╞⌠÷≥√∙ ╓▄▀ßφ≤·±╤¬║A etc.
  715.  
  716. The functions CHAR-EQUAL, CHAR-NOT-EQUAL, CHAR-LESSP, CHAR-GREATERP,
  717. CHAR-NOT-GREATERP, CHAR-NOT-LESSP ignore bits and font attributes of their
  718. arguments.
  719.  
  720. 13.4.
  721. -----
  722.  
  723. The string chars that are not graphic chars and the space character have
  724. names:
  725.   (code-char #x00) = #\Null
  726.   (code-char #x07) = #\Bell
  727.   (code-char #x08) = #\Backspace = #\Rubout
  728.   (code-char #x09) = #\Tab
  729.   (code-char #x0A) = #\Newline = #\Linefeed
  730.   (code-char #x0B) = #\Code11
  731.   (code-char #x0C) = #\Page
  732.   (code-char #x0D) = #\Return
  733.   (code-char #x1A) = #\Code26
  734.   (code-char #x1B) = #\Escape
  735.   (code-char #x20) = #\Space
  736.  
  737. 13.5.
  738. -----
  739.  
  740. CHAR-CONTROL-BIT = 1
  741. CHAR-META-BIT    = 2
  742. CHAR-SUPER-BIT   = 4
  743. CHAR-HYPER-BIT   = 8
  744.  
  745.  
  746.                          CHAPTER 14: Sequences
  747.                          ---------------------
  748.  
  749. 14.1.
  750. -----
  751.  
  752. The result of NREVERSE is always EQ to the argument. NREVERSE on a vector
  753. swaps pairs of elements. NREVERSE on a list swaps the first and the last
  754. element and reverses the list chaining between them.
  755.  
  756. 14.2.
  757. -----
  758.  
  759. For iteration through a sequence, a macro DOSEQ, analogous to DOLIST, may be
  760. used instead of MAP :
  761.   (doseq (var seqform [resultform]) {declaration}* {tag|statement}* )
  762.  
  763. The CLtL2 function MAP-INTO is implemented.
  764.  
  765. 14.3.
  766. -----
  767.  
  768. REMOVE, REMOVE-IF, REMOVE-IF-NOT, REMOVE-DUPLICATES return their argument
  769. unchanged, if no element has to be removed.
  770.  
  771. DELETE, DELETE-IF, DELETE-IF-NOT, DELETE-DUPLICATES destructively modify
  772. their argument: If the argument is a list, the CDR parts are modified. If
  773. the argument is a vector with fill pointer, the fill pointer is lowered and
  774. the remaining elements are compacted below the new fill pointer.
  775.  
  776. 14.5.
  777. -----
  778.  
  779. SORT and STABLE-SORT have two additional keywords :START and :END :
  780.   (SORT sequence predicate &key :key :start :end)
  781.   (STABLE-SORT sequence predicate &key :key :start :end)
  782.  
  783. SORT and STABLE-SORT are identical. They implement the mergesort algorithm.
  784.  
  785.  
  786.                          CHAPTER 15: Lists
  787.                          -----------------
  788.  
  789. 15.4.
  790. -----
  791.  
  792. SUBLIS and NSUBLIS apply the :KEY argument to the nodes of the cons tree and
  793. not to the keys of the alist.
  794.  
  795.  
  796.                       CHAPTER 16: Hash Tables
  797.                       -----------------------
  798.  
  799. 16.1.
  800. -----
  801.  
  802. MAKE-HASH-TABLE has an additional keyword :INITIAL-CONTENTS :
  803.   (MAKE-HASH-TABLE &key :test :initial-contents :size :rehash-size
  804.                         :rehash-threshold)
  805. The :INITIAL-CONTENTS argument is an alist that is used to initialize the
  806. new hash table.
  807. The :REHASH-THRESHOLD argument is ignored.
  808.  
  809. For iteration through a hash table, a macro DOHASH, analogous to DOLIST, can
  810. be used instead of MAPHASH :
  811.   (dohash (key-var value-var hash-table-form [resultform])
  812.     {declaration}* {tag|statement}*
  813.   )
  814.  
  815.  
  816.                      CHAPTER 17: Arrays
  817.                      ------------------
  818.  
  819. 17.1.
  820. -----
  821.  
  822. ARRAY-RANK-LIMIT is 65536 on 16-bit processors, 4294967296 on 32-bit
  823. processors.
  824.  
  825. ARRAY-DIMENSION-LIMIT  = 2^24 = 16777216
  826. ARRAY-TOTAL-SIZE-LIMIT = 2^24 = 16777216
  827.  
  828. 17.6.
  829. -----
  830.  
  831. An array to which another array is displaced should not be shrunk (using
  832. ADJUST-ARRAY) in such a way that the other array points into void space.
  833. This is not checked at the time ADJUST-ARRAY is called!
  834.  
  835.  
  836.                        CHAPTER 18: Strings
  837.                        -------------------
  838.  
  839. 18.2.
  840. -----
  841.  
  842. String comparison is based on the function CHAR<=. Therefore diphtongs do
  843. not obey the usual national rules. Example: "o" < "oe" < "z" < "÷".
  844.  
  845.  
  846.                         CHAPTER 19: Structures
  847.                         ----------------------
  848.  
  849. 19.5.
  850. -----
  851.  
  852. The :PRINT-FUNCTION option should contain a lambda expression
  853.   (lambda (structure stream depth) (declare (ignore depth)) ...)
  854. This lambda expression names a function whose task is to output the external
  855. representation of structure onto the stream. This may be done by outputting
  856. text onto the stream using WRITE-CHAR, WRITE-STRING, WRITE, PRIN1, PRINC,
  857. PRINT, PPRINT, FORMAT and the like. The following rules must be obeyed:
  858. * The value of *PRINT-ESCAPE* must be respected.
  859. * The value of *PRINT-PRETTY* should not and cannot be respected, since the
  860.   pretty-print mechanism is not accessible from outside.
  861. * The value of *PRINT-CIRCLE* need not to be respected. This is managed by
  862.   the system. (But the print-circle mechanism handles only those objects that
  863.   are (direct or indirect) components of structure.)
  864. * The value of *PRINT-LEVEL* is respected by
  865.   WRITE, PRIN1, PRINC, PRINT, PPRINT, FORMAT ~A, FORMAT ~S, FORMAT ~W and
  866.   FORMAT ~D,~B,~O,~X,~R,~F,~E,~G,~$ with not-numerical arguments.
  867.   Therefore the print-level mechanism works automatically if only these
  868.   functions are used for outputting objects and if they are not called on
  869.   objects with nesting level > 1. (The print-level mechanism does not
  870.   recognize how many parentheses you have output. It only counts how many
  871.   times it was called recursively.)
  872. * The value of *PRINT-LENGTH* must be respected, especially if you are
  873.   outputting an arbitrary number of components.
  874. * The value of *PRINT-READABLY* must be respected. Remember that the values
  875.   of *PRINT-ESCAPE*, *PRINT-LEVEL*, *PRINT-LENGTH* don't matter if
  876.   *PRINT-READABLY* is true.
  877.   The value of *PRINT-READABLY* is respected by PRINT-UNREADABLE-OBJECT,
  878.   WRITE, PRIN1, PRINC, PRINT, PPRINT, FORMAT ~A, FORMAT ~S, FORMAT ~W and
  879.   FORMAT ~D,~B,~O,~X,~R,~F,~E,~G,~$ with not-numerical arguments.
  880.   Therefore *PRINT-READABLY* will be respected automatically if only these
  881.   functions are used for outputting objects.
  882. * You need not bother about the values of *PRINT-BASE*, *PRINT-RADIX*,
  883.   *PRINT-CASE*, *PRINT-GENSYM*, *PRINT-ARRAY*, *PRINT-CLOSURE*, *PRINT-RPARS*.
  884.  
  885. The :INHERIT option is exactly like :INCLUDE except that it doesn't create
  886. new accessors for the inherited slots. Use this option to avoid the problems
  887. that occur when using the same :CONC-NAME for the new and the inherited
  888. structure.
  889.  
  890.  
  891.                        CHAPTER 20: The Evaluator
  892.                        -------------------------
  893.  
  894. As in Scheme, the Macro (THE-ENVIRONMENT) returns the current lexical
  895. environment. This works only in interpreted code and is not compilable!
  896.  
  897. (EVAL-ENV form [env]) evaluates a form in a given lexical environment, just
  898. if the form had been part of the program text that environment came from.
  899.  
  900.  
  901.                          CHAPTER 21: Streams
  902.                          -------------------
  903.  
  904. 21.1.
  905. -----
  906.  
  907. Input through *TERMINAL-IO* uses the GNU readline library. Arrow keys can be
  908. used to move within the input history. The Tab key completes the symbol's
  909. name that is being typed.
  910. See readline.dvi for a complete description of the key bindings.
  911. The GNU readline library is not used if standard input and standard output do
  912. not both refer to the same terminal.
  913.  
  914. *TERMINAL-IO* is not the only stream that communicates directly with the
  915. user: During execution of the body of a (WITH-KEYBOARD . body) form,
  916. *KEYBOARD-INPUT* is the stream that reads the keystrokes from the keyboard.
  917. It returns every keystroke in detail, as character with the following bits:
  918.   HYPER        if a non-standard key. These are:
  919.                  function keys, cursor keypads, numeric keypad.
  920.   CHAR-CODE    the Ascii code for standard keys,
  921.                for non-standard keys:
  922.                  F1 -> #\F1, ..., F10 -> #\F10, F11 -> #\F11, F12 -> #\F12,
  923.                  Insert -> #\Insert, Delete -> #\Delete,
  924.                  Home -> #\Home, End -> #\End, PgUp -> #\PgUp, PgDn -> #\PgDn,
  925.                  Arrow keys -> #\Up, #\Down, #\Left, #\Right.
  926.   SUPER        if pressed together with Shift key(s) and if the keystroke
  927.                would have been an other without Shift.
  928.   CONTROL      if pressed together with the Control key.
  929.   META         if pressed together with the Alternate key.
  930. This keyboard input is not echoed on the screen.
  931. During execution of a (WITH-KEYBOARD . body) form, no input from *TERMINAL-IO*
  932. or any synonymous stream should be requested.
  933.  
  934. 21.2.
  935. -----
  936.  
  937. The macro WITH-OUTPUT-TO-PRINTER
  938.        (with-output-to-printer (var) {declaration}* {form}*)
  939. binds the variable var to an output stream that sends its output to the
  940. printer.
  941.  
  942. (MAKE-PIPE-INPUT-STREAM command) returns an input stream that will supply the
  943. output from the execution of the given operating system command.
  944. See also (SHELL command).
  945.  
  946. (MAKE-PIPE-OUTPUT-STREAM command) returns an output stream that will pass its
  947. output as input to the execution of the given operating system command.
  948. See also (SHELL command).
  949.  
  950. (MAKE-PIPE-IO-STREAM command) returns three values. The first value is a
  951. bidirectional stream that will simultaneously pass its output as input to
  952. the execution of the given operating system command and supply the output
  953. from this command as input. The second and third value will be the input
  954. stream and the output stream that make up the I/O stream, respectively.
  955. Note that they must be closed individually.
  956. Warning: Improper use of this function can lead to deadlocks. You use it at
  957. your own risk!
  958. A deadlock occurs if the command and your program either both try to read
  959. read from each other at the same time or both try to write to each other at
  960. the same time. To avoid deadlocks, it is recommended that you fix a protocol
  961. between the command and your program and avoid any hidden buffering: Use
  962. READ-CHAR, READ-CHAR-NO-HANG, LISTEN instead of READ-LINE and READ on the
  963. input side, and complete every output operation by a FINISH-OUTPUT. The same
  964. cautions must apply to the called command as well.
  965. See also (SHELL command).
  966.  
  967. Generic streams are user programmable streams. The programmer interface:
  968.  
  969.   (MAKE-GENERIC-STREAM controller) returns a generic stream.
  970.  
  971.   (GENERIC-STREAM-CONTROLLER stream)
  972.      returns a private object to which generic stream methods dispatch.
  973.      The typical usage is to retrieve the object originally provided by the
  974.      user in MAKE-GENERIC-STREAM.
  975.  
  976.   (GENERIC-STREAM-P stream)
  977.     determines whether a stream is a generic stream, returning T if it is,
  978.     NIL otherwise.
  979.  
  980. In order to specify the behaviour of a generic stream, the user must define
  981. CLOS methods on the following CLOS generic functions. The function
  982. GENERIC-STREAM-XYZ corresponds to the Common Lisp function XYZ. They all
  983. take a controller and some number of arguments.
  984.  
  985.   (GENERIC-STREAM-READ-CHAR    controller)
  986.   (GENERIC-STREAM-READ-BYTE    controller)
  987.          These generic functions should return NIL at end of file.
  988.          Takes one argument, the controller object.
  989.   (GENERIC-STREAM-LISTEN       controller)
  990.          Returns -1 for EOF, 0 for character pending, and 1 for none.
  991.          Takes one argument, the controller object.
  992.   (GENERIC-STREAM-WRITE-CHAR   controller ch)
  993.          First argument is the controller object.
  994.          Second argument is the character to be written.
  995.   (GENERIC-STREAM-WRITE-BYTE   controller by)
  996.          First argument is the controller object.
  997.          Second argument is the integer to be written.
  998.   (GENERIC-STREAM-WRITE-STRING controller string start len)
  999.          Called with argument list (controller string start len),
  1000.          this function shall write
  1001.            (subseq (the string string) start (+ start len))
  1002.          First argument is the controller object.
  1003.   (GENERIC-STREAM-CLEAR-INPUT   controller)
  1004.   (GENERIC-STREAM-CLEAR-OUTPUT  controller)
  1005.   (GENERIC-STREAM-FINISH-OUTPUT controller)
  1006.   (GENERIC-STREAM-FORCE-OUTPUT  controller)
  1007.   (GENERIC-STREAM-CLOSE         controller)
  1008.          Takes one argument, the controller object.
  1009.  
  1010. 21.3.
  1011. -----
  1012.  
  1013. CLOSE ignores its :ABORT argument.
  1014.  
  1015.  
  1016.                      CHAPTER 22: Input/Output
  1017.                      ------------------------
  1018.  
  1019. 22.1.2.
  1020. -------
  1021.  
  1022. A "reserved token", i.e. a token that has potential number syntax but cannot
  1023. be interpreted as a number, is interpreted as symbol when being read. (CLtL1
  1024. p. 341)
  1025.  
  1026. When a token with package markers is read, then (CLtL1 p. 343/344) no
  1027. checking is done whether the package part and the symbol-name part do not
  1028. have number syntax. (What's the purpose of this check?) So we consider
  1029. tokens like USER:: or :1 or LISP::4711 or 21:3 as symbols.
  1030.  
  1031. 22.1.3.
  1032. -------
  1033.  
  1034. The backquote read macro also works when nested. Example:
  1035.  (eval ``(,#'(lambda () ',a) ,#'(lambda () ',b)))
  1036.  = (eval `(list #'(lambda () ',a) #'(lambda () ',b)))
  1037.  = (eval (list 'list (list 'function (list 'lambda nil (list 'quote a)))
  1038.                      (list 'function (list 'lambda nil (list 'quote b)))
  1039.    )     )
  1040.  
  1041. Multiple backquote combinations like ,,@ or ,@,@ are not implemented. Their
  1042. use would be confusing anyway.
  1043.  
  1044. 22.1.4.
  1045. -------
  1046.  
  1047. #\ allows inputting characters of arbitrary code: #\Code231 yields the
  1048. character (code-char 231.).
  1049.  
  1050. Additional read dispatch macros:
  1051. * #Y is used to read compiled functions.
  1052. * #" is used to read pathnames:
  1053.      #"test.lsp" is the value of (pathname "test.lsp")
  1054.      As in all strings, backslashes must be written twice here:
  1055.      #"A:\\programs\\test.lsp"
  1056.  
  1057. 22.1.5.
  1058. -------
  1059.  
  1060. Is it impossible to get the read macro function of a dispatch macro
  1061. character like #\# using GET-MACRO-CHARACTER.
  1062.  
  1063. The CLtL2 place READTABLE-CASE is implemented. The possible values of
  1064. (READTABLE-CASE readtable) are :UPCASE, :DOWNCASE and :PRESERVE.
  1065.  
  1066. 22.1.6.
  1067. -------
  1068.  
  1069. In absence of SYS::WRITE-FLOAT, floating point numbers are output in radix 2.
  1070.  
  1071. If *PRINT-READABLY* is true, *READ-DEFAULT-FLOAT-FORMAT* has no influence on
  1072. the way floating point numbers are printed.
  1073.  
  1074. Pathnames are written according to the syntax #"namestring" if
  1075. *PRINT-ESCAPE* /= NIL. If *PRINT-ESCAPE* = NIL, only the namestring is
  1076. printed.
  1077.  
  1078. *PRINT-CASE* controls the output not only of symbols, but also of characters
  1079. and some #<...> objects.
  1080.  
  1081. *PRINT-PRETTY* is initially = NIL.
  1082.  
  1083. *PRINT-ARRAY* is initially = T.
  1084.  
  1085. An additional variable *PRINT-CLOSURE* controls whether compiled and
  1086. interpreted functions (closures) are output in detailed form. If
  1087. *PRINT-CLOSURE* /= NIL, compiled closures are output in #Y syntax the reader
  1088. understands. *PRINT-CLOSURE* is initially = NIL.
  1089.  
  1090. An additional variable *PRINT-RPARS* controls the output of right (closing)
  1091. parentheses. If *PRINT-RPARS* /= NIL, closing parentheses which don't fit
  1092. onto the same line as the the corresponding opening parenthesis are output
  1093. just below their corresponding opening parenthesis, in the same column.
  1094. *PRINT-RPARS* is initially = T.
  1095.  
  1096. 22.2.1.
  1097. -------
  1098.  
  1099. The function READ-CHAR-SEQUENCE performs multiple READ-CHAR operations:
  1100. (READ-CHAR-SEQUENCE sequence stream [:start] [:end]) fills the
  1101. subsequence of sequence specified by :start and :end with characters
  1102. consecutively read from stream. It returns the index of the first element
  1103. of sequence that was not updated (= end or < end if the stream reached its
  1104. end).
  1105. This function is especially efficient if sequence is a string and stream is
  1106. a file stream with element type STRING-CHAR, a pipe stream or a string input
  1107. stream.
  1108.  
  1109. 22.2.2.
  1110. -------
  1111.  
  1112. The function READ-BYTE-SEQUENCE performs multiple READ-BYTE operations:
  1113. (READ-BYTE-SEQUENCE sequence stream [:start] [:end]) fills the
  1114. subsequence of sequence specified by :start and :end with integers
  1115. consecutively read from stream. It returns the index of the first element
  1116. of sequence that was not updated (= end or < end if the stream reached its
  1117. end).
  1118. This function is especially efficient if sequence is a
  1119. (VECTOR (UNSIGNED-BYTE 8)) and stream is a file stream with element type
  1120. (UNSIGNED-BYTE 8) or a pipe stream.
  1121.  
  1122. 22.3.1.
  1123. -------
  1124.  
  1125. The functions WRITE and WRITE-TO-STRING have an additional keyword :CLOSURE
  1126. that can be used to bind *PRINT-CLOSURE*.
  1127.  
  1128. The CLtL2 macro PRINT-UNREADABLE-OBJECT is implemented.
  1129.  
  1130. The function WRITE-CHAR-SEQUENCE performs multiple WRITE-CHAR operations:
  1131. (WRITE-CHAR-SEQUENCE sequence stream [:start] [:end]) outputs the characters
  1132. of the subsequence of sequence specified by :start and :end to stream.
  1133. It returns sequence.
  1134. This function is especially efficient if sequence is a string and stream is
  1135. a file stream with element type STRING-CHAR or a pipe stream.
  1136.  
  1137. 22.3.2.
  1138. -------
  1139.  
  1140. The function WRITE-BYTE-SEQUENCE performs multiple WRITE-BYTE operations:
  1141. (WRITE-BYTE-SEQUENCE sequence stream [:start] [:end]) outputs the integers
  1142. of the subsequence of sequence specified by :start and :end to stream.
  1143. It returns sequence.
  1144. This function is especially efficient if sequence is a
  1145. (VECTOR (UNSIGNED-BYTE 8)) and stream is a file stream with element type
  1146. (UNSIGNED-BYTE 8) or a pipe stream.
  1147.  
  1148. 22.3.3.
  1149. -------
  1150.  
  1151. The FORMAT option ~W is analogous to ~A and ~S, but avoids binding of
  1152. *PRINT-ESCAPE*. (FORMAT stream "~W" object) is equivalent to
  1153. (WRITE object :stream stream).
  1154.  
  1155. FORMAT ~R and FORMAT ~:R can output only integers in the range |n| < 10^66.
  1156. The output is in English, according to the American conventions, and these
  1157. conventions are identical to the British conventions only in the range
  1158. |n| < 10^9.
  1159.  
  1160. FORMAT ~:@C does not output the character itself, only the instruction how
  1161. to type the character.
  1162.  
  1163. For FORMAT ~E and FORMAT ~G, the value of *READ-DEFAULT-FLOAT-FORMAT* doesn't
  1164. matter if *PRINT-READABLY* is true.
  1165.  
  1166. FORMAT ~T can determine the current column of any stream.
  1167.  
  1168.  
  1169.                     CHAPTER 23: File System Interface
  1170.                     ---------------------------------
  1171.  
  1172. 23.1.
  1173. -----
  1174.  
  1175. For most operations, pathnames denoting files and pathnames denoting
  1176. directories can not be used interchangeably.
  1177. This is especially important for the functions DIRECTORY, DIR, CD, MAKE-DIR,
  1178. DELETE-DIR.
  1179.  
  1180. The minimum filename syntax that may be used portably is:
  1181.   "xxx"       for a file with name xxx,
  1182.   "xxx.yy"    for a file with name xxx and type yy,
  1183.   ".yy"       for a pathname with type yy and no name specified.
  1184. Hereby xxx denote 1 to 8 characters, and yy denote 1 to 3 characters, each of
  1185. which being either alphanumerical or the underscore #\_.
  1186. Other properties of pathname syntax vary between operating systems.
  1187.  
  1188. 23.1.1.
  1189. -------
  1190.  
  1191. Pathname components:
  1192. HOST          always NIL
  1193. DEVICE        NIL or :WILD or "A"|...|"Z"
  1194. DIRECTORY     (startpoint . subdirs) where
  1195.                startpoint = :RELATIVE | :ABSOLUTE
  1196.                subdirs = () | (subdir . subdirs)
  1197.                subdir = :WILD (means "**" or "...", all subdirectories) or
  1198.                subdir = simple string, may contain wildcard characters ? and *
  1199. NAME          NIL or
  1200.               simple string, may contain wildcard characters ? and *
  1201.               (may also be specified as :WILD)
  1202. TYPE          NIL or
  1203.               simple string, may contain wildcard characters ? and *
  1204.               (may also be specified as :WILD)
  1205. VERSION       always NIL (may also be specified as :WILD or :NEWEST)
  1206.  
  1207. An OS/2 filename is split into name and type according to the following rule:
  1208.   if there is no '.' in the filename, then the name is everything, type = NIL;
  1209.   if there is a '.', then name is the part before and type the part after
  1210.      the last dot.
  1211.  
  1212. When a pathname is to be fully specified (no wildcards), that means that
  1213. no :WILD is allowed, no wildcard characters are allowed in the strings, and
  1214. NAME = NIL may not be allowed either.
  1215.  
  1216. External notation:       A:\sub1.typ\sub2.typ\name.typ
  1217. using defaults:            \sub1.typ\sub2.typ\name.typ
  1218. or                                            name.typ
  1219. or                       *:\sub1.typ\**\sub3.typ\x*.lsp
  1220. or similar.
  1221. Instead of '\' one may use '/', as usual for DOS calls.
  1222.  
  1223. The wildcard characters: '*' matches any sequence of characters, '?' matches
  1224. any one character.
  1225.  
  1226. Due to the name/type splitting rule, there are pathnames that can't result
  1227. from PARSE-NAMESTRING. To get a pathname whose type contains a dot or whose
  1228. name contains a dot and whose type is NIL, MAKE-PATHNAME must be used.
  1229. Example: (MAKE-PATHNAME :NAME ".profile").
  1230.  
  1231. 23.1.2.
  1232. -------
  1233.  
  1234. External notation of pathnames (cf. PARSE-NAMESTRING and NAMESTRING),
  1235. of course without spaces, [,],{,}:
  1236.  [ [drivespec]         a letter '*'|'A'|...|'Z'|'a'|...|'z'
  1237.    :
  1238.  ]
  1239.  { name [. type] \ }   each one a subdirectory, '\' may be replaced by '/'
  1240.  [ name [. type] ]     filename with type (extension)
  1241.  
  1242. Name and type may be character sequences of any length (consisting of
  1243. printing ASCII characters, except '/', '\', ':').
  1244.  
  1245. The function USER-HOMEDIR-PATHNAME is not implemented.
  1246. If you really need that function, you might define it like this:
  1247.   (DEFUN USER-HOMEDIR-PATHNAME (&OPTIONAL HOST)
  1248.     (DECLARE (IGNORE HOST))
  1249.     (OR (SYSTEM::GETENV "HOME") "\\")
  1250.   )
  1251.  
  1252. 23.2.
  1253. -----
  1254.  
  1255. The file streams returned by OPEN are always buffered.
  1256.  
  1257. 23.3.
  1258. -----
  1259.  
  1260. FILE-AUTHOR always returns NIL.
  1261.  
  1262. FILE-POSITION works on any file stream. When a Newline is output to resp.
  1263. input from a file stream, its file position is increased by 2 since Newline
  1264. is encoded as CR/LF in the file.
  1265.  
  1266. 23.4.
  1267. -----
  1268.  
  1269. LOAD has two additional keywords :ECHO and :COMPILING.
  1270. (LOAD filename &key :verbose :print :echo :if-does-not-exist :compiling)
  1271. :VERBOSE T   causes LOAD to emit a short message that a file is being loaded.
  1272.              The default is *LOAD-VERBOSE*, which is initially = T.
  1273. :PRINT T     causes LOAD to print the value of each form.
  1274.              The default is *LOAD-PRINT*, which is initially = NIL.
  1275. :ECHO T      causes the input from the file to be echoed to *STANDARD-OUTPUT*
  1276.              (normally to the screen). Should there be an error in the file,
  1277.              you can see at one glance where it is.
  1278.              The default is *LOAD-ECHO*, which is initially = NIL.
  1279. :COMPILING T causes each form read to be compiled on the fly. The compiled
  1280.              code is executed at once and - in contrast to COMPILE-FILE -
  1281.              not written to a file.
  1282.  
  1283. The CLtL2 variables *LOAD-PATHNAME* and *LOAD-TRUENAME* are implemented.
  1284.  
  1285. The variable *LOAD-PATHS* contains a list of directories where program files
  1286. are searched - additionally to the specified or current directory - by LOAD,
  1287. REQUIRE, COMPILE-FILE.
  1288.  
  1289. 23.5.
  1290. -----
  1291.  
  1292. (DIRECTORY [pathname [:full] [:circle]]) can run in two modes:
  1293. * If pathname contains no name or type component, a list of all matching
  1294.   directories is produced.
  1295. * Otherwise a list of all matching files is returned. If the :FULL argument
  1296.   is /= NIL, this contains additional information: for each matching file
  1297.   you get a list of at least four elements
  1298.   (file-pathname file-truename file-write-date-as-decoded-time file-length).
  1299.  
  1300. (DIR [pathname]) is like DIRECTORY, but displays the pathnames instead of
  1301. returning them. (DIR) shows the contents of the current directory.
  1302.  
  1303. (CD [pathname]) manages the current device and the current directory.
  1304. (CD pathname) sets it, (CD) returns it.
  1305.  
  1306. (DEFAULT-DIRECTORY) is equivalent to (CD), (SETF (DEFAULT-DIRECTORY) pathname)
  1307. is equivalent to (CD pathname).
  1308.  
  1309. (MAKE-DIR directory-pathname) creates a new subdirectory.
  1310.  
  1311. (DELETE-DIR directory-pathname) removes an (empty) subdirectory.
  1312.  
  1313. (EXECUTE programfile arg1 arg2 ...)  executes an external program. Its name
  1314. is programfile. It is given the strings arg1, arg2, ... as arguments.
  1315.  
  1316. (SHELL [command])  calls the operating system's shell.
  1317. (SHELL) calls the shell for interactive use. (SHELL command) calls the shell
  1318. only for execution of the one given command.
  1319.  
  1320. The functions RUN-SHELL-COMMAND and RUN-PROGRAM are a general interface to
  1321. SHELL and the above:
  1322.   (RUN-SHELL-COMMAND command [:input] [:output] [:if-output-exists])
  1323.     runs a shell command.
  1324.   (RUN-PROGRAM program [:arguments] [:input] [:output] [:if-output-exists])
  1325.     runs an external program.
  1326. The command argument     specifies the shell command.
  1327. The program argument     specifies the program. The directories listed in the
  1328.                          PATH environment veriable will be searched for it.
  1329. The :arguments argument  specifies a list of arguments (strings) that are
  1330.                          given to the program.
  1331. The :input argument      specifies where the program's input is to come from:
  1332.                          either :TERMINAL (the standard input) or :STREAM
  1333.                          (a Lisp stream to be created) or a pathname (an
  1334.                          input file) or NIL (no input at all).
  1335. The :output argument     specifies where the program's output is to be sent
  1336.                          to: either :TERMINAL (the standard output) or :STREAM
  1337.                          (a Lisp stream to be created) or a pathname (an
  1338.                          output file) or NIL (ignore the output).
  1339. The :if-output-exists argument specifies what to do if the :output file
  1340.                          already exists. The possible values are :overwrite,
  1341.                          :append, :error, with the same meaning as for OPEN.
  1342. If :STREAM was specified for :input or :output, a Lisp stream is returned.
  1343. If :STREAM was specified for :input and :output, three Lisp streams are
  1344. returned, as for the function MAKE-PIPE-IO-STREAM. This use of RUN-PROGRAM
  1345. can cause deadlocks, see MAKE-PIPE-IO-STREAM.
  1346.  
  1347.  
  1348.                         CHAPTER 24: Errors
  1349.                         ------------------
  1350.  
  1351. 24.1.
  1352. -----
  1353.  
  1354. When an error occurred, you are in a break loop. You can evaluate forms as
  1355. usual. The HELP command (or help key if there is one) lists the available
  1356. debugging commands.
  1357.  
  1358.  
  1359.                   CHAPTER 25: Miscellaneous Features
  1360.                   ----------------------------------
  1361.  
  1362. 25.1.
  1363. -----
  1364.  
  1365. The compiler can be called not only by the functions COMPILE, COMPILE-FILE
  1366. and DISASSEMBLE, also by the declaration (COMPILE).
  1367.  
  1368. (COMPILE-FILE input-file [:output-file] [:listing]
  1369.                          [:warnings] [:verbose] [:print])
  1370. compiles a file to bytecode.
  1371.     input-file                should be a pathname/string/symbol.
  1372. The :output-file argument     should be NIL or T or a pathname/string/symbol
  1373.                               or an output-stream. The default is T.
  1374. The :listing argument         should be NIL or T or a pathname/string/symbol
  1375.                               or an output-stream. The default is NIL.
  1376. The :warnings argument        specifies whether warnings should also appear
  1377.                               on the screen.
  1378. The :verbose argument         specifies whether error messages should also
  1379.                               appear on the screen.
  1380. The :print argument           specifies whether an indication which forms are
  1381.                               being compiled should appear on the screen.
  1382. The variables *COMPILE-WARNINGS*, *COMPILE-VERBOSE*, *COMPILE-PRINT* provide
  1383. defaults for the :warnings, :verbose, :print keyword arguments, respectively.
  1384.  
  1385. The CLtL2 variables *COMPILE-FILE-PATHNAME* and *COMPILE-FILE-TRUENAME* are
  1386. implemented.
  1387.  
  1388. The CLtL2 special form LOAD-TIME-VALUE is implemented. (LOAD-TIME-VALUE form)
  1389. is like (QUOTE #,form) except that the former can be generated by macros.
  1390.  
  1391. The CLtL2 function FUNCTION-LAMBDA-EXPRESSION is implemented.
  1392. (FUNCTION-LAMBDA-EXPRESSION function) returns information about the source
  1393. of an interpreted function: lambda-expression, lexical environment, name.
  1394.  
  1395. 25.2.
  1396. -----
  1397.  
  1398. No on-line documentation is available for the system functions (yet).
  1399.  
  1400. 25.3.
  1401. -----
  1402.  
  1403. (TRACE fun ...) makes the functions fun, ... traced. Syntax of fun:
  1404. Either a symbol:
  1405.        symbol
  1406. or a list of a symbol and some keywords and arguments (which must come in
  1407. pairs!):
  1408.        (symbol
  1409.          [:suppress-if form]   ; no trace output as long as form is true
  1410.          [:step-if form]       ; invokes the stepper as soon as form is true
  1411.          [:pre form]           ; evaluates form before calling the function
  1412.          [:post form]          ; evaluates form after return from the function
  1413.          [:pre-break-if form]  ; goes into the break loop before calling the
  1414.                                ; function if form is true
  1415.          [:post-break-if form] ; goes into the break loop after return from
  1416.                                ; the function if form is true
  1417.          [:pre-print form]     ; prints the values of form before calling the
  1418.                                ; function
  1419.          [:post-print form]    ; prints the values of form after return from
  1420.                                ; the function
  1421.          [:print form]         ; prints the values of form both before
  1422.                                ; calling and after return from the function
  1423.        )
  1424. In all these forms you can access
  1425.   the function itself               as *TRACE-FUNCTION*,
  1426.   the arguments to the function     as *TRACE-ARGS*,
  1427.   the function/macro call as form   as *TRACE-FORM*,
  1428. and after return from the function
  1429.   the list of return values from the function call  as *TRACE-VALUES*,
  1430. and you can leave the function call with specified values by using RETURN.
  1431.  
  1432. TRACE and UNTRACE are also applicable to functions (SETF symbol) and to macros,
  1433. but not to locally defined functions and macros.
  1434.  
  1435. The function INSPECT is not implemented.
  1436.  
  1437. The function ROOM can only be called without arguments. It returns two values:
  1438. the number of bytes currently occupied by Lisp objects, and the number of
  1439. bytes that can be allocated before the next regular garbage collection occurs.
  1440.  
  1441. The function ED calls the external editor specified by the variable *EDITOR*
  1442. (see config.lsp).
  1443. If using the optional package EDITOR:
  1444.   ED behaves like this only if the variable *USE-ED* is NIL.
  1445.   Otherwise ED uses an Emacs-like screen editor with multiple windows.
  1446.  
  1447. The function UNCOMPILE does the converse of COMPILE: (UNCOMPILE function-name)
  1448. reverts an interpreted function that has been entered or loaded in the same
  1449. session and then compiled back to its interpreted form.
  1450.  
  1451. 25.4.1.
  1452. -------
  1453.  
  1454. The variable *DEFAULT-TIME-ZONE* contains the default time zone used by
  1455. ENCODE-UNIVERSAL-TIME and DECODE-UNIVERSAL-TIME. It is initially set to -1
  1456. (which means 1 hour east of Greenwich, i.e. Mid European Time).
  1457.  
  1458. The timezone in a decoded time must not necessarily be an integer, but (as
  1459. float or rational number) it should be a multiple of 1/4.
  1460.  
  1461. INTERNAL-TIME-UNITS-PER-SECOND = 100.
  1462.  
  1463. 25.4.2.
  1464. -------
  1465.  
  1466. The functions MACHINE-TYPE, MACHINE-VERSION, MACHINE-INSTANCE and
  1467. SHORT-SITE-NAME, LONG-SITE-NAME should be defined by every user in his
  1468. site-specific CONFIG.LSP file.
  1469.  
  1470. The variable *FEATURES* initially contains the symbols
  1471.    CLISP            ; this implementation
  1472.    COMMON-LISP
  1473.    CLTL1
  1474.    INTERPRETER
  1475.    COMPILER
  1476.    LOOP
  1477.    CLOS
  1478.    ATARI            ; if hardware = Atari ST/TT and operating system = TOS
  1479.    AMIGA            ; if hardware = Amiga and operating system = Exec/AmigaDOS
  1480.    DOS              ; if hardware = PC (clone)  and operating system = DOS
  1481.    OS/2             ; if hardware = PC (clone)  and operating system = OS/2
  1482.    PC386            ; if hardware = PC (clone) with a 386/486
  1483.    UNIX             ; if                            operating system = Unix
  1484.                     ;                               (yes, in this case the
  1485.                     ;                               hardware is irrelevant!)
  1486.  
  1487.  
  1488.                            CHAPTER 26: Loop
  1489.                            ----------------
  1490.  
  1491. The CLtL2 macros LOOP and LOOP-FINISH are implemented.
  1492.  
  1493.  
  1494.                  CHAPTER 28: Common Lisp Object System
  1495.                  -------------------------------------
  1496.  
  1497. To use CLOS, do (USE-PACKAGE "CLOS").
  1498.  
  1499. The functions
  1500.   SLOT-VALUE, SLOT-BOUNDP, SLOT-MAKUNBOUND, SLOT-EXISTS-P,
  1501.   FIND-CLASS, (SETF FIND-CLASS), CLASS-OF, CALL-NEXT-METHOD, NEXT-METHOD-P,
  1502.   CLASS-NAME, (SETF CLASS-NAME), NO-APPLICABLE-METHOD, NO-NEXT-METHOD,
  1503.   FIND-METHOD, ADD-METHOD, REMOVE-METHOD, COMPUTE-APPLICABLE-METHODS,
  1504.   METHOD-QUALIFIERS, FUNCTION-KEYWORDS, SLOT-MISSING, SLOT-UNBOUND,
  1505.   PRINT-OBJECT, DESCRIBE-OBJECT, MAKE-INSTANCE, INITIALIZE-INSTANCE,
  1506.   REINITIALIZE-INSTANCE, SHARED-INITIALIZE,
  1507. the macros
  1508.   WITH-SLOTS, WITH-ACCESSORS, DEFCLASS, DEFMETHOD, DEFGENERIC,
  1509.   GENERIC-FUNCTION, GENERIC-FLET, GENERIC-LABELS,
  1510. the classes
  1511.   STANDARD-CLASS, STRUCTURE-CLASS, BUILT-IN-CLASS, STANDARD-OBJECT,
  1512.   STANDARD-GENERIC-FUNCTION, STANDARD-METHOD and all predefined classes,
  1513. and the method combination
  1514.   STANDARD
  1515. are implemented.
  1516.  
  1517. Deviations from CLtL2 chapter 28:
  1518.  
  1519. DEFCLASS : It *is* required that the superclasses of a class be defined before
  1520. the DEFCLASS form for the class is evaluated.
  1521.  
  1522. The REAL type is added to the predefined classes listed in table 28-1.
  1523.  
  1524. Only STANDARD method combination is implemented.
  1525.  
  1526. When CALL-NEXT-METHOD is called with arguments, the rule that the ordered
  1527. set of applicable methods must be the same as for the original arguments
  1528. is not enforced by the implementation.
  1529.  
  1530. CALL-NEXT-METHOD and NEXT-METHOD-P are local macros, not local functions.
  1531. Use #'(lambda () (call-next-method)) instead of #'call-next-method if you
  1532. really need it as a function.
  1533.  
  1534. There is a generic function NO-PRIMARY-METHOD (analogous to
  1535. NO-APPLICABLE-METHOD) which is called when a generic function of the class
  1536. STANDARD-GENERIC-FUNCTION is invoked and no primary method on that generic
  1537. function is applicable.
  1538.  
  1539. GENERIC-FLET and GENERIC-LABELS are implemented as macros, not as special
  1540. forms.
  1541.  
  1542. The function ENSURE-GENERIC-FUNCTION is not implemented.
  1543.  
  1544. ADD-METHOD can put methods into other generic functions than the one the method
  1545. came from.
  1546.  
  1547. PRINT-OBJECT and DESCRIBE-OBJECT are only called on objects of type
  1548. STANDARD-OBJECT.
  1549.  
  1550. DESCRIBE-OBJECT should not call DESCRIBE recursively as this would produce
  1551. more information than is likely to be useful to a human reader.
  1552.  
  1553. DOCUMENTATION still has the CLtL1 implementation.
  1554.  
  1555. User-defined method combination is not supported.
  1556. The sections 28.1.7.3., 28.1.7.4., the macros DEFINE-METHOD-COMBINATION,
  1557. CALL-METHOD and the functions INVALID-METHOD-ERROR, METHOD-COMBINATION-ERROR,
  1558. METHOD-QUALIFIERS are not implemented.
  1559.  
  1560. The special form WITH-ADDED-METHODS is not implemented.
  1561.  
  1562. Redefining classes is not supported.
  1563. The sections 28.1.10., 28.1.10.1., 28.1.10.2., 28.1.10.3., 28.1.10.4. and the
  1564. function UPDATE-INSTANCE-FOR-REDEFINED-CLASS are not implemented.
  1565.  
  1566. Changing the class of a given instance is not supported.
  1567. The sections 28.1.11., 28.1.11.1., 28.1.11.2., 28.1.11.3. and the functions
  1568. CHANGE-CLASS, UPDATE-INSTANCE-FOR-DIFFERENT-CLASS, MAKE-INSTANCES-OBSOLETE are
  1569. not implemented.
  1570.  
  1571.  
  1572.                         CHAPTER 29: Conditions
  1573.                         ----------------------
  1574.  
  1575. 29.4.1.
  1576. -------
  1577.  
  1578. The default condition type for conditions created by SIGNAL is
  1579. SIMPLE-CONDITION, not SIMPLE-ERROR.
  1580.  
  1581. 29.4.7.
  1582. -------
  1583.  
  1584. In RESTART-CASE clauses the argument list can also be specified after the
  1585. keyword/value pairs instead of before them. The syntax therefore is
  1586.   (RESTART-CASE form {restart-clause}*)
  1587. with
  1588.   restart-clause ::=   (restart-name arglist {keyword value}* {form}*)
  1589.                      | (restart-name {keyword value}* arglist {form}*)
  1590.  
  1591. The macro WITH-RESTARTS is like RESTART-CASE, except that the forms are
  1592. specified after the restart clauses instead of before them, and the
  1593. restarts created are not implicitly associated to any condition.
  1594.   (WITH-RESTARTS ({restart-clause}*) {form}*)
  1595. is therefore equivalent to (RESTART-CASE (PROGN {form}*) {restart-clause}*).
  1596.  
  1597. 29.4.8.
  1598. -------
  1599.  
  1600. COMPUTE-RESTARTS and FIND-RESTART behave as specified in dpANS: If the
  1601. optional condition argument is not NIL, only restarts associated with that
  1602. condition and restarts associated to no condition at all are considered.
  1603. Therefore the effect of associating a restart to a condition is not to
  1604. activate it, but to hide it from other conditions. This makes the syntax
  1605. dependent implicit association performed by RESTART-CASE nearly obsolete.
  1606.  
  1607. 29.4.9.
  1608. -------
  1609.  
  1610. The default condition type for conditions created by WARN is SIMPLE-WARNING,
  1611. not SIMPLE-ERROR.
  1612.  
  1613.  
  1614.                CHAPTER 90: Platform independent Extensions
  1615.                -------------------------------------------
  1616.  
  1617. 90.1. Saving an Image
  1618. ---------------------
  1619.  
  1620. The function (SAVEINITMEM [filename [:quiet] [:init-function]]) saves the
  1621. running CLISP's memory to a file. The filename defaults to "lispinit.mem".
  1622. If the :QUIET argument is not NIL, the startup banner and the good-bye
  1623. message will be suppressed. The :INIT-FUNCTION argument specifies a function
  1624. that will be executed at startup of the saved image.
  1625.  
  1626. 90.2. Quitting Lisp
  1627. -------------------
  1628.  
  1629. The functions (EXIT [errorp]), (QUIT [errorp]) and (BYE [errorp])
  1630. - all synonymous - terminate CLISP. If errorp is not NIL, CLISP aborts with
  1631. error status, i.e. the environment is informed that the CLISP session didn't
  1632. succeed.
  1633.  
  1634. 90.3. The Language
  1635. ------------------
  1636.  
  1637. The language CLISP uses to communicate with the user can be either
  1638. ENGLISH or DEUTSCH (i.e. german) or FRANCAIS (i.e. french). The macros
  1639. ENGLISH, DEUTSCH, FRANCAIS and LANGUAGE-CASE produce code that depends on
  1640. the language:
  1641. (ENGLISH english-form DEUTSCH deutsch-form FRANCAIS francais-form)
  1642. - and all permutations of this - evaluates all of english-form, deutsch-form,
  1643. francais-form in no particular order and returns the evaluation result
  1644. corresponding to the user language.
  1645. (LANGUAGE-CASE {clause}*) executes the clause (analogous to CASE) that
  1646. corresponds to the user language.
  1647. The language itself is the value of
  1648. (ENGLISH 'ENGLISH DEUTSCH 'DEUTSCH FRANCAIS 'FRANCAIS).
  1649.  
  1650.  
  1651.                   CHAPTER 91: The Debugger and Stepper
  1652.                   ------------------------------------
  1653.  
  1654. The debugger may be invoked through the functions INVOKE-DEBUGGER, BREAK,
  1655. SIGNAL, ERROR, CERROR, WARN. The stepper is invoked through the macro STEP.
  1656. Debugger and stepper execute subordinate READ - EVAL - PRINT loops (called
  1657. "break loops") which are analogous to the main READ - EVAL - PRINT loop except
  1658. for the prompt and the set of available commands. Commands must be typed
  1659. literally, without surrounding quotes or white space.
  1660.  
  1661. Commands common to the main loop, the debugger and the stepper:
  1662.   Help       prints a list of available commands.
  1663.  
  1664. Commands common to the debugger and the stepper:
  1665.   Abort      and
  1666.   Unwind     abort to the next most recent READ - EVAL - PRINT loop.
  1667.  
  1668. The stack is organized into frames and other stack elements. Usually every
  1669. invocation of an interpreted function and every evaluation of an interpreted
  1670. form corresponds to one stack frame. Special forms such as LET, LET*,
  1671. UNWIND-PROTECT and CATCH produce special kinds of stack frames.
  1672.  
  1673. In a break loop there is a current stack frame, which is initially the most
  1674. recent stack frame but can be moved using the debugger commands Up and Down.
  1675.  
  1676. Evaluation of forms in a break loop occurs in the lexical environment of the
  1677. current stack frame but in the dynamic environment of the debugger's caller.
  1678. This means that to inspect or modify a lexical variable all you have to do
  1679. is to move to the current stack frame just below the frame that corresponds
  1680. to the form or the function call that binds that variable.
  1681.  
  1682. There is a current "stack mode" which defines in how much detail the stack
  1683. is shown by the stack related debugger commands.
  1684.  
  1685. Commands common to the debugger and the stepper:
  1686.   Mode-1      sets the current mode to 1: all the stack elements are
  1687.               considered. This mode is fine for debugging compiled functions.
  1688.   Mode-2      sets the current mode to 2: all the frames are considered.
  1689.   Mode-3      sets the current mode to 3: only lexical frames (frames that
  1690.               correspond to special forms that modify the lexical environment)
  1691.               are considered.
  1692.   Mode-4      sets the current mode to 4 (the default): only EVAL and APPLY
  1693.               frames are considered. Every evaluation of a form in the
  1694.               interpreter corresponds to an EVAL frame.
  1695.   Mode-5      sets the current mode to 5: only APPLY frames are considered.
  1696.               Every invocation of an interpreted function corresponds to one
  1697.               APPLY frame.
  1698.   Where       shows the current stack frame.
  1699.   Up          goes up one frame, i.e. to the caller if in mode-5
  1700.   Down        does down one frame, i.e. to the callee if in mode-5
  1701.   Top         goes to top frame, i.e. to the top-level form if in mode-4
  1702.   Bottom      goes to bottom (most recent) frame, i.e. most probably to the
  1703.               form or function that caused the debugger to be entered.
  1704.   Backtrace   lists the stack in current mode, bottom frame first, top frame
  1705.               last.
  1706.   Backtrace-1 lists the stack in mode 1.
  1707.   Backtrace-2 lists the stack in mode 2.
  1708.   Backtrace-3 lists the stack in mode 3.
  1709.   Backtrace-4 lists the stack in mode 4.
  1710.   Backtrace-5 lists the stack in mode 5.
  1711. If the current stack frame is an EVAL or APPLY frame, the following commands
  1712. are available as well:
  1713.   Break+      sets a breakpoint in the current frame. When the corresponding
  1714.               form or function will be left, the debugger will be entered
  1715.               again, with the variable *TRACE-VALUES* containing a list of
  1716.               its values.
  1717.   Break-      removes a breakpoint from the current frame.
  1718.   Redo        re-evaluates the corresponding form or function call. This
  1719.               command can be used to restart parts of a computation without
  1720.               aborting it entirely.
  1721.   Return      leaves the current frame. You will be prompted for the
  1722.               return values.
  1723.  
  1724. Commands specific to the debugger:
  1725.   Continue    continues evaluation of the program.
  1726.  
  1727. Commands specific to the stepper:
  1728.   Step        step into a form: evaluate this form in single step mode
  1729.   Next        step over a form: evaluate this form at once
  1730.   Over        step over this level: evaluate at once up to the next return
  1731.   Continue    switch off single step mode, continue evaluation
  1732.  
  1733. The stepper is usually used like this: If some form returns a strange value
  1734. or results in an error, call  (STEP form)  and navigate using the commands
  1735. Step  and  Next  until you reach the form you regard as responsible. If you
  1736. are too fast (execute Next once and get the error), there is no way back; you
  1737. have to restart the entire stepper session. If you are too slow (stepped into
  1738. a function or a form which certainly is OK), a couple of Next commands or one
  1739. Over command will help.
  1740.  
  1741.  
  1742.                 CHAPTER 99: Platform specific Extensions
  1743.                 ----------------------------------------
  1744.  
  1745. 99.2. Random Screen Access
  1746. --------------------------
  1747.  
  1748. (SCREEN:MAKE-WINDOW)
  1749.   returns a "window stream". As long as this stream is open, the terminal
  1750.   is in cbreak/noecho mode. *TERMINAL-IO* shouldn't be used for input or
  1751.   output during this time. (Use WITH-KEYBOARD and *KEYBOARD-INPUT* instead.)
  1752.  
  1753. (SCREEN:WITH-WINDOW . body)
  1754.   binds SCREEN:*WINDOW* to a window stream and executes body. The stream is
  1755.   guaranteed to be closed when the body is left. During its execution,
  1756.   *TERMINAL-IO* shouldn't be used, as above.
  1757.  
  1758. (SCREEN:WINDOW-SIZE window-stream)
  1759.   returns the window's size, as two values:
  1760.   height (= Ymax+1) and width (= Xmax+1).
  1761.  
  1762. (SCREEN:WINDOW-CURSOR-POSITION window-stream)
  1763.   returns the position of the cursor in the window, as two values:
  1764.   line (>=0, <=Ymax, 0 means top), column (>=0, <=Xmax, 0 means left margin).
  1765.  
  1766. (SCREEN:SET-WINDOW-CURSOR-POSITION window-stream line column)
  1767.   sets the position of the cursor in the window.
  1768.  
  1769. (SCREEN:CLEAR-WINDOW window-stream)
  1770.   clears the window's contents and puts the cursor in the upper left corner.
  1771.  
  1772. (SCREEN:CLEAR-WINDOW-TO-EOT window-stream)
  1773.   clears the window's contents from the cursor position to the end of window.
  1774.  
  1775. (SCREEN:CLEAR-WINDOW-TO-EOL window-stream)
  1776.   clears the window's contents from the cursor position to the end of line.
  1777.  
  1778. (SCREEN:DELETE-WINDOW-LINE window-stream)
  1779.   removes the cursor's line, moves the lines below it up by one line and
  1780.   clears the window's last line.
  1781.  
  1782. (SCREEN:INSERT-WINDOW-LINE window-stream)
  1783.   inserts a line at the cursor's line, moving the lines below it down by
  1784.   one line.
  1785.  
  1786. (SCREEN:HIGHLIGHT-ON window-stream)
  1787.   switches highlighted output on.
  1788.  
  1789. (SCREEN:HIGHLIGHT-OFF window-stream)
  1790.   switches highlighted output off.
  1791.  
  1792. (SCREEN:WINDOW-CURSOR-ON window-stream)
  1793.   makes the cursor visible, a cursor block in most implementations.
  1794.  
  1795. (SCREEN:WINDOW-CURSOR-OFF window-stream)
  1796.   makes the cursor invisible, in implementations where this is possible.
  1797.  
  1798.  
  1799. Authors:
  1800. --------
  1801.  
  1802.         Bruno Haible                    Michael Stoll
  1803.         Augartenstra▀e 40               Gallierweg 39
  1804.     D - 76137 Karlsruhe             D - 53117 Bonn
  1805.         Germany                         Germany
  1806.  
  1807. Email:  haible@ma2s2.mathematik.uni-karlsruhe.de
  1808.