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

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