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