Fix bugs reported by Fengjing Xiao
[clqr.git] / clqr-types-and-classes.tex
blobbe539b50a104a8110e7aff465be3cba2c5dde5f6
1 % Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014, 2018
2 % Bert Burgemeister
4 % Permission is granted to copy, distribute and/or modify this
5 % document under the terms of the GNU Free Documentation License,
6 % Version 1.2 or any later version published by the Free Software
7 % Foundation; with no Invariant Sections, no Front-Cover Texts and
8 % no Back-Cover Texts. For details see file COPYING.
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{Types and Classes}
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \begin{figure}
16 \begin{center}
17 \begin{sideways}
18 \includegraphics{clqr-types-and-classes.1}
19 \end{sideways}
20 \end{center}
21 \caption[]{Precedence Order of System Classes
22 (\includegraphics{clqr-types-and-classes.3}),
23 Classes (\includegraphics{clqr-types-and-classes.4}),
24 Types (\includegraphics{clqr-types-and-classes.2}), and
25 Condition Types
26 (\includegraphics{clqr-types-and-classes.5}).\\
27 Every type is also a supertype of \NIL, the empty type.
28 \label{data-types}%
30 \index{*@\A}%
31 \index{T}%
32 \index{ATOM}%
33 \index{READTABLE}%
34 \index{PACKAGE}%
35 \index{SYMBOL}%
36 \index{KEYWORD}%
37 \index{BOOLEAN}%
38 \index{RESTART}%
39 \index{RANDOM-STATE}%
40 \index{HASH-TABLE}%
41 \index{STRUCTURE-OBJECT}%
42 \index{STANDARD-OBJECT}%
43 \index{NULL}%
44 \index{CLASS}%
45 \index{BUILT-IN-CLASS}%
46 \index{STANDARD-CLASS}%
47 \index{STRUCTURE-CLASS}%
48 \index{METHOD}%
49 \index{STANDARD-METHOD}%
50 \index{METHOD-COMBINATION}%
51 \index{CHARACTER}%
52 \index{FUNCTION}%
53 \index{COMPILED-FUNCTION}%
54 \index{GENERIC-FUNCTION}%
55 \index{STANDARD-GENERIC-FUNCTION}%
56 \index{PATHNAME}%
57 \index{LOGICAL-PATHNAME}%
58 \index{NUMBER}%
59 \index{COMPLEX}%
60 \index{REAL}%
61 \index{FLOAT}%
62 \index{SHORT-FLOAT}%
63 \index{SINGLE-FLOAT}%
64 \index{DOUBLE-FLOAT}%
65 \index{LONG-FLOAT}%
66 \index{RATIONAL}%
67 \index{INTEGER}%
68 \index{RATIO}%
69 \index{SIGNED-BYTE}%
70 \index{FIXNUM}%
71 \index{BIGNUM}%
72 \index{UNSIGNED-BYTE}%
73 \index{BIT}%
74 \index{LIST}%
75 \index{SEQUENCE}%
76 \index{CONS}%
77 \index{ARRAY}%
78 \index{SIMPLE-ARRAY}%
79 \index{VECTOR}%
80 \index{STRING}%
81 \index{SIMPLE-STRING}%
82 \index{BASE-STRING}%
83 \index{SIMPLE-BASE-STRING}%
84 \index{SIMPLE-VECTOR}%
85 \index{BIT-VECTOR}%
86 \index{SIMPLE-BIT-VECTOR}%
87 \index{STREAM}%
88 \index{FILE-STREAM}%
89 \index{TWO-WAY-STREAM}%
90 \index{SYNONYM-STREAM}%
91 \index{STRING-STREAM}%
92 \index{BROADCAST-STREAM}%
93 \index{CONCATENATED-STREAM}%
94 \index{ECHO-STREAM}%
95 \index{EXTENDED-CHAR}%
96 \index{BASE-CHAR}%
97 \index{STANDARD-CHAR}%
98 \index{CONDITION}%
99 \index{SERIOUS-CONDITION}%
100 \index{STORAGE-CONDITION}%
101 \index{SIMPLE-TYPE-ERROR}%
102 \index{TYPE-ERROR}%
103 \index{ERROR}%
104 \index{PROGRAM-ERROR}%
105 \index{CONTROL-ERROR}%
106 \index{PACKAGE-ERROR}%
107 \index{PRINT-NOT-READABLE}%
108 \index{STREAM-ERROR}%
109 \index{PARSE-ERROR}%
110 \index{CELL-ERROR}%
111 \index{FILE-ERROR}%
112 \index{ARITHMETIC-ERROR}%
113 \index{SIMPLE-CONDITION}%
114 \index{WARNING}%
115 \index{STYLE-WARNING}%
116 \index{SIMPLE-ERROR}%
117 \index{SIMPLE-WARNING}%
118 \index{UNDEFINED-FUNCTION}%
119 \index{UNBOUND-VARIABLE}%
120 \index{UNBOUND-SLOT}%
121 \index{END-OF-FILE}%
122 \index{READER-ERROR}%
123 \index{DIVISION-BY-ZERO}%
124 \index{FLOATING-POINT-INEXACT}%
125 \index{FLOATING-POINT-OVERFLOW}%
126 \index{FLOATING-POINT-UNDERFLOW}%
127 \index{FLOATING-POINT-INVALID-OPERATION}%
129 \end{figure}
131 For any class, there is always a corresponding type of the same name.
133 \begin{LIST}{1cm}
135 \IT{(\FU*{TYPEP} \VAR{foo} \VAR{type} \Op{\VAR{environment}\DF{\NIL}})}
137 \retval{\T} if \VAR{foo} is of \VAR{type}.
140 \IT{(\FU*{SUBTYPEP} \VAR{type-a} \VAR{type-b}
141 \Op{\VAR{environment}})}
143 Return \retval{\T} if \VAR{type-a} is a recognizable subtype of
144 \VAR{type-b}, and \retvalii{\NIL} if the relationship could not be
145 determined.
148 \IT{(\SO*{THE} \NEV{\VAR{type}} \VAR{form})}
150 Declare \retval{values of \VAR{form}} to be of
151 \VAR{type}.
154 \IT{(\FU*{COERCE} \VAR{object} \VAR{type})}
156 Coerce \retval{\VAR{object}} into \VAR{type}.
159 \IT{(\MC*{TYPECASE} \VAR{foo} \OPn{(\NEV{\VAR{type}} \PROGN{\VAR{a-form}})}
160 \OP{(\xorGOO{\kwd*{OTHERWISE}\\
161 \T}{\}} \PROGN{\VAR{b-form}\DF{\NIL}})})}
163 Return \retval{values of the first \OPn{\VAR{a-form}}} whose \VAR{type} is
164 \VAR{foo} of. Return \retval{values of \VAR{b-form}s} if no
165 \VAR{type} matches.
166 % Keep \OPn{\VAR{a-form}} instead of the otherwise preferable
167 % \VAR{a-form}s because we're talking about one set of a-forms out
168 % of several.
171 \IT{(\xorGOO{%
172 \MC*{ETYPECASE}\\
173 \MC*{CTYPECASE}}{\}}
174 \VAR{foo}
175 \OPn{(\NEV{\VAR{type}} \PROGN{\VAR{form}})})}
177 Return \retval{values of the first \OPn{\VAR{form}}} whose \VAR{type} is
178 \VAR{foo} of. Signal non-correctable/correctable \kwd{type-error}
179 if no \VAR{type} matches.
180 % Keep \OPn{\VAR{form}} instead of the otherwise preferable
181 % \VAR{form}s because we're talking about one set of forms out
182 % of several.
185 \IT{(\FU*{TYPE-OF} \VAR{foo})}
187 \retval{Type of \VAR{foo}}.
190 \IT{(\MC*{CHECK-TYPE} \VAR{place} \VAR{type}
191 \Op{\VAR{string}\DF{\Goo{\LIT{a}\XOR\LIT{an}}\hspace{.3ex}\VAR{type}}})}
193 Signal correctable \kwd{type-error} if \VAR{place} is
194 not of \VAR{type}. Return \retval{\NIL}.
197 \IT{(\FU*{STREAM-ELEMENT-TYPE} \VAR{stream})}
199 \retval{Type} of \VAR{stream} objects.
202 \IT{(\FU*{ARRAY-ELEMENT-TYPE} \VAR{array})}
204 Element \retval{type} \VAR{array} can hold.
207 \IT{(\FU*{UPGRADED-ARRAY-ELEMENT-TYPE} \VAR{type}
208 \Op{\VAR{environment}\DF{\NIL}})}
210 \retval{Element type} of most specialized array capable of holding
211 elements of \VAR{type}.
214 \IT{(\MC*{DEFTYPE} \VAR{foo} (\OPn{\VAR{macro-$\lambda$}})
215 \orGOO{%
216 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\\
217 \NEV{\VAR{doc}}}{\}}
218 \PROGN{\VAR{form}})}
220 Define type \retval{\VAR{foo}} which when referenced as (\VAR{foo}
221 \OPn{\NEV{\VAR{arg}}}) (or as \VAR{foo} if \VAR{macro-$\lambda$}
222 doesn't contain any required parameters) applies expanded \VAR{form}s to \VAR{arg}s
223 returning the new type. For (\OPn{\VAR{macro-$\lambda$}}) see
224 page \pageref{section:Macros} but with default value of \kwd{\A}
225 instead of \NIL. \VAR{form}s are enclosed in an implicit \SO{block}
226 named \VAR{foo}.
229 \IT{\arrGOO{(\kwd*{EQL } \VAR{foo})\\
230 (\kwd*{MEMBER } \OPn{\VAR{foo}})}{.}}
232 Specifier for a type comprising \VAR{foo} or \VAR{foo}s.
235 \IT{(\kwd*{SATISFIES} \VAR{predicate})}
237 Type specifier for all objects satisfying \VAR{predicate}.
240 \IT{(\kwd*{MOD} \VAR{n})}
242 Type specifier for all non-negative integers $<n$.
245 \IT{(\kwd*{NOT} \VAR{type})}
247 Complement of type.
250 \IT{(\kwd*{AND} \OPn{\VAR{type}}\DF{\T})}
252 Type specifier for intersection of \VAR{type}s.
255 \IT{(\kwd*{OR} \OPn{\VAR{type}}\DF{\NIL})}
257 Type specifier for union of \VAR{type}s.
260 \IT{(\kwd*{VALUES} \OPn{\VAR{type}} \OP{\OPn{\kwd{\&optional} \VAR{type}}
261 \Op{\kwd{\&rest} \VAR{other-args}}})}
263 Type specifier for multiple values.
266 \IT{\kwd{\A}}
268 \index{*@\A}%
269 As a type argument (cf.\ Figure \ref{data-types}): no restriction.
271 \end{LIST}
275 %%% Local Variables:
276 %%% mode: latex
277 %%% TeX-master: "clqr"
278 %%% End: