0fe516564b95a633d875e2582b121564fda2c651
[sod] / doc / misc.tex
1 %%% -*-latex-*-
2 %%%
3 %%% Miscellaneous functionality
4 %%%
5 %%% (c) 2015 Straylight/Edgeware
6 %%%
7
8 %%%----- Licensing notice ---------------------------------------------------
9 %%%
10 %%% This file is part of the Sensible Object Design, an object system for C.
11 %%%
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
16 %%%
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
21 %%%
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 \chapter{Miscellaneous functionality} \label{ch:misc}
27
28 %%%--------------------------------------------------------------------------
29 \section{Utilities} \label{sec:misc.utilities}
30
31 These symbols are defined in the @|sod-utilities| package.
32
33
34 \subsection{Macro utilities}
35
36 We begin with some simple utilities which help with writing macros. Several
37 of these are standard.
38
39 \begin{describe}{mac}
40 {with-gensyms (@{ @<var> @! (@<var> @[@<name>@]) @}^*) \\ \ind
41 @<declaration>^* \\
42 @<form>^*
43 \-\nlret @<value>^*}
44 Bind each @<var> (a symbol, not evaluated) to a freshly made gensym whose
45 name is based on the corresponding @<name> (a string, evaluated), and
46 evaluate the @<form>s as an implicit @|progn| in the resulting environment.
47 If @<name> is omitted, then the name of the @<var> is used as a default; a
48 bare symbol may be written in place of a singleton list.
49 \end{describe}
50
51 \begin{describe}{mac}
52 {once-only (@[[ :environment @<env> @]]
53 @{ @<var> @! (@<var> @[@<value-form>@]) @}^*) \\ \ind
54 @<declaration>^* \\
55 @<form>^*
56 \-\nlret @<result-form>}
57 This is a helper to ensure that macro expansions evaluate their arguments
58 exactly once each, in the correct order.
59
60 Each @<var> is bound to an appropriate value (often a gensym) and then the
61 @<form>s are evaluated as an implicit @|progn| in the resulting environment
62 to produce an output form. This output form is then enclosed in one or
63 more binding forms to produce a @<result-form>. When the @<result-form> is
64 evaluated, the behaviour will be as if each @<value-form> is evaluated
65 exactly once each, in order, and each value is captured in the
66 corresponding @<var>.
67
68 A simple @|once-only| expansion might look something like
69 \begin{prog}
70 (let (\=(@<var>_1 (gensym)) \\
71 \>\qquad\vdots \\
72 \>(@<var>_n (gensym))) \\ \ind
73 `(let (\=(,@<var>_1 ,@<value-form>_1) \\
74 \>\qquad\vdots \\
75 \>(,@<var>_n ,@<value-form>_n)) \\ \ind
76 @<declaration>_1 \dots\ @<declaration>_m \\
77 @<form>_1 \dots\ @<form>_\ell))
78 \end{prog}
79 However, if @|once-only| can determine that some @<value-form> is a
80 constant (e.g., it is @|quote|d, self-evaluating, or reported as
81 @|constantp| in the given environment @<env>), then it need not allocate a
82 gensym: it can instead bind the @<var> directly to the constant value.
83
84 If a @<value-form> is omitted, then the value of the corresponding @<var>
85 is used. It is conventional usage for a macro to wrap @|once-only| around
86 its body so as to convert the arguments which it should evaluate into safe
87 gensyms capturing their runtime values. (Not that the simple expansion
88 given above can't do this correctly.) A bare symbol may be written in
89 place of a singleton list.
90 \end{describe}
91
92 \begin{describe}{fun}
93 {parse-body @<body> \&key :docp :declp
94 @> @<doc-string> @<declarations> @<body-forms>}
95 Parse the @<body> into a @<doc-string>, some @<declaration>s, and a list of
96 @<body-forms>.
97
98 The @<body> is assumed to have the general syntax
99 \begin{prog}
100 @[[ @<doc-string> @! @<declaration>^* @]] \\
101 @<form>^*
102 \end{prog}
103 A @<doc-string> is permitted if and only if @<docp> is non-nil, and
104 declarations are permitted if and only if @<declp> is non-nil; both are
105 true by default.
106
107 Each return value is a list, which is empty if the corresponding part of
108 the input @<body> is missing. Specifically:
109 \begin{itemize}
110 \item @<doc-string> is either nil, or a singleton list containing a string;
111 \item @<declarations> is either nil, or a singleton list containing a
112 @|(declare \dots)| form gathering up all of the individual
113 @<declaration>s within the @<body>; and
114 \item @<body-forms> is a list of the remaining forms in the @<body>.
115 \end{itemize}
116 Thus, the parsed body-parts can conveniently be spliced into a macro
117 expansion using @|,@@|.
118 \end{describe}
119
120 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
121 Return the symbol, interned in the current @|*package*|, whose name is the
122 concatenation of the names of the given @<symbols>.
123 \end{describe}
124
125
126 \subsection{Locatives}
127
128 A \emph{locative} is a value which remembers where another value is stored,
129 -- whether it's in a variable, an array element, a structure slot, a hash
130 table, etc.\ -- and can modify and retrieve it.
131
132 Some Lisp systems have highly efficient locatives which actually keep track
133 of the machine addresses of the places to which they refer. Common Lisp does
134 not implement true locatives of this kind, but something sufficiently useful
135 can be synthesized.
136
137 These locatives can't usefully be compared. It should be possible to compare
138 true locatives, such that two locatives compare equal if and only if they
139 refer to the same place; but that doesn't work for these locatives.
140
141 \begin{describe}{cls}{locative}
142 The type of locative objects.
143 \end{describe}
144
145 \begin{describe}{fun}{locativep @<object> @> @<generalized-boolean>}
146 Return non-nil if and only if @<object> is a locative.
147 \end{describe}
148
149 \begin{describe}{mac}{locf @<place> @> @<locative>}
150 Return a fresh locative capturing the @<place>, which may be any expression
151 usable as the first operand to @|setf|.
152 \end{describe}
153
154 \begin{describe*}
155 {\dhead{fun}{ref @<locative> @> @<value>}
156 \dhead{fun}{setf (ref @<locative>) @<value>}}
157 Retrieve and return the current value stored in the place captured by the
158 @<locative>. With @|setf|, store the new @<value> in the place captured by
159 the @<locative>.
160 \end{describe*}
161
162 \begin{describe}{mac}
163 {with-locatives
164 @{ @<var> @! (@{ @<var> @!
165 (@<var> @[@<locative>@]) @}^*) @} \\ \ind
166 @<declaration>^* \\
167 @<form>^*
168 \-\nlret @<values>^*}
169 This is a macro which hides the use of locatives from its caller using
170 symbol-macros.
171
172 Each @<locative> should be an expression which evaluates to a locative
173 value (not a general place). These are evaluated once each, left to
174 right. The @<form>s are then evaluated as an implicit @|progn|, with each
175 @<var> defined as a symbol macro which will retrieve -- or, with @|setf|,
176 modify -- the value referred to by the corresponding locative.
177
178 If a @<locative> is omitted, it defaults to the value of @<var>; a
179 bare symbol may be used in place of a singleton list.
180 \end{describe}
181
182
183 \subsection{Anaphorics}
184
185 An anaphoric macro implicitly binds a well-known name to a value of interest,
186 in the course of doing something else. The concept was popularized by Paul
187 Graham \cite{graham-1993:on-lisp}.
188
189 The macros described here all bind the variable @|it|.
190
191 \begin{describe}{sym}{it}
192 The symbol @|it| is exported by the @|sod-utilities| package.
193 \end{describe}
194
195 \begin{describe}{mac}
196 {aif @<condition> @<consequent> @[@<alternative>@] @> @<value>^*}
197 Evaluate the @<condition>. If @<condition> is non-nil, then bind @|it| to
198 the resulting value and evaluate the @<consequent>, returning all of its
199 values. Otherwise, evaluate @<alternative>, returning all of its values.
200 \end{describe}
201
202 \begin{describe}{mac}{aand @<form>^* @> @<value>^*}
203 Evaluate each @<form> in turn. If any @<form> evaluates to nil, then stop
204 and return nil. Each form except the first is evaluated with @|it| bound
205 to the (necessarily non-nil) value of the previous form. If all but the
206 last form evaluate non-nil, then return all the values of the final form.
207 \end{describe}
208
209 (No @|aor| is provided, since @|it| would necessarily be bound to nil.)
210
211 \begin{describe}{mac}{awhen @<condition> @<form>^* @> nil}
212 If @<condition> evaluates to a non-nil value, bind @|it| to that value, and
213 evaluate the @<form>s as an implicit @|progn|. Otherwise, return nil.
214 \end{describe}
215
216 \begin{describe}{mac}{acond @{ (@<condition> @<form>^*) @}^* @> @<value>^*}
217 Evaluate each @<condition> in turn, until one of them produces a non-nil
218 value. If the @<condition> is followed by one or more @<form>s, then bind
219 @|it| to the non-nil value of the @<condition> and evaluate the @<form>s as
220 an implicit @|progn|; otherwise, simply return the value of the
221 @<condition>. If no @<condition> produces a non-nil value then return nil.
222 \end{describe}
223
224 \begin{describe*}
225 {\dhead{mac}{acase @<scrutinee>
226 @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*
227 @> @<value>^*}
228 \dhead{mac}{aecase @<scrutinee>
229 @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*
230 @> @<value>^*}
231 \dhead{mac}{atypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*
232 @> @<value>^*}
233 \dhead{mac}{aetypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*
234 @> @<value>^*}}
235 These are like the Common Lisp macros @|case|, @|ecase|, @|typecase|, and
236 @|etypecase|, except that @|it| is bound to the value of the @<scrutinee>
237 while evaluating the matching @<form>s.
238 \end{describe*}
239
240 \begin{describe}{mac}{asetf @{ @<place> @<value> @}^* @> @<value>^*}
241 For each @<place> and @<value> in turn: bind @|it| to the current value of
242 the @<place>, evaluate the @<value> expression, and store the resulting
243 value back in the @<place>. Return the @<value>(s) stored by the final
244 pair: there may be more than one value, e.g., if @<place> is a @|values|
245 form.
246
247 For example, @|(asetf @<place> (1+ it))| is almost equivalent to @|(incf
248 @<place>)|, even if evaluating @<place> has side-effects.
249 \end{describe}
250
251
252 \subsection{Metaobject protocol utilities}
253
254 The following utilities make use of the introspection features of the CLOS
255 metaobject protocol.
256
257 \begin{describe}{gf}{instance-initargs @<instance> @> @<initargs-list>}
258 Return a fresh list of plausible initargs for the given @<instance>.
259
260 The default method should work for most classes, but may be overridden to
261 cope with special effects.
262
263 \begin{describe}{meth}{standard-object}
264 {instance-initargs (@<instance> standard-object) @> @<initargs-list>}
265 The default method works by digging through the instance's class's slot
266 definitions and enquiring about their initargs. Initargs which are
267 handled by methods on @|shared-initialize| or similar generic functions
268 won't be discovered.
269 \end{describe}
270 \end{describe}
271
272 \begin{describe*}
273 {\dhead{fun}{copy-instance @<instance> \&rest @<initargs>
274 @> @<new-instance>}
275 \dhead{gf}{copy-instance-using-class @<class> @<instance>
276 \&rest @<initargs>
277 @> @<new-instance>}}
278 The @|copy-instance| function creates and returns a fresh copy of a given
279 @<instance>, possibly modifying it according to the given @<initargs>.
280
281 It immediately calls @|copy-instance-using-class|, calling it with the
282 instance's class and the instance itself, and simply returns the result of
283 that generic function.
284
285 The default method on @|copy-instance-using-class| should work for most
286 classes, but may be overridden to cope with special effects.
287
288 \begin{describe}{meth}{standard-class}
289 {copy-instance-using-class \=(@<class> standard-class) @<instance> \\
290 \>\&rest initargs
291 \nlret @<new-instance>}
292 The default method works as follows.
293 \begin{enumerate}
294 \item Allocate a fresh instance of @<class>, using @|allocate-instance|.
295 \item For each slot defined by @<class>, if that slot is bound in the
296 original instance, then set the corresponding slot in the new instance
297 to the same value.
298 \item Call @|shared-initialize| on the new instance, providing it the
299 given list of @<initargs>, but inhibiting the usual initialization of
300 slots from their initforms.
301 \item Return the new instance.
302 \end{enumerate}
303 \end{describe}
304 \end{describe*}
305
306 \begin{describe*}
307 {\dhead{gf}{generic-function-methods @<generic-function> @> @<list>}
308 \dhead{gf}{method-specializers @<method> @> @<list>}
309 \dhead{cls}{eql-specializer}
310 \dhead{gf}{eql-specializer-object @<specializer> @> @<value>}}
311 These are precisely the MOP functions and class: the symbols are
312 re-exported for portability, because different Lisp systems define these
313 symbols in different packages.
314 \end{describe*}
315
316
317 \subsection{Other CLOS utilities}
318
319 Some other minor CLOS utilities.
320
321 \begin{describe}{mac}
322 {default-slot (@<instance> @<slot> @[@<slot-names>@]) \\ \ind
323 @<form>^*}
324 This macro is useful in methods (usually @|:after| methods) on
325 @|shared-initialize|, to set slots to some sensible default values in the
326 case where no suitable initarg was given, and default initialization is too
327 complicated to be done using an initform.
328
329 Set a slot to a default value, obeying the @|shared-initialize| protocol.
330 If (a) the named @<slot> of @<instance> is unbound, and (b) either
331 @<slot-names> is @|t|, or @<slot> is a member of the list @<slot-names>,
332 then evaluate the @<form>s as an implicit @|progn| and store their
333 value in the @<slot>. Otherwise do nothing.
334
335 The @<instance>, @<slot>, and @<slot-names> (if any) are evaluated once
336 each, left-to-right.
337 \end{describe}
338
339 \begin{describe}{mac}
340 {define-on-demand-slot @<class> @<slot> (@<instance>) \\ \ind
341 @[[ @<declaration>^* @! @<doc-string> @]] \\
342 @<form>^*}
343 This macro makes slots with delayed initialization: rather than being
344 set when the object is constructed, the slot's initial value is only
345 calculated when it's first requested. This is useful if calculating the
346 slot value is expensive and often not required, or if it's not possible to
347 initialize the slot along with the rest of the object because of dependency
348 cycles.
349
350 The macro arranges things as follows. Whenever @|slot-value| is called
351 (possibly indirectly, via a reader function) to read the named @<slot> (a
352 symbol, not evaluated) on an (indirect) instance of @<class>, but the slot
353 is unbound, then @<instance> is bound to the instance in question and the
354 @<form>s are evaluated as an implicit @|progn| within the lexical
355 environment of the @|define-on-demand-slot| call, and the resulting value
356 is used as the initial value of the slot. (Furthermore, a block named
357 @<slot> is wrapped around the @<form>s, allowing an early return if that
358 should be useful.)
359
360 This macro currently works by defining a method on @|slot-unbound|.
361 \end{describe}
362
363
364 \subsection{Building lists}
365
366 Many Lisp functions end up constructing lists. In simple cases, a function
367 like @|mapcar| will just do the job directly. In more complex cases, a
368 common idiom is to build the list using @|push| for each element in turn; but
369 a list built this way ends up in the wrong order, so an additional pass,
370 usually using @|nreverse|, is necessary to fix it.
371
372 A `list builder' is an object which can be used to construct a list in the
373 right order. (Currently, a list-builder is simply a cons cell, whose cdr
374 points to the first cons-cell of the list, and whose car points to its last
375 cons; an empty list-builder is a cons whose cdr is nil and whose car is the
376 cons itself, i.e., @|\#1=(\#1\# . nil)|.)
377
378 \begin{describe}{fun}{make-list-builder \&optional @<initial> @> @<builder>}
379 Return a fresh new list-builder, initially containing no items.
380 \end{describe}
381
382 \begin{describe}{fun}{lbuild-add @<builder> @<item> @> @<builder>}
383 Add @<item> to the end of the list being constructed in @<builder>.
384 \end{describe}
385
386 \begin{describe}{fun}{lbuild-add-list @<builder> @<list> @> @<builder>}
387 Append @<list> to the list being constructed in @<builder>. The list is
388 \emph{not} copied: adding further items to the list will clobber cdr of its
389 final cons-cell.
390 \end{describe}
391
392 \begin{describe}{fun}{lbuild-list @<builder> @> @<list>}
393 Return the list being constructed in the @<builder>.
394
395 It is permitted to continue adding items to the list: this will mutate the
396 list in-place. Often, this is what you want. For example, one might write
397 an analogue to @|pushnew| like this:
398 \begin{prog}
399 (defun lbuild-add-new
400 (builder item \&key key test test-not \&rest keywords) \\ \ind
401 (declare (ignore key test test-not)) \\
402 (when (apply \#'member item (lbuild-list builder)
403 keywords) \\ \ind
404 (lbuild-add builder item)))
405 \end{prog}
406 \end{describe}
407
408
409 \subsection{Merging lists}
410
411 The following machinery merges lists representing a partial order. The
412 primary use for this is in computing class precedence lists during class
413 finalization. By building the input lists and choosing the tie-breaking
414 @<pick> function appropriately, many different linearization algorithms can
415 be implemented fairly easily using @|merge-lists| below.
416
417 \begin{describe*}
418 {\dhead{cls}
419 {inconsistent-merge-error (error) \&key :candidates :present}
420 \dhead{gf}{merge-error-candidates @<error> @> @<list>}
421 \dhead{gf}{merge-error-present-function @<error> @> @<function>}}
422 The @|inconsistent-merge-error| condition class used to represent a failure
423 of the \descref{fun}{merge-lists}[function].
424
425 The @<candidates> are a list of offending items from the input lists, in
426 some order: the error is reporting that the function has failed because it
427 is not possible to order the items listed in @<candidates> in any way
428 without being inconsistent with at least one of the input lists. There is
429 no default.
430
431 The @<present> function is used to convert the input items into
432 human-readable descriptions (printed using @|princ|); the default is
433 @|identity|, which will simply print the items in a `friendly' format.
434 (Using @|prin1-to-string| would print their machine-readable escaped forms
435 instead.)
436
437 The functions @|merge-error-candidates| and @|merge-error-present-function|
438 respectively retrieve the candidates list and presentation function
439 assigned to a condition when it was created.
440 \end{describe*}
441
442 \begin{describe}{fun}
443 {merge-lists @<lists> \&key :pick :test :present @> @<list>}
444 Return a merge of the @<lists>, considered as partial orderings.
445
446 In more detail: @<lists> should be a list of lists. Each distinct item, as
447 determined by the @<test> function (by default, @|eql|) appears in the
448 result list exactly once. Furthermore, if, in some input list, an item $x$
449 appears earlier than a different item $y$, then $x$ will also precede $y$
450 in the output list.
451
452 If the input lists contradict each other (e.g., list $A$ has $x$ before
453 $y$, but list $B$ has $y$ before $x$), then an error of type
454 @|inconsistent-merge-error| is signalled, with the offending items attached
455 as candidates, and the function @<present> (by default, @|identity|) as the
456 presentation function.
457
458 Frequently, a collection of input lists has multiple valid merges.
459 Whenever @|merge-lists| must decide between two or more equally good
460 candidates, it calls the @<pick> function to choose one of them.
461 Specifically, it invokes @|(funcall @<pick> @<candidates>
462 @<merge-so-far>)|, where @<candidates> are the items it needs to choose
463 between, and @<merge-so-far> is the currently determined prefix of the
464 final merge. The order of items in the @<candidates> list reflects their
465 order in the input lists: item $x$ precedes item $y$ in @<candidates> if
466 any only if an occurrence of $x$ appears in an earlier input list than
467 $y$. (This completely determines the order of candidates: if two items
468 appear in the same list, then that list would have ordered them and we
469 wouldn't have to call @<pick> to break the tie.) The default @<pick>
470 function simply chooses the item appearing in the earliest list, i.e.,
471 effectively
472 \begin{prog}
473 (lambda (candidates merge-so-far) \\ \ind
474 (declare (ignore merge-so-far)) \\
475 (car candidates))
476 \end{prog}
477 \end{describe}
478
479
480 \subsection{Other list utilities}
481
482 \begin{describe}{fun}
483 {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>}
484 Return the result of appending @<list> and @<more-lists>, in order. All
485 but the final list are copied into the @<result-list>; the last one is used
486 as-is.
487 \end{describe}
488
489 \begin{describe}{mac}
490 {categorize (\=@<item-var> @<items>
491 @[[ :bind (@{ @<var> @!
492 (@<var> @[@<value>@]) @}^*) @]])
493 \\ \ind\ind
494 (@{ (@<cat-var> @<cat-predicate>) @}^*) \-\\
495 @<declaration>^* \\
496 @<form>^*
497 \-\nlret @<value>^*}
498 Partition an input list of @<items> according to the @<cat-predicate>s.
499
500 First, @<items> is evaluated, to yield a list. The @<item-var> is bound,
501 an empty list is created for each @|(@<cat-var> @<cat-predicate>)| pair,
502 and an iteration is begun. For each item in the list in turn is assigned
503 to @<item-var>; then, the bindings given by the @|:bind| keyword are
504 performed, as if by @|let*|; and the @<cat-predicate>s are evaluated in the
505 resulting environment, one by one, until one of them returns non-nil. When
506 this happens, the item is added to the corresponding list. If no predicate
507 matches the item, an error is signalled.
508
509 Once this iteration is complete, each @<cat-var> is bound to its
510 corresponding completed list, and the body @<form>s are evaluated in the
511 resulting environment (which does not include @<item-var>), as an implicit
512 @|progn|, and the macro yields the values of the final @<form>.
513 \end{describe}
514
515 \begin{describe}{fun}{partial-order-minima @<items> @<order> @> @<list>}
516 Return a list of minimal items from the list @<items> according to a
517 non-strict partial order defined by the function @<order>: @|(funcall
518 @<order> $x$ $y$)| should return non-nil if and only if $x \preceq y$ in
519 the partial order.
520 \end{describe}
521
522 \begin{describe}{fun}{cross-product \&rest @<pieces>}
523 Return the cross product of the @<pieces>.
524
525 Each arguments may be a list, or a (non-nil) atom, which is equivalent to a
526 singleton list containing just that atom. Return a list of all possible
527 lists which can be constructed by taking one item from each argument list
528 in turn, in an arbitrary order.
529 \end{describe}
530
531 \begin{describe}{fun}
532 {find-duplicates @<report> @<sequence> \&key :key :test}
533 Call @<report> on each pair of duplicate items in a @<sequence>.
534 Duplicates are determined according to the @<key> (by default @|identity|)
535 and @<test> (by default @|eql|) functions, in the usual way: two items $x$
536 and $y$ are considered equal if and only if @|(funcall @<test> (funcall
537 @<key> $x$) (funcall @<key> $y$))| returns non-nil.
538
539 The @<report> function is called as @|(funcall @<report> @<duplicate>
540 @<previous>)|. Duplicates are reported in order; the @<previous> item is
541 always the first matching item in the sequence.
542
543 This function will work for arbitrary @<test> functions, but it will run
544 much more efficiently if @<test> is @|eq|, @|eql|, @|equal|, or @|equalp|,
545 because it can use hash-tables. (The generic implementation for lists is
546 especially inefficient.)
547 \end{describe}
548
549
550 \subsection{Position tracking}
551
552 The following functions are used to maintain file positions: see
553 \xref{sec:parsing.floc}. Columns are counted starting from zero at the far
554 left. (No particular origin is needed for line numbers.) Newlines, vertical
555 tabs, and form-feeds all move to the start of the next line; horizontal tabs
556 move to the next multiple of eight columns; other characters simply advance
557 to the next column.
558
559 \begin{describe}{fun}
560 {update-position @<character> @<line> @<column>
561 @> @<new-line> @<new-column>}
562 Assume that we found @<character> at a particular @<line> and @<column> in
563 a file: return the @<new-line> and @<new-column> for the next character.
564 \end{describe}
565
566 \begin{describe}{fun}
567 {backtrack-position @<character> @<line> @<column>
568 @> @<old-line> @<old-column>}
569 Assume that we are currently at a particular @<line> and @<column> in a
570 file, and wish to \emph{unread} @<character>: return an @<old-line> and
571 @<old-column> at which we might plausibly re-read the character, so that
572 the next call to \descref{fun}{update-position} will return us to @<line>
573 and @<column>. (Specifically, the @<old-column> will likely be wrong if
574 @<character> is a horizontal tab. It is expected that this won't matter:
575 the purpose of this function is to set things up so that the
576 @|update-position| call that will accompany re-reading the character will
577 return the correct values, rather than to use the @<old-line> and
578 @<old-column> for any other purpose.)
579 \end{describe}
580
581
582 \subsection{Object printing}
583
584 \begin{describe}{mac}
585 {maybe-print-unreadable-object
586 (@<object> @<stream>
587 @[[ :type @<type> @!
588 :identity @<identity> @]]) \\ \ind
589 @<declaration>^* \\
590 @<form>^*}
591 If @|*print-escape*| is nil, then simply evaluate the @<form>s as an
592 implicit @|progn|; otherwise, print an `unreadable' object, as if by
593 \begin{prog}
594 (print-unreadable-object
595 (@<object> @<stream>
596 @[:type @<type>@]
597 @[:identity @<identity>@]) \\ \ind
598 @<form>^*)
599 \end{prog}
600 \end{describe}
601
602 \begin{describe}{fun}{print-ugly-stuff @<stream> @<func> @> @<value>^*}
603 If @<stream> is a pretty-printing stream, then print a mandatory newline,
604 and call @<func> on the underlying non-pretty-printing stream. If
605 @<stream> is not a pretty-printing stream, then simply call @<func> on
606 @<stream> directly.
607
608 The main purpose for this is to be able to access features of the
609 underlying stream which a pretty-printing stream can't proxy. Most
610 notably, this is used by C fragment output, which takes advantage of an
611 underlying \descref{cls}{position-aware-output-stream} to print @|\#line|
612 directives, so that a C~compiler will blame the original fragment in the
613 Sod module source rather than the generated C code.
614 \end{describe}
615
616
617 \subsection{Condition utilities}
618
619 The following definitions are useful when working with conditions.
620
621 \begin{describe}{cls}
622 {simple-control-error (control-error simple-error)
623 \&key :format-control :format-arguments}
624 This is the obvious multiply-inherited subclass of @|control-error| whose
625 print form is determined by a @<format-control> and a @<format-arguments>
626 list.
627 \end{describe}
628
629 \begin{describe}{fun}
630 {designated-condition
631 \=@<default-type> @<datum> @<arguments> \\
632 \>\&key :allow-pointless-arguments
633 \nlret @<condition>}
634 Creates and returns a condition object of @<default-type>, given a
635 condition designator @<datum> and @<arguments>.
636
637 The Common Lisp specification carefully explains how a `datum' and an
638 argument list together form a `condition designator', and how such a pair
639 are to be converted into a condition object with some default type, but
640 there's no mechanism provided to simply do this task. (Functions like
641 @|error| and @|signal| implicitly, but have possibly-undesirable
642 side-effects, and don't allow control over the default type.)
643
644 \begin{itemize}
645
646 \item If @<datum> is a condition object, then the designated condition is
647 simply @<datum>. In this case, if @<arguments> is not an empty list and
648 @<allow-pointless-arguments> is nil (the default), an error is signalled;
649 otherwise, the @<arguments> are ignored.
650
651 \item If @<datum> is a symbol, then the designated condition is constructed
652 by calling
653 \begin{prog}
654 (apply \#'make-condition @<datum> @<arguments>)
655 \end{prog}
656
657 \item If @<datum> is a string or function (i.e., a `format-control'), then
658 the designated condition is constructed by calling
659 \begin{prog}
660 (make-condition \=@<default-type> \\
661 \>:format-control @<datum> \\
662 \>:format-arguments @<arguments>)
663 \end{prog}
664
665 \item Otherwise the designator is malformed, and an error is signalled.
666 \end{itemize}
667 \end{describe}
668
669 \begin{describe}{fun}
670 {invoke-associated-restart @<restart> @<condition> \&rest @<arguments>}
671 Invoke the active restart named @<restart>, associated with the given
672 @<condition>, passing a list of @<arguments>.
673
674 The function attempts to find and invoke a restart with the given name. If
675 @<condition> is non-nil, then it searches among restarts associated with
676 that specific condition, and restarts associated with no condition; if
677 @<condition> is nil, then it searches among all restarts.
678
679 If a matching restart is found, it is invoked, passing the @<arguments>
680 list. Otherwise, an error (of class @|control-error|) is signalled.
681 \end{describe}
682
683 \begin{describe*}
684 {\dhead{cls}{enclosing-condition (condition) \&key :condition}
685 \dhead{gf}{enclosed-condition @<enclosing-condition> @> @<condition>}}
686 An @|enclosing condition| is a condition which contains another condition
687 within it. Objects of type @|enclosing-condition| are used to add
688 additional information to an existing condition, or to alter the type of a
689 condition without losing information.
690
691 When an @|enclosing-condition| is constructed, the @<condition> argument
692 names the existing condition to be enclosed. This enclosed condition can
693 be retrieved by calling @|enclosed-condition|.
694 \end{describe*}
695
696 \begin{describe}{cls}{information (condition) \&key}
697 A condition of class @|information| conveys information which might be of
698 interest, but does not of itself indicate that anything is wrong.
699
700 Within a compiler, @|information| conditions may be signalled in order to
701 present the user with additional diagnostic information about a recently
702 reported error.
703 \end{describe}
704
705 \begin{describe}{cls}
706 {simple-information (simple-condition information) \\ \ind
707 \&key :format-control :format-arguments}
708 This is the obvious multiply-inherited subclass of @|information|
709 whose print-representation is determined by a @<format-control> and a
710 @<format-arguments> list.
711 \end{describe}
712
713 \begin{describe*}
714 {\dhead{fun}{info @<datum> \&rest @<arguments> @> @<flag>}
715 \dhead{rst}{noted}
716 \dhead{fun}{noted \&optional @<condition>}}
717 The @|info| function establishes a restart named @|noted| and signals a
718 condition of default type @|simple-information|, designated by the @<datum>
719 and @<arguments>. The @|info| function returns non-nil if and only if the
720 associated @|noted| restart was invoked.
721
722 The @|noted| restart accepts no arguments.
723
724 The @|noted| function finds and invokes a @|noted| restart: if @<condition>
725 is non-nil, then only the restart associated with that condition (and those
726 not associated with any condition) are considered; otherwise, all
727 conditions are considered.
728 \end{describe*}
729
730 \begin{describe}{fun}
731 {promiscuous-cerror @<continue-string> @<datum> \&rest @<arguments>}
732 Establish a @|continue| restart and signal an error of default type
733 @|simple-error|, designated by @<datum> and @<arguments>. The restart's
734 report format is determined by @<continue-string> and the @<arguments>.
735
736 Some implementations of @|cerror| associate the @|continue| restart which
737 they establish with the condition they signal. This interferes with
738 special effects -- specifically, enclosing the signalled condition and
739 resignalling it. The @|promiscuous-cerror| function carefully avoids
740 associating its restart with the condition.
741 \end{describe}
742
743 \begin{describe}{fun}{cerror* @<datum> \&rest @<arguments>}
744 A simplified version of \descref{fun}{promiscuous-cerror} which uses the
745 hardcoded string @|Continue| for the restart. This makes calling the
746 function more similar to other condition-signalling functions, at the
747 expense of some usability in environments which don't continue after
748 continuable errors automatically.
749 \end{describe}
750
751
752 \subsection{Very miscellaneous utilities}
753
754 \begin{describe}{fun}
755 {whitespace-char-p @<character> @> @<generalized-boolean>}
756 Return non-nil if and only if @<character> is a whitespace character.
757
758 A character is whitespace if @|(peek-char t @<stream>)| would skip it.
759 \end{describe}
760
761 \begin{describe}{fun}
762 {frob-identifier @<string> \&key :swap-case :swap-hyphen
763 @> @<frobbed-string>}
764 Return a `frobbed' version of the identifier @<string>. Two different
765 transformations can be applied.
766
767 \begin{itemize}
768
769 \item If @<swap-case> is non-nil (the default), and the letters in
770 @<string> are either all uppercase or all lowercase, then switch the case
771 of all of the letters.
772
773 \item If @<swap-hyphen> is non-nil (the default), and @<string> contains
774 either hyphens @`--' or underscores @`_', but not both, then replace the
775 hyphens by underscores or \emph{vice-versa}.
776
777 \end{itemize}
778
779 (These are the `obvious' transformations to convert a C identifier into a
780 Lisp symbol.)
781
782 Some examples:
783 \begin{itemize}
784 \item @|(frob-identifier "foo")| $\Longrightarrow$ @|"FOO"|
785 \item @|(frob-identifier "FOO")| $\Longrightarrow$ @|"foo"|
786 \item @|(frob-identifier "FooBar")| $\Longrightarrow$ @|"FooBar"|
787 \item @|(frob-identifier "Foo-Bar")| $\Longrightarrow$ @|"Foo_Bar"|
788 \item @|(frob-identifier "Foo_Bar")| $\Longrightarrow$ @|"Foo-Bar"|
789 \item @|(frob-identifier "foo_bar")| $\Longrightarrow$ @|"FOO-BAR"|
790 \item @|(frob-identifier "foo_bar" :swap-hyphen nil)| $\Longrightarrow$
791 @|"FOO_BAR"|
792 \item @|(frob-identifier "foo_bar" :swap-case nil)| $\Longrightarrow$
793 @|"foo-bar"|
794 \item @|(frob-identifier "foo_bar" :swap-case nil :swap-hyphen nil)|
795 $\Longrightarrow$ @|"foo_bar"|
796 \end{itemize}
797 \end{describe}
798
799 \begin{describe}{fun}
800 {compose @<functions> @> @<function>}
801 Return the left-to-right composition zero or more @<functions>.
802
803 Let $f_1$, $f_2$, \ldots, $f_n$ be functions, and let $g = @|(compose $f_1$
804 $f_2$ $\cdots$ $f_n$)|$ is their composition. If $g$ is applied to
805 arguments, the effect is as follows: first, $f_1$ is applied to the
806 arguments, yielding some value; $f_2$ is applied to this value, yielding a
807 second value; and so on, until finally the value yielded by $f_n$ is
808 returned as the result of $g$. Note that this is the reverse of the usual
809 mathematician's convention, but the author finds this ordering
810 significantly easier to work with:
811 \[ g = f_n \circ \cdots \circ f_2 \circ f_1 \]
812
813 If any of the input functions return multiple values then \emph{all} of the
814 values are passed on to the next function in the list. (If the last
815 function returns multiple values then all of the values are returned from
816 the composition.
817
818 The result of composing no functions is a function which simply returns all
819 of its arguments as values; essentially, $@|(compose)| \equiv
820 @|\#'values|$.
821 \end{describe}
822
823 \begin{describe}{mac}{defvar-unbound @<name> @<documentation> @> @<name>}
824 Define a variable called @<name>, with a @<documentation> string.
825
826 The Common Lisp @|defvar| macro accepts both an initial value and a
827 doc-string as optional arguments, in that order, with the result that it's
828 not possible to define a variable and establish a documentation string for
829 it without also giving it an initial value. The @|defvar-unbound| macro,
830 on the other hand, never changes the symbol's variable-value.
831 \end{describe}
832
833 \begin{describe}{mac}
834 {dosequence (@<var> @<sequence>
835 @[[ :start @<start> @! :end @<end> @!
836 :indexvar @<index-var> @]]) \\ \ind
837 @<declaration>^* \\
838 @{ @<tag> @! @<statement> @}^*}
839 Iterate over a @<sequence>. Common Lisp has a rich collection of iteration
840 primitives, and a rich collection of functions for working with sequences,
841 but no macro for iterating over the items of a sequence.
842
843 First, the @<sequence> is evaluated. If @<start> and/or @<end> are
844 provided, they are also evaluated (in that order), which should produce
845 integers; @<end> may be also be nil. If not provided, or nil (in the case
846 of @<end>), @<start> and @<end> default respectively to zero and the length
847 of the @<sequence>. For each item in the sequence between the @<start> and
848 @<end> positions (i.e., each item in @|(subseq @<sequence> @<start>
849 @<end>)|, in order, the body is evaluated as an implicit @|tagbody|, with
850 @<var> bound to the item and, if provided, @<index-var> bound to the item's
851 index. It is not specified whether the @<var> and @<index-var> are
852 let-bound or mutated in each iteration.
853
854 Unlike other Common Lisp @|do|\dots\ forms, there is no `result' form.
855 \end{describe}
856
857 \begin{describe}{mac}
858 {define-access-wrapper @<from> @<to>
859 @[[ :read-only @<read-only-flag> @]]}
860 Define @<from> as a function of one argument, so that @|(@<from> @<thing>)|
861 is equivalent to @|(@<to> @<thing>)|. If @<read-only-flag> is nil (the
862 default), then also define @|(setf @<from>)| so that @|(setf (@<from>
863 @<thing>) @<value>)| is equivalent to @|(setf (@<to> @<thing>) @<value>)|.
864
865 In a @|defstruct| form, the accessor function names are constructed based
866 on the structure name and slot names. The structure name and accessor
867 names are part of the exported interface, but the slot names ideally
868 shouldn't be. This causes a problem when the slot name which will lead to
869 the right accessor is already an external symbol in some package. You can
870 solve this problem by choosing an internal name for the symbol, and then
871 using this macro to define an accessor function with the name that you
872 want, in terms of the accessor that @|defstruct| made.
873 \end{describe}
874
875 \begin{describe}{fun}
876 {distinguished-point-shortest-paths @<root> @<neighbours-func>
877 @> @<list>}
878 Calculate the shortest path from the @<root> to each node reachable from it
879 in a directed graph. The nodes of the graph can be any kind of object;
880 they will be compared using @|eql|.
881
882 The @<neighbours-func> should be a function which, given a node~$v$ as its
883 only argument, returns a list of cons cells @|($v'$ . $c'$)|, one for each
884 node~$v'$ adjacent to $v$, indicating the cost $c'$ of traversing the arc
885 from $v$ to $v'$.
886
887 The return value is a list of cons cells @|($c$ . $p$)|, where $p$ is list
888 of nodes, in reverse order, along a path from the @<root> to some other
889 node, and $c$ is the total cost of traversing this path. (Therefore @|(car
890 $p$)| is the destination node, and @|(car (last $p$))| is always the
891 @<root> itself.)
892
893 The function runs in $O(n^2)$ time, where $n$ is the number of nodes
894 reachable from the @<root>. Currently, it uses an algorithm due to Edsger
895 Dijkstra.
896 \end{describe}
897
898
899 \subsection{Other exported symbols}
900
901 \begin{describe}{sym}{int}
902 The symbol @|int| is exported by the @|sod-utilities| package, without
903 giving it any particular meaning. This is done because it's given
904 non-conflicting meanings by two different packages, and it's more
905 convenient for user code not to have to deal with an unnecessary symbol
906 conflict. Specifically, the @|sod| package wants to define it as a C type
907 specifier, see \descref{cls}{simple-c-type}; and @|optparse| wants to
908 define it as an option handler, see \descref{opt}{int}.
909 \end{describe}
910
911 %%%--------------------------------------------------------------------------
912 \section{Option parser} \label{sec:misc.optparse}
913
914 Most of these symbols are defined in the @|optparse| package.
915
916 \begin{describe}{fun}{exit \&optional (@<code> 0) \&key :abrupt}
917 \end{describe}
918
919 \begin{describe}{var}{*program-name*}
920 \end{describe}
921
922 \begin{describe}{var}{*command-line*}
923 \end{describe}
924
925 \begin{describe}{fun}{set-command-line-arguments}
926 \end{describe}
927
928 \begin{describe}{fun}{moan @<format-string> \&rest @<format-args>}
929 \end{describe}
930
931 \begin{describe}{fun}{die @<format-string> \&rest @<format-args>}
932 \end{describe}
933
934 \begin{describe}{var}{*options*}
935 \end{describe}
936
937 \begin{describe}{cls}{option}
938 \end{describe}
939
940 \begin{describe}{fun}{optionp @<object> @> @<generalized-boolean>}
941 \end{describe}
942
943 \begin{describe}{fun}
944 {make-option \=@<long-name> @<short-name> \+\\
945 \&optional @<arg-name> \\
946 \&key :tag :negated-tag
947 :arg-optional-p :documentation \-
948 \nlret @<option>}
949 \end{describe}
950
951 \begin{describe*}
952 {\dhead{fun}{opt-short-name @<option> @> @<character-or-null>}
953 \dhead{fun}{setf (opt-short-name @<option>) @<character-or-null>}
954 \dhead{fun}{opt-long-name @<option> @> @<string-or-null>}
955 \dhead{fun}{setf (opt-long-name @<option>) @<string-or-null>}
956 \dhead{fun}{opt-tag @<option> @> @<tag>}
957 \dhead{fun}{setf (opt-tag @<option>) @<tag>}
958 \dhead{fun}{opt-negated-tag @<option> @> @<tag>}
959 \dhead{fun}{setf (opt-negated-tag @<option>) @<tag>}
960 \dhead{fun}{opt-arg-name @<option> @> @<string-or-null>}
961 \dhead{fun}{setf (opt-arg-name @<option>) @<string-or-null>}
962 \dhead{fun}{opt-arg-optional-p @<option> @> @<generalized-boolean>}
963 \dhead{fun}{setf (opt-arg-optional-p @<option>) @<generalized-boolean>}
964 \dhead{fun}{opt-documentation @<option> @> @<string-or-null>}
965 \dhead{fun}{setf (opt-documentation @<option>) @<string-or-null>}}
966 \end{describe*}
967
968 \begin{describe}{cls}{option-parser}
969 \end{describe}
970
971 \begin{describe}{fun}{option-parser-p @<object> @> @<generalized-boolean>}
972 \end{describe}
973
974 \begin{describe}{fun}
975 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
976 :negated-numeric-p long-only-p \-
977 \nlret @<option-parser>}
978 \end{describe}
979
980 \begin{describe*}
981 {\dhead{fun}{op-options @<option-parser> @> @<list>}
982 \dhead{fun}{setf (op-options @<option-parser>) @<list>}
983 \dhead{fun}{op-non-option @<option-parser> @> @<action>}
984 \dhead{fun}{setf (op-non-option @<option-parser>) @<action>}
985 \dhead{fun}{op-long-only-p @<option-parser> @> @<generalized-boolean>}
986 \dhead{fun}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>}
987 \dhead{fun}{op-numeric-p @<option-parser> @> @<generalized-boolean>}
988 \dhead{fun}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>}
989 \dhead{fun}{op-negated-numeric-p @<option-parser> @<generalized-boolean>}
990 \dhead{fun}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>}
991 \dhead{fun}{op-negated-p @<option-parser> @> @<generalized-boolean>}
992 \dhead{fun}{setf (op-negated-p @<option-parser>) @<generalized-boolean>}}
993 \end{describe*}
994
995 \begin{describe}{cls}
996 {option-parse-error (error simple-condition)
997 \&key :format-control :format-arguments}
998 \end{describe}
999
1000 \begin{describe}{fun}{option-parse-error @<msg> \&optional @<args>}
1001 \end{describe}
1002
1003 \begin{describe}{fun}{option-parse-remainder @<option-parser>}
1004 \end{describe}
1005
1006 \begin{describe}{fun}{option-parse-return @<tag> \&optional @<argument>}
1007 \end{describe}
1008
1009 \begin{describe}{fun}{option-parse-next @<option-parser>}
1010 \end{describe}
1011
1012 \begin{describe}{mac}{option-parse-try @<form>^*}
1013 \end{describe}
1014
1015 \begin{describe}{mac}{with-unix-error-reporting () @<form>^*}
1016 \end{describe}
1017
1018 \begin{describe}{mac}
1019 {defopthandler @<name> (@<var> @[@<arg>@]) @<lambda-list> \\ \ind
1020 @[[ @<declaration>^* @! @<doc-string> @]] \\
1021 @<form>^*}
1022 \end{describe}
1023
1024 \begin{describe}{fun}
1025 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>}
1026 \end{describe}
1027
1028 \begin{describe}{opt}{set \&optional @<value>}
1029 \end{describe}
1030
1031 \begin{describe}{opt}{clear \&optional @<value>}
1032 \end{describe}
1033
1034 \begin{describe}{opt}{inc \&optional @<maximum> @<step>}
1035 \end{describe}
1036
1037 \begin{describe}{opt}{dec \&optional @<minimum> @<step>}
1038 \end{describe}
1039
1040 \begin{describe}{opt}{read}
1041 \end{describe}
1042
1043 \begin{describe}{opt}{int \&key :radix :min :max}
1044 \end{describe}
1045
1046 \begin{describe}{opt}{string}
1047 \end{describe}
1048
1049 \begin{describe}{opt}{keyword \&optional @<valid>}
1050 \end{describe}
1051
1052 \begin{describe}{opt}{list \&optional @<handler> \&rest @<handler-args>}
1053 \end{describe}
1054
1055 \begin{describe}{mac}
1056 {defoptmacro @<name> @<lambda-list> \\ \ind
1057 @[[ @<declaration>^* @! @<doc-string> @]] \\
1058 @<form>^*}
1059 \end{describe}
1060
1061 \begin{describe}{fun}{parse-option-form @<form>}
1062 \end{describe}
1063
1064 \begin{describe}{mac}
1065 {options @{ \=@<string> @! \+ \\
1066 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
1067 (@[[ \=@<character> @! (:short-name @<character>) @! \+ \\
1068 @<string>^* @! @<symbol> @! @<rational> @!
1069 (:long-name @<string>) @! \\
1070 (@<string> @<format-arg>^+) @!
1071 (:doc @<string> @<format-arg>^*) @! \\
1072 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
1073 @<keyword> @! (:tag @<tag>) @!
1074 (:negated-tag @<tag>) @! \\
1075 @{ (@<handler> @<var> @<handler-arg>^*) @}^*
1076 @]]) @}^*}
1077 \end{describe}
1078
1079 \begin{describe}{fun}
1080 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>}
1081 \end{describe}
1082
1083 \begin{describe}{fun}{show-usage @<prog> @<usage> \&optional @<stream>}
1084 \end{describe}
1085
1086 \begin{describe}{fun}
1087 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>}
1088 \end{describe}
1089
1090 \begin{describe}{fun}{sanity-check-option-list @<option-list>}
1091 \end{describe}
1092
1093 \begin{describe*}
1094 {\dhead{var}{*help*}
1095 \dhead{var}{*version*}
1096 \dhead{var}{*usage*}}
1097 \end{describe*}
1098
1099 \begin{describe}{fun}{do-usage \&optional @<stream>}
1100 \end{describe}
1101
1102 \begin{describe}{fun}{die-usage}
1103 \end{describe}
1104
1105 \begin{describe}{optmac}
1106 {help-options \&key :short-help :short-version :short-usage}
1107 \end{describe}
1108
1109 \begin{describe}{fun}
1110 {define-program \&key \=:program-name \+ \\
1111 :help :version :usage :full-usage \\
1112 :options}
1113 \end{describe}
1114
1115 \begin{describe}{mac}
1116 {do-options (@[[ :parser @<option-parser> @]]) \\ \ind
1117 @{ (@{ @<case> @! (@<case>^*)@} (@[@[@<opt-var>@] @<arg-var>@])
1118 @<form>^*) @}^*}
1119 \end{describe}
1120
1121 \begin{describe}{fun}{sod-frontend:augment-options @<options-list>}
1122 \end{describe}
1123
1124 %%%--------------------------------------------------------------------------
1125 \section{Property sets} \label{sec:misc.pset}
1126
1127 \begin{describe}{fun}{property-key @<name> @> @<keyword>}
1128 \end{describe}
1129
1130 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
1131 \end{describe}
1132
1133 \begin{describe}{cls}{property}
1134 \end{describe}
1135
1136 \begin{describe}{fun}{propertyp @<object> @> @<generalized-boolean>}
1137 \end{describe}
1138
1139 \begin{describe}{fun}
1140 {make-property @<name> @<raw-value> \&key :type :location :seenp}
1141 \end{describe}
1142
1143 \begin{describe*}
1144 {\dhead{fun}{p-name @<property> @> @<name>}
1145 \dhead{meth}{property}{file-location (@<property> property) @> @<floc>}
1146 \dhead{fun}{p-value @<property> @> @<value>}
1147 \dhead{fun}{p-type @<property> @> @<type>}
1148 \dhead{fun}{p-key @<property> @> @<symbol>}
1149 \dhead{fun}{p-seenp @<property> @> @<boolean>}
1150 \dhead{fun}{setf (p-seenp @<property>) @<boolean>}}
1151 \end{describe*}
1152
1153 \begin{describe}{gf}
1154 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>}
1155 \end{describe}
1156
1157 \begin{describe}{cls}{pset}
1158 \end{describe}
1159
1160 \begin{describe}{fun}{psetp @<object> @> @<generalized-boolean>}
1161 \end{describe}
1162
1163 \begin{describe}{fun}{make-pset @> @<pset>}
1164 \end{describe}
1165
1166 \begin{describe}{fun}{pset-get @<pset> @<key> @> @<property-or-nil>}
1167 \end{describe}
1168
1169 \begin{describe}{fun}{pset-store @<pset> @<property> @> @<property>}
1170 \end{describe}
1171
1172 \begin{describe}{fun}{pset-map @<func> @<pset>}
1173 \end{describe}
1174
1175 \begin{describe}{mac}
1176 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*}
1177 \end{describe}
1178
1179 \begin{describe}{fun}
1180 {store-property @<pset> @<name> @<value> \&key :type :location
1181 @> @<property>}
1182 \end{describe}
1183
1184 \begin{describe}{fun}
1185 {get-property @<pset> @<name> @<type> \&optional @<default>
1186 @> @<value> @<floc-or-nil>}
1187 \end{describe}
1188
1189 \begin{describe}{fun}
1190 {add-property @<pset> @<name> @<value> \&key :type :location
1191 @> @<property>}
1192 \end{describe}
1193
1194 \begin{describe}{fun}{make-property-set \&rest @<plist> @> @<pset>}
1195 \end{describe}
1196
1197 \begin{describe}{gf}{property-set @<thing> @> @<pset>}
1198 \end{describe}
1199
1200 \begin{describe}{fun}{check-unused-properties @<pset>}
1201 \end{describe}
1202
1203 \begin{describe}{mac}
1204 {default-slot-from-property
1205 (@<instance> @<slot> @[@<slot-names>@]) \\ \ind\ind
1206 (@<pset> @<property> @<type> @[@<prop-var> @<convert-form>^*@]) \- \\
1207 @<declaration>^* \\
1208 @<default-form>^*}
1209 \end{describe}
1210
1211 \begin{describe}{fun}
1212 {parse-property @<scanner> @<pset>
1213 @> @<result> @<success-flag> @<consumed-flag>}
1214 \end{describe}
1215
1216 \begin{describe}{fun}
1217 {parse-property-set @<scanner>
1218 @> @<result> @<success-flag> @<consumed-flag>}
1219 \end{describe}
1220
1221 %%%--------------------------------------------------------------------------
1222 \section{Miscellaneous translator features} \label{sec:misc.misc}
1223
1224 \begin{describe}{var}{*sod-version*}
1225 \end{describe}
1226
1227 \begin{describe}{var}{*debugout-pathname*}
1228 \end{describe}
1229
1230 \begin{describe}{fun}
1231 {test-module @<path> \&key :reason :clear :backtrace @> @<status>}
1232 \end{describe}
1233
1234 \begin{describe}{fun}
1235 {test-parse-c-type @<string>
1236 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>}
1237 \end{describe}
1238
1239 \begin{describe}{fun}
1240 {test-parse-pset @<string>
1241 @> t @<pset> @! nil @<indicator>}
1242 \end{describe}
1243
1244 \begin{describe}{mac}
1245 {test-parser (@<scanner> \&key :backtrace) @<parser> @<input>
1246 @> @<result> @<status> @<remainder>}
1247 \end{describe}
1248
1249 \begin{describe}{fun}{exercise}
1250 \end{describe}
1251
1252 \begin{describe}{fun}{sod-frontend:main}
1253 \end{describe}
1254
1255 %%%----- That's all, folks --------------------------------------------------
1256
1257 %%% Local variables:
1258 %%% mode: LaTeX
1259 %%% TeX-master: "sod.tex"
1260 %%% TeX-PDF-mode: t
1261 %%% End: