chiark / gitweb /
src/utilities.lisp: Convert merge candidates to presentation form on the fly.
[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 \begin{describe}{mac}
37     {with-gensyms (@{ @<var> @! (@<var> @[@<name>@]) @}^*)      \\ \ind
38       @<declaration>^*                                          \\
39       @<form>^*}
40 \end{describe}
41
42 \begin{describe}{mac}
43     {once-only (@[[ :environment @<env> @]]
44                 @{ @<var> @! (@<var> @[@<value-form>@]) @}^*)   \\ \ind
45       @<declaration>^*                                          \\
46       @<form>^*}
47 \end{describe}
48
49 \begin{describe}{mac}
50     {parse-body @<body> \&key :docp :declp
51       @> @<doc-string> @<declarations> @<body-forms>}
52 \end{describe}
53
54 \begin{describe}{cls}{loc}
55 \end{describe}
56
57 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
58 \end{describe}
59
60
61 \subsection{Locatives}
62
63 \begin{describe}{fun}{locp @<object> @> @<generalized-boolean>}
64 \end{describe}
65
66 \begin{describe}{mac}{locf @<place> @> @<locative>}
67 \end{describe}
68
69 \begin{describe*}
70     {\dhead{fun}{ref @<locative> @> @<value>}
71      \dhead{fun}{setf (ref @<locative>) @<value>}}
72 \end{describe*}
73
74 \begin{describe}{mac}
75     {with-locatives
76         @{ @<var> @! (@{ @<var> @!
77                          (@<var> @[@<locative>@]) @}^*) @}      \\ \ind
78       @<declaration>^*                                          \\
79       @<form>^*}
80 \end{describe}
81
82
83 \subsection{Anaphorics}
84
85 \begin{describe}{sym}{it}
86 \end{describe}
87
88 \begin{describe}{mac}{aif @<condition> @<consequent> @[@<alt>@]}
89 \end{describe}
90
91 \begin{describe}{mac}{aand @<form>^*}
92 \end{describe}
93
94 \begin{describe}{mac}{awhen @<condition> @<form>^*}
95 \end{describe}
96
97 \begin{describe}{mac}{acond @{ (@<condition> @<form>^*) @}^*}
98 \end{describe}
99
100 \begin{describe*}
101     {\dhead{mac}
102       {acase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
103      \dhead{mac}
104       {aecase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
105      \dhead{mac}{atypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}
106      \dhead{mac}{aetypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}}
107 \end{describe*}
108
109 \begin{describe}{mac}{asetf @{ @<place> @<value> @}^*}
110 \end{describe}
111
112
113 \subsection{Metaobject protocol utilities}
114
115 \begin{describe}{gf}{instance-initargs @<instance>}
116 \end{describe}
117
118 \begin{describe*}
119     {\dhead{fun}{copy-instance @<instance> \&rest @<initargs>}
120      \dhead{gf}{copy-instance-using-class @<class> @<instance>
121                                           \&rest @<initargs>}}
122 \end{describe*}
123
124 \begin{describe*}
125     {\dhead{gf}{generic-function-methods @<generic-function> @> @<list>}
126      \dhead{gf}{method-specializers @<method> @> @<list>}
127      \dhead{cls}{eql-specializer}
128      \dhead{gf}{eql-specializer-object @<specializer> @> @<value>}}
129 \end{describe*}
130
131
132 \subsection{Other CLOS utilities}
133
134 \begin{describe}{mac}
135     {default-slot (@<instance> @<slot> @[@<slot-names>@])       \\ \ind
136       @<form>^*}
137 \end{describe}
138
139 \begin{describe}{mac}
140     {define-on-demand-slot @<class> @<slot> (@<instance>)       \\ \ind
141       @[[ @<declaration>^* @! @<doc-string> @]]                 \\
142       @<form>^*}
143 \end{describe}
144
145
146 \subsection{Building lists}
147
148 \begin{describe}{fun}{make-list-builder \&optional @<initial> @> @<builder>}
149 \end{describe}
150
151 \begin{describe}{fun}{lbuild-add @<builder> @<item> @> @<builder>}
152 \end{describe}
153
154 \begin{describe}{fun}{lbuild-add-list @<builder> @<list> @> @<builder>}
155 \end{describe}
156
157 \begin{describe}{fun}{lbuild-list @<builder> @> @<list>}
158 \end{describe}
159
160
161 \subsection{Merging lists}
162
163 \begin{describe}{cls}
164     {inconsistent-merge-error (error) \&key :candidates :present}
165 \end{describe}
166
167 \begin{describe}{gf}{merge-error-candidates @<error> @> @<list>}
168 \end{describe}
169
170 \begin{describe}{gf}{merge-error-present-function @<error> @> @<function>}
171 \end{describe}
172
173 \begin{describe}{fun}
174     {merge-lists @<lists> \&key :pick (:test \#'eql) :present @> @<list>}
175 \end{describe}
176
177
178 \subsection{Other list utilities}
179
180 \begin{describe}{fun}
181     {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>}
182 \end{describe}
183
184 \begin{describe}{fun}
185     {distinguished-point-shortest-paths @<root> @<neighbours-func>
186       @> @<list>}
187 \end{describe}
188
189 \begin{describe}{mac}
190     {categorize (\=@<item-var> @<items>
191                    @[[ :bind (@{ @<var> @!
192                                  (@<var> @[@<value>@]) @}^*) @]])
193                                                                 \\ \ind\ind
194         (@{ (@<cat-var> @<cat-predicate>) @}^*)               \-\\
195       @<declaration>^*                                          \\
196       @<form>^*
197      \-\nlret @<value>^*}
198 \end{describe}
199
200 \begin{describe}{fun}{partial-order-minima @<items> @<order> @> @<list>}
201 \end{describe}
202
203 \begin{describe}{fun}
204     {find-duplicates @<report> @<sequence> \&key :identity :test}
205 \end{describe}
206
207
208 \subsection{Position tracking}
209
210 \begin{describe}{fun}
211     {whitespace-char-p @<character> @> @<generalized-boolean>}
212 \end{describe}
213
214 \begin{describe}{fun}
215     {update-position @<character> @<line> @<column>
216       @> @<new-line> @<new-column>}
217 \end{describe}
218
219 \begin{describe}{fun}
220     {backtrack-position @<character> @<line> @<column>
221       @> @<old-line> @<old-column>}
222 \end{describe}
223
224
225 \subsection{Object printing}
226
227 \begin{describe}{mac}
228     {maybe-print-unreadable-object
229         (@<object> @<stream>
230          @[[ :type @<type> @!
231              :identity @<identity> @]])                         \\ \ind
232       @<declaration>^*                                          \\
233       @<form>^*}
234 \end{describe}
235
236 \begin{describe}{fun}{print-ugly-stuff @<stream> @<func> @> @<value>^*}
237 \end{describe}
238
239
240 \subsection{Condition utilities}
241
242 \begin{describe}{cls}
243     {simple-control-error (control-error simple-error)
244         \&key :format-control :format-arguments}
245 \end{describe}
246
247 \begin{describe}{fun}
248     {designated-condition
249         \=@<default-type> @<datum> @<arguments>                 \\
250         \>\&key :allow-pointless-arguments
251       \nlret @<condition>}
252 \end{describe}
253
254 \begin{describe}{fun}
255     {invoke-associated-restart @<restart> @<condition> \&rest @<arguments>}
256 \end{describe}
257
258
259 \subsection{Very miscellaneous utilities}
260
261 \begin{describe}{fun}
262     {frob-identifier @<string> \&key :swap-case :swap-hyphen
263       @> @<frobbed-string>}
264 \end{describe}
265
266 \begin{describe}{fun}
267     {compose @<function> \&rest @<more-functions> @> @<function>}
268 \end{describe}
269
270 \begin{describe}{mac}{defvar-unbound @<name> @<documentation> @> @<name>}
271 \end{describe}
272
273 \begin{describe}{mac}
274     {dosequence (@<var> @<sequence>
275                  @[[ :start @<start> @! :end @<end> @!
276                      :indexvar @<var> @]])                      \\ \ind
277       @<declaration>^*                                          \\
278       @{ @<tag> @! @<statement> @}^*}
279 \end{describe}
280
281 \begin{describe}{mac}
282     {define-access-wrapper @<from> @<to>
283                            @[[ :read-only @<read-only-flag> @]]}
284 \end{describe}
285
286 %%%--------------------------------------------------------------------------
287 \section{Condition utilities} \label{sec:misc.condition}
288
289 These symbols are defined in the @|sod-parser| package.
290
291 \begin{describe}{cls}{enclosing-condition (condition) \&key :condition}
292 \end{describe}
293
294 \begin{describe}{gf}
295     {enclosed-condition @<enclosing-condition> @> @<condition>}
296 \end{describe}
297
298 \begin{describe}{cls}{information (condition) \&key}
299 \end{describe}
300
301 \begin{describe}{cls}
302     {simple-information (simple-condition information)          \\ \ind
303       \&key :format-control :format-arguments}
304 \end{describe}
305
306 \begin{describe}{fun}{info @<datum> \&rest @<arguments> @> @<flag>}
307 \end{describe}
308
309 \begin{describe*}
310     {\dhead{rst}{noted}
311      \dhead{fun}{noted \&optional @<condition>}}
312 \end{describe*}
313
314 \begin{describe}{fun}{cerror* @<datum> \&rest @<arguments>}
315 \end{describe}
316
317 %%%--------------------------------------------------------------------------
318 \section{Option parser} \label{sec:misc.optparse}
319
320 These symbols are defined in the @|optparse| package.
321
322 \begin{describe}{fun}{exit \&optional (@<code> 0) \&key :abrupt}
323 \end{describe}
324
325 \begin{describe}{var}{*program-name*}
326 \end{describe}
327
328 \begin{describe}{var}{*command-line*}
329 \end{describe}
330
331 \begin{describe}{fun}{set-command-line-arguments}
332 \end{describe}
333
334 \begin{describe}{fun}{moan @<format-string> \&rest @<format-args>}
335 \end{describe}
336
337 \begin{describe}{fun}{die @<format-string> \&rest @<format-args>}
338 \end{describe}
339
340 \begin{describe}{var}{*options*}
341 \end{describe}
342
343 \begin{describe}{cls}{option}
344 \end{describe}
345
346 \begin{describe}{fun}{optionp @<object> @> @<generalized-boolean>}
347 \end{describe}
348
349 \begin{describe}{fun}
350     {make-option \=@<long-name> @<short-name>                 \+\\
351                    \&optional @<arg-name>                       \\
352                    \&key :tag :negated-tag
353                          :arg-optional-p :documentation       \-
354       \nlret @<option>}
355 \end{describe}
356
357 \begin{describe*}
358     {\dhead{fun}{opt-short-name @<option> @> @<character-or-null>}
359      \dhead{fun}{setf (opt-short-name @<option>) @<character-or-null>}
360      \dhead{fun}{opt-long-name @<option> @> @<string-or-null>}
361      \dhead{fun}{setf (opt-long-name @<option>) @<string-or-null>}
362      \dhead{fun}{opt-tag @<option> @> @<tag>}
363      \dhead{fun}{setf (opt-tag @<option>) @<tag>}
364      \dhead{fun}{opt-negated-tag @<option> @> @<tag>}
365      \dhead{fun}{setf (opt-negated-tag @<option>) @<tag>}
366      \dhead{fun}{opt-arg-name @<option> @> @<string-or-null>}
367      \dhead{fun}{setf (opt-arg-name @<option>) @<string-or-null>}
368      \dhead{fun}{opt-optional-p @<option> @> @<generalized-boolean>}
369      \dhead{fun}{setf (opt-optional-p @<option>) @<generalized-boolean>}
370      \dhead{fun}{opt-documentation @<option> @> @<string-or-null>}
371      \dhead{fun}{setf (opt-documentation @<option>) @<string-or-null>}}
372 \end{describe*}
373
374 \begin{describe}{cls}{option-parser}
375 \end{describe}
376
377 \begin{describe}{fun}{option-parser-p @<object> @> @<generalized-boolean>}
378 \end{describe}
379
380 \begin{describe}{fun}
381     {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
382                               :negated-numeric-p long-only-p \-
383       \nlret @<option-parser>}
384 \end{describe}
385
386 \begin{describe*}
387     {\dhead{fun}{op-options @<option-parser> @> @<list>}
388      \dhead{fun}{setf (op-options @<option-parser>) @<list>}
389      \dhead{fun}{op-non-option @<option-parser> @> @<action>}
390      \dhead{fun}{setf (op-non-option @<option-parser>) @<action>}
391      \dhead{fun}{op-long-only-p @<option-parser> @> @<generalized-boolean>}
392      \dhead{fun}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>}
393      \dhead{fun}{op-numeric-p @<option-parser> @> @<generalized-boolean>}
394      \dhead{fun}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>}
395      \dhead{fun}{op-negated-numeric-p @<option-parser> @<generalized-boolean>}
396      \dhead{fun}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>}
397      \dhead{fun}{op-negated-p @<option-parser> @> @<generalized-boolean>}
398      \dhead{fun}{setf (op-negated-p @<option-parser>) @<generalized-boolean>}}
399 \end{describe*}
400
401 \begin{describe}{cls}
402     {option-parse-error (error simple-condition)
403       \&key :format-control :format-arguments}
404 \end{describe}
405
406 \begin{describe}{fun}{option-parse-remainder @<option-parser>}
407 \end{describe}
408
409 \begin{describe}{fun}{option-parse-return @<tag> \&optional @<argument>}
410 \end{describe}
411
412 \begin{describe}{fun}{option-parse-next @<option-parser>}
413 \end{describe}
414
415 \begin{describe}{mac}{option-parse-try @<form>^*}
416 \end{describe}
417
418 \begin{describe}{mac}{with-unix-error-reporting () @<form>^*}
419 \end{describe}
420
421 \begin{describe}{mac}
422     {defopthandler @<name> (@<var> @[@<arg>@]) @<lambda-list> \\ \ind
423       @[[ @<declaration>^* @! @<doc-string> @]] \\
424       @<form>^*}
425 \end{describe}
426
427 \begin{describe}{fun}
428     {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>}
429 \end{describe}
430
431 \begin{describe}{opt}{set \&optional @<value>}
432 \end{describe}
433
434 \begin{describe}{opt}{clear \&optional @<value>}
435 \end{describe}
436
437 \begin{describe}{opt}{inc \&optional @<maximum> @<step>}
438 \end{describe}
439
440 \begin{describe}{opt}{dec \&optional <minimum> <step>}
441 \end{describe}
442
443 \begin{describe}{opt}{read}
444 \end{describe}
445
446 \begin{describe}{opt}{int \&key :radix :min :max}
447 \end{describe}
448
449 \begin{describe}{opt}{string}
450 \end{describe}
451
452 \begin{describe}{opt}{keyword \&optional @<valid>}
453 \end{describe}
454
455 \begin{describe}{opt}{list \&optional @<handler> \&rest @<handler-args>}
456 \end{describe}
457
458 \begin{describe}{mac}
459     {defoptmacro @<name> @<lambda-list> \\ \ind
460       @[[ @<declaration>^* @! @<doc-string> @]] \\
461       @<form>^*}
462 \end{describe}
463
464 \begin{describe}{fun}{parse-option-form @<form>}
465 \end{describe}
466
467 \begin{describe}{mac}
468     {options @{ \=@<string> @! \+ \\
469                   @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
470                   (@[[ \=@<character> @! (:short-name @<character>) @! \+ \\
471                          @<string>^* @! @<symbol> @! @<rational> @!
472                          (:long-name @<string>) @! \\
473                          (@<string> @<format-arg>^+) @!
474                          (:doc @<string> @<format-arg>^*) @! \\
475                          (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
476                          @<keyword> @! (:tag @<tag>) @!
477                                        (:negated-tag @<tag>) @! \\
478                          @{ (@<handler> @<var> @<handler-arg>^*) @}^*
479                    @]]) @}^*}
480 \end{describe}
481
482 \begin{describe}{fun}
483     {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>}
484 \end{describe}
485
486 \begin{describe}{fun}{show-usage @<prog> @<usage> \&optional @<stream>}
487 \end{describe}
488
489 \begin{describe}{fun}
490     {show-help @<prog> @<usage> @<option-list> \&optional @<stream>}
491 \end{describe}
492
493 \begin{describe}{fun}{sanity-check-option-list @<option-list>}
494 \end{describe}
495
496 \begin{describe*}
497     {\dhead{var}{*help*}
498      \dhead{var}{*version*}
499      \dhead{var}{*usage*}}
500 \end{describe*}
501
502 \begin{describe}{fun}{do-usage \&optional @<stream>}
503 \end{describe}
504
505 \begin{describe}{fun}{die-usage}
506 \end{describe}
507
508 \begin{describe}{optmac}
509     {help-options \&key :short-help :short-version :short-usage}
510 \end{describe}
511
512 \begin{describe}{fun}
513     {define-program \&key \=:program-name \+ \\
514                             :help :version :usage :full-usage \\
515                             :options}
516 \end{describe}
517
518 \begin{describe}{mac}
519     {do-options (@[[ :parser @<option-parser> @]]) \\ \ind
520       @{ (@{ @<case> @! (@<case>^*)@} (@[@[@<opt-var>@] @<arg-var>@])
521           @<form>^*) @}^*}
522 \end{describe}
523
524 %%%--------------------------------------------------------------------------
525 \section{Property sets} \label{sec:misc.pset}
526
527 \begin{describe}{fun}{property-key @<name> @> @<keyword>}
528 \end{describe}
529
530 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
531 \end{describe}
532
533 \begin{describe}{cls}{property}
534 \end{describe}
535
536 \begin{describe}{fun}{propertyp @<object> @> @<generalized-boolean>}
537 \end{describe}
538
539 \begin{describe}{fun}
540     {make-property @<name> @<raw-value> \&key :type :location :seenp}
541 \end{describe}
542
543 \begin{describe*}
544     {\dhead{fun}{p-name @<property> @> @<name>}
545      \dhead{fun}{p-value @<property> @> @<value>}
546      \dhead{fun}{p-type @<property> @> @<type>}
547      \dhead{fun}{p-key @<property> @> @<symbol>}
548      \dhead{fun}{p-seenp @<property> @> @<boolean>}
549      \dhead{fun}{setf (p-seenp @<property>) @<boolean>}}
550 \end{describe*}
551
552 \begin{describe}{gf}
553     {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>}
554 \end{describe}
555
556 \begin{describe}{cls}{pset}
557 \end{describe}
558
559 \begin{describe}{fun}{psetp @<object> @> @<generalized-boolean>}
560 \end{describe}
561
562 \begin{describe}{fun}{make-pset @> @<pset>}
563 \end{describe}
564
565 \begin{describe}{fun}{pset-get @<pset> @<key> @> @<property-or-nil>}
566 \end{describe}
567
568 \begin{describe}{fun}{pset-store @<pset> @<property> @> @<property>}
569 \end{describe}
570
571 \begin{describe}{fun}{pset-map @<func> @<pset>}
572 \end{describe}
573
574 \begin{describe}{mac}
575     {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*}
576 \end{describe}
577
578 \begin{describe}{fun}
579     {store-property @<pset> @<name> @<value> \&key :type :location
580       @> @<property>}
581 \end{describe}
582
583 \begin{describe}{fun}
584     {get-property @<pset> @<name> @<type> \&optional @<default>
585       @> @<value> @<floc-or-nil>}
586 \end{describe}
587
588 \begin{describe}{fun}
589     {add-property @<pset> @<name> @<value> \&key :type :location
590       @> @<property>}
591 \end{describe}
592
593 \begin{describe}{fun}{make-property-set \&rest @<plist> @> @<pset>}
594 \end{describe}
595
596 \begin{describe}{gf}{property-set @<thing> @> @<pset>}
597 \end{describe}
598
599 \begin{describe}{fun}{check-unused-properties @<pset>}
600 \end{describe}
601
602 \begin{describe}{mac}
603     {default-slot-from-property
604         (@<instance> @<slot> @[@<slot-names>@]) \\ \ind\ind
605         (@<pset> @<property> @<type> @[@<prop-var> @<convert-form>^*@]) \- \\
606       @<declaration>^* \\
607       @<default-form>^*}
608 \end{describe}
609
610 \begin{describe}{fun}
611     {parse-property @<scanner> @<pset>
612       @> @<result> @<success-flag> @<consumed-flag>}
613 \end{describe}
614
615 \begin{describe}{fun}
616     {parse-property-set @<scanner>
617       @> @<result> @<success-flag> @<consumed-flag>}
618 \end{describe}
619
620 %%%--------------------------------------------------------------------------
621 \section{Miscellaneous translator features} \label{sec:misc.misc}
622
623 \begin{describe}{var}{*sod-version*}
624 \end{describe}
625
626 \begin{describe}{var}{*debugout-pathname*}
627 \end{describe}
628
629 \begin{describe}{fun}
630     {test-module @<path> \&key :reason :clear :backtrace @> @<status>}
631 \end{describe}
632
633 \begin{describe}{fun}
634     {test-parse-c-type @<string>
635       @> t @<c-type> @<kernel> @<string> @! nil @<indicator>}
636 \end{describe}
637
638 \begin{describe}{fun}
639     {test-parse-pset @<string>
640       @> t @<pset> @! nil @<indicator>}
641 \end{describe}
642
643 \begin{describe}{mac}
644     {test-parser (@<scanner> \&key :backtrace) @<parser> @<input>
645       @> @<result> @<status> @<remainder>}
646 \end{describe}
647
648 \begin{describe}{fun}{exercise}
649 \end{describe}
650
651 \begin{describe}{fun}{sod-frontend:main}
652 \end{describe}
653
654 %%%----- That's all, folks --------------------------------------------------
655
656 %%% Local variables:
657 %%% mode: LaTeX
658 %%% TeX-master: "sod.tex"
659 %%% TeX-PDF-mode: t
660 %%% End: