added missing symbols
[clqr.git] / clqr-input-output.tex
blob3dc628a17e400a101ea02004d9a1b845ccbf0fb8
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 \section{Input/Output}
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 \subsection{Predicates}
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9 \begin{LIST}{1cm}
11 \IT{\arrGOO{(\FU*{STREAMP} \VAR{ foo})\\
12 (\FU*{PATHNAMEP} \VAR{ foo})\\
13 (\FU*{READTABLEP} \VAR{ foo})}{\}}}
14 Return \retval{\T} if \VAR{foo} is of type \kwd{stream},
15 \kwd{pathname}, or \kwd{readtable}, resp.
17 \IT{\arrGOO{(\FU*{INPUT-STREAM-P} \VAR{ stream})\\
18 (\FU*{OUTPUT-STREAM-P} \VAR{ stream})\\
19 (\FU*{INTERACTIVE-STREAM-P} \VAR{ stream})\\
20 (\FU*{OPEN-STREAM-P} \VAR{ stream})}{\}}}
21 Return \retval{\T} if \VAR{stream} is for input, for output,
22 interactive, or open, resp.
24 \IT{(\FU*{PATHNAME-MATCH-P} \VAR{path} \VAR{wildcard})}
25 \retval{\T} if \VAR{path} matches \VAR{wildcard}.
27 \IT{(\FU*{WILD-PATHNAME-P} \VAR{path}
28 \OP{\Goo{\kwd{:host}\XOR\kwd{:device}\XOR
29 \kwd{:directory}\XOR\kwd{:name}\XOR\kwd{:type}
30 \XOR\kwd{:version}\XOR\NIL}})}
31 Return \retval{\T} if indicated component in \VAR{path} is wildcard.
33 \end{LIST}
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 \subsection{Reader}
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 \begin{LIST}{1cm}
42 \IT{(\xorGOO{\FU*{Y-OR-N-P}\\
43 \FU*{YES-OR-NO-P}}{\}} \OP{\VAR{control} \Op{\VAR{args}}})}
44 Ask user a question and return \retval{\T} or \retval{\NIL}
45 depending on their answer. See p.\ \pageref{section:Format},
46 \kwd{format}, for \VAR{control} and \VAR{args}.
48 \IT{(\SF*{WITH-STANDARD-IO-SYNTAX} \OPn{\VAR{form}})}
49 Evaluate \VAR{form}s with standard behaviour of reader and
50 printer. Return \retval{values of \VAR{form}s}.
52 \IT{(\xorGOO{\FU*{READ}\\
53 \FU*{READ-PRESERVING-WHITESPACE}}{\}}
54 \OP{\VAR{stream}\DF{\T} \OP{\VAR{eof-err}\DF{\T}
55 \Op{\VAR{eof-val}\DF{\NIL} \Op{\VAR{recursive}\DF{\NIL}}}}})}
56 Read printed representation of \retval{object}.
58 \IT{(\FU*{READ-FROM-STRING} \VAR{string}\OP{\VAR{eof-error}\DF{\T}
59 \Op{\VAR{eof-val}\DF{\NIL}}}\orGOO{%
60 \kwd{:start}\kwd{:start}\VAR{ start}\DF{0}\\
61 \kwd{:end}\VAR{ end}\DF{\NIL}\\
62 \kwd{:preserve-whitespace}\VAR{ bool}\DF{\NIL}}{\}})}
63 Return \retval{object} read from string and \retvalii{position} of
64 next character.
66 \IT{(\FU*{READ-DELIMITED-LIST} \VAR{char}
67 \OP{\VAR{stream}\DF{\kwd{*standard-input*}}
68 \Op{\VAR{recursive}\DF{\NIL}}})}
69 Continue reading until encountering \VAR{char}. Return \retval{list}
70 of objects read.
72 \IT{(\FU*{READ-CHAR} \OP{\VAR{stream}\DF{\T}
73 \OP{\VAR{eof-err}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
74 \Op{\VAR{recursive}\DF{\NIL}}}}})}
75 Return \retval{next character} from \VAR{stream}.
77 \IT{(\FU*{READ-CHAR-NO-HANG}
78 \OP{\VAR{stream}\DF{\kwd{*standard-input*}}
79 \OP{\VAR{eof-error}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
80 \Op{\VAR{recursive}\DF{\NIL}}}}})}
81 \retval{Next character} from \VAR{stream} or \retval{\NIL} if none
82 is available.
84 \IT{(\FU*{PEEK-CHAR}
85 \OP{\VAR{mode}\DF{\NIL}\OP{\VAR{stream}\DF{\kwd{*standard-input*}}
86 \OP{\VAR{eof-error}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
87 \Op{\VAR{recursive}\DF{\NIL}}}}}})}
88 Next, or, if \VAR{mode} is \T, next non-whitespace
89 \retval{character} from stream without removing it there.
91 \IT{(\FU*{UNREAD-CHAR} \VAR{character}
92 \Op{\VAR{stream}\DF{\kwd{*standard-input*}}})}
93 Put last read \VAR{character} back into \VAR{stream}, return
94 \retval{\NIL}.
96 \IT{(\FU*{READ-BYTE} \VAR{stream} \OP{\VAR{eof-err}\DF{\T}
97 \Op{\VAR{eof-val}\DF{\NIL}}})}
98 Return \retval{next byte} from binary \VAR{stream}.
100 \IT{(\FU*{READ-LINE} \OP{\VAR{stream}\DF{\T}
101 \OP{\VAR{eof-err}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
102 \Op{\VAR{recursive}\DF{\NIL}}}}})}
103 Return a \retval{line of text} from \VAR{stream}. Secondary value is
104 \retval{\T} if line was ended by end of file.
106 \IT{(\FU*{READ-SEQUENCE} \VAR{sequence} \VAR{stream}
107 \OP{\kwd{:start} \VAR{start}\DF{0}}\Op{\kwd{:end}
108 \VAR{end}\DF{\NIL}})}
109 Replace elements of \VAR{sequence} between \VAR{start} and \VAR{end}
110 with \VAR{stream}. Return index of \VAR{sequence}'s unmodified
111 element.
113 \IT{(\FU*{READTABLE-CASE} \VAR{readtable})}
114 \retval{Case sensitivity attribute} of \VAR{readtable}. \kwd{setf}able.
116 \IT{(\FU*{COPY-READTABLE} \VAR{from-readtable}\DF{\kwd{*readtable*}}
117 \VAR{to}\DF{\NIL})}
118 Return \retval{Copy of \VAR{from-readtable}}.
120 \IT{(\FU*{SET-SYNTAX-FROM-CHAR} \VAR{to-char} \VAR{from-char}
121 \OP{\VAR{to-readtable}\DF{\kwd{*readtable*}}
122 \Op{\VAR{from-readtable}\DF{standard readtable}}})}
123 Copy syntax of \VAR{from-char} to \VAR{to-readtable}. Return \retval{\T}.
125 \IT{\V*{*readtable*}}
126 Current readtable.
128 \IT{\V*{*read-base*}\DF{10}}
129 Radix for reading \kwd{integer}s and \kwd{ratio}s.
131 \IT{\V*{*read-default-float-format*}\DF{\kwd{single-float}}}
132 Floating point format to use when not indicated in the number read.
134 \IT{(\FU*{SET-MACRO-CHARACTER} \VAR{char} \VAR{function}
135 \OP{\VAR{non-term-p}\DF{\NIL}
136 \Op{\VAR{rt}\DF{\kwd{*readtable*}}}})}
137 Make \VAR{char} a macro character associated with
138 \VAR{function}. Return \retval{\T}.
140 \IT{(\FU*{GET-MACRO-CHARACTER} \VAR{char}
141 \Op{\VAR{rt}\DF{\kwd{*readtable*}}})}
142 \retval{Reader macro function} associated with \VAR{char}, and
143 \retvalii{\T} if \VAR{char} is a non-terminating macro character.
145 \IT{(\FU*{MAKE-DISPATCH-MACRO-CHARACTER} \VAR{char}
146 \OP{\VAR{non-term-p}\DF{\NIL}
147 \Op{\VAR{rt}\DF{\kwd{*readtable*}}}})}
148 Make \VAR{char} a dispatching macro character. Return \retval{\T}.
150 \IT{(\FU*{SET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char} \VAR{function}
151 \Op{\VAR{rt}\DF{\kwd{*readtable*}}})}
152 Make \VAR{function} a dispatch function of \VAR{char} followed by
153 \VAR{sub-char}. Return \retval{\T}.
155 \IT{(\FU*{GET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char}
156 \Op{\VAR{rt}\DF{\kwd{*readtable*}}})}
157 \VAR{Dispatch function} associated with \VAR{char} followed by \VAR{sub-char}.
159 \end{LIST}
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 \subsection{Macro Characters}
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 \begin{LIST}{1cm}
167 \IT{\KWD*{;}\OPn{\VAR{comment}}}
168 Rest of line is a comment.
170 \IT{\KWD{\#\boldmath$|$}\OPn{\VAR{comment}}\KWD{\boldmath$|$\#}}
171 Comment.
173 \IT{\KWD*{(}}
174 Initiate reading of a list.
176 \IT{\KWD{"}}\index{""}
177 Begin and end of a string.
179 \IT{\KWD*{'}\VAR{foo}} Quote \VAR{foo}.
181 \IT{\KWD*{`}\VAR{foo} \KWD*{,}\VAR{bar} \KWD*{,@}\VAR{baz}
182 \KWD*{,.}\VAR{quux} \VAR{bing}}
183 Quote \VAR{foo} and \VAR{bing}; but neither \VAR{bar}, nor the lists
184 \VAR{baz} and \VAR{quux} which are spliced into their
185 elements. \VAR{quux} is possibly modified in the process.
187 \IT{\KWD{\#\boldmath{$\backslash$}}\VAR{c}}
188 \index{\#@\#$\backslash$}%
189 Character \VAR{c}.
191 \IT{\KWD*{\#b}, \KWD*{\#o}, \KWD*{\#x}, \KWD{\#}\VAR{n}\KWD{R}}
192 \index{\#R}%
193 Binary, octal, or hexadecimal number, or number of base \VAR{n}.
195 \IT{\KWD*{\#C(}\VAR{a b}\kwd{)}} Complex number \VAR{a}$+$\VAR{b}i.
197 \IT{\KWD*{\#'}\VAR{foo}}
198 Return \retval{function named \VAR{foo}}.
200 \IT{\KWD{\#}\VAR{n}\KWD{A}\OPn{\VAR{foo}}}
201 \index{\#A}%
202 \VAR{n}-dimensional array
204 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{(}\OPn{\VAR{foo}}\kwd{)}}
205 \index{\#(}%
206 Vector of some, or \VAR{n},
207 \VAR{foo}s filled with last \VAR{foo} if necessary.
209 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{*}\OPn{\VAR{b}}}
210 \index{\#*}%
211 Bit vector of some, or \VAR{n},
212 \VAR{b}s filled with last \VAR{b} if necessary.
214 \IT{\KWD*{\#S(}\VAR{type} \Goos{\VAR{slot} \VAR{value}}\kwd{)}}
215 Structure of \VAR{type}.
217 \IT{\KWD*{\#:}\VAR{foo}}
218 Uninterned Symbol \VAR{foo}.
220 \IT{\KWD*{\#.}\VAR{form}}
221 Read-time value of \VAR{form}.
223 \IT{\V*{*read-eval*}\DF{\T}}
224 If \NIL, a \kwd{reader-error} is signalled by \kwd{\#.}.
226 \IT{\KWD{\#}\VAR{label}\kwd{=} \VAR{foo}}
227 \index{\#=}%
228 Give value of \VAR{foo} a \VAR{label}.
230 \IT{\KWD{\#}\VAR{label}\kwd{\#}}
231 \index{\#\#}%
232 \retval{Object labelled \VAR{label}}.
234 \IT{\KWD*{\#P}\VAR{foo}}
235 Value of \retval{(\kwd{parse-namestring '}\VAR{foo})}.
237 \IT{\KWD{\#\boldmath$<$}}
238 \index{\#<@\#$<$}%
239 Have the reader signal an error.
241 \IT{\KWD*{\#+}\VAR{test} \VAR{form}}
242 Means \VAR{form} if \VAR{test} returns \T, means whitespace
243 otherwise.
245 \IT{\KWD*{\#--}\VAR{test} \VAR{form}}
246 Means \VAR{form} if \VAR{test} returns \NIL, means whitespace
247 otherwise.
249 \IT{\V*{*read-suppress*}\DF{\NIL}}
250 Used by \kwd{\#+} and \kwd{\#--}.
252 \end{LIST}
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 \subsection{Printer}
257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 \begin{LIST}{1cm}
262 \IT{(\xorGOO{\FU*{PRIN1}\\
263 \FU*{PRINT}\\
264 \FU*{PPRINT}\\
265 \FU*{PRINC}}{\}}
266 \VAR{foo} \Op{\VAR{stream}\DF{\T}})}
267 Print \retval{\VAR{foo}} to \VAR{stream} \FU{read}ably,
268 \FU{read}ably after a newline and followed by a space,
269 \FU{read}ably after a newline, or human-readably without any extra
270 characters, resp.
272 \IT{\arrGOO{(\FU*{PRIN1-TO-STRING} \VAR{ foo})\\
273 (\FU*{PRINC-TO-STRING} \VAR{ foo})}{\}}}
274 Print \VAR{foo} to \retval{\VAR{string}} \FU{read}ably or
275 human-readably, resp.
277 \IT{(\FU*{PRINT-OBJECT} \VAR{object} \VAR{stream})}
278 Print \retval{\VAR{object}} to \VAR{stream}.
280 \IT{(\FU*{PRINT-UNREADABLE-OBJECT} (\VAR{foo} \VAR{stream}
281 \Op{\kwd{:type} \VAR{bool}} \Op{\kwd{:identity} \VAR{bool}})
282 \OPn{form})}
283 Print \VAR{foo} enclosed in \kwd{\#\boldmath$<$} and
284 \kwd{\boldmath$>$}. Return \retval{\NIL}.
286 \IT{(\FU*{TERPRI} \Op{\VAR{stream}\DF{\T}})}
287 Output a newline to \VAR{stream}. Return \retval{\NIL}.
289 \IT{(\FU*{FRESH-LINE}) \Op{\VAR{stream}\DF{\T}}}
290 Output a newline to \VAR{stream} and return \retval{\T} unless \VAR{stream}
291 is already at the start of a line.
293 \IT{(\FU*{WRITE-CHAR} \VAR{char} \Op{\VAR{stream}\DF{\T}}))}
294 Output \retval{\VAR{char}} to \VAR{stream}.
296 \IT{(\xorGOO{\FU*{WRITE-STRING}\\\FU*{WRITE-LINE}}{\}} \VAR{string}
297 \VAR{stream}
298 \orGOO{\kwd{:start} \VAR{ start}\DF{0}\\\kwd{:end} \VAR{
299 end}\DF{\NIL}}{\}})}
300 Write \retval{part of \VAR{string} between \VAR{start} and
301 \VAR{end}} to \VAR{stream}, without/with a trailing newline,
302 resp.
304 \IT{(\FU*{WRITE-BYTE} \VAR{byte} \VAR{stream})} Write one \retval{\VAR{byte}} to \VAR{stream}.
306 \IT{(\FU*{WRITE-SEQUENCE} \VAR{sequence}
307 \VAR{stream}\orGOO{\kwd{:start}\VAR{ start}\DF{0}\\
308 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
309 Write elements of \retval{\VAR{sequence}} to \VAR{stream}.
311 \IT{(\xorGOO{\FU*{WRITE}\\
312 \FU*{WRITE-TO-STRING}}{\}}\VAR{foo}\orGOO{%
313 \kwd{:array} \VAR{ bool}\\
314 \kwd{:base} \VAR{ radix}\\
315 \kwd{:case} \xorGOO{\kwd{:upcase}\\
316 \kwd{:downcase}\\
317 \kwd{:capitalize}}{.}\\
318 \kwd{:circle} \VAR{ bool}\\
319 \kwd{:escape} \VAR{ bool}\\
320 \kwd{:gensym} \VAR{ bool}\\
321 \kwd{:length} \VAR{ int}\\
322 \kwd{:level} \VAR{ int}\\
323 \kwd{:lines} \VAR{ int}\\
324 \kwd{:miser-width} \VAR{ int}\\
325 \kwd{:pprint-dispatch} \VAR{ d-tbl}\\
326 \kwd{:pretty} \VAR{ bool}\\
327 \kwd{:radix} \VAR{ bool}\\
328 \kwd{:readably} \VAR{ bool}\\
329 \kwd{:right-margin} \VAR{ int}\\
330 \kwd{:stream} \VAR{ stream}\DF{\T}%
331 }{\}})}
332 Print and return \retval{\VAR{foo}}, or print into
333 \retval{string}, resp., after dynamically setting printer variables
334 corresponding to keyword parameters (\kwd{:}\VAR{bar} becoming
335 \kwd{*print-}\VAR{bar}\kwd{*}). (\kwd{:stream} keyword for \FU{write} only.)
337 \IT{(\FU*{PPRINT-NEWLINE}\xorGOO{%
338 \kwd{:linear}\\
339 \kwd{:fill}\\
340 \kwd{:miser}\\
341 \kwd{:mandatory}}{\}}
342 \OP{\VAR{stream}\DF{\kwd{*standard-output*}}})}
343 Print a conditional newline. Return \retval{\NIL}.
345 \IT{(\xorGOO{\FU*{PPRINT-FILL}\\
346 \FU*{PPRINT-LINEAR}}{\}}%
347 \VAR{stream} \VAR{foo} \OP{\VAR{parenthesis}\DF{\T} \Op{\VAR{noop}}})}
348 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print as
349 many elements per line as possible; or print either all elements on
350 one line or each on its own line. Return \retval{\NIL}.
352 \IT{(\FU*{PPRINT-TABULAR} \VAR{stream} \VAR{foo}
353 \OP{\VAR{parenthesis}\DF{\T} \Op{\VAR{noop}
354 \Op{\VAR{n}\DF{16}}}})}
355 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print
356 elements in a table with column width \VAR{n} ems. Return \retval{\NIL}.
358 \IT{(\SF*{PPRINT-LOGICAL-BLOCK} (\VAR{stream} \VAR{list}
359 \orGOO{\xorGOO{\kwd{:prefix} \VAR{ prefix}\\
360 \kwd{:per-line-prefix} \VAR{ per-line-prefix}}{\}}\\
361 \kwd{:suffix} \VAR{ suffix}\DF{\LIT{""}}}{\}})
362 \OPn{(\kwd{declare} \OPn{\VAR{decl}})} \OPn{\VAR{form}})}
363 Evaluate \VAR{form}s, which should print \VAR{list}, with
364 \VAR{stream} locally bound to a pretty
365 printing stream which outputs to the original \VAR{stream}.
367 \begin{LIST}{.5cm}
369 \IT{(\SF*{PPRINT-POP})}
370 Take \retval{next element} off \VAR{list}. If there is no remaining
371 list in \VAR{list}, or \V{*print-length*} or \V{*print-circle*} indicate
372 printing should end, send element together with an appropriate to
373 \VAR{stream}.
375 \IT{(\FU*{PPRINT-TAB} \Goo{\kwd{:line}\XOR\kwd{:line-relative}%
376 \XOR\kwd{:section}\XOR\kwd{:section-relative}} \VAR{c}
377 \VAR{i} \Op{\VAR{stream}})}
378 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
379 as possible.
381 \IT{(\FU*{PPRINT-INDENT}\xorGOO{%
382 \kwd{:block}\\
383 \kwd{:current}}{\}} \VAR{n}
384 \OP{\VAR{stream}\DF{\kwd{*standard-output*}}})}
385 Specify indentation for innermost logical block. Return \retval{\NIL}.
387 \IT{(\kwd*{PPRINT-EXIT-IF-LIST-EXHAUSTED})}
388 If \VAR{list} is empty, terminate logical block. Return
389 \retval{\NIL} otherwise.
391 \end{LIST}
393 \IT{(\FU*{SET-PPRINT-DISPATCH} \VAR{type} \VAR{function}
394 \OP{\VAR{priority}\DF{0}
395 \Op{\VAR{table}\DF{*print-pprint-dispatch*}}})}
396 Install entry comprising \VAR{function} and \VAR{priority} as
397 \VAR{type} into \VAR{table}. Return \retval{\NIL}.
399 \IT{(\FU*{PPRINT-DISPATCH} \VAR{foo}
400 \Op{\VAR{table}\DF{\kwd{*print-pprint-dispatch*}}})}
401 Highest priority \retval{\VAR{function}} associated with type of
402 \VAR{foo}.
404 \IT{(\FU*{COPY-PPRINT-DISPATCH}
405 \Op{\VAR{table}\DF{*print-pprint-dispatch*}})}
406 Return \retval{copy of \VAR{table}}.
408 \IT{\V*{*print-pretty*}}
409 If \T, print pretty.
411 \IT{\V*{*print-case*}\DF{\kwd{:upcase}}}
412 Print symbol names all uppercase (\kwd{:upcase}), all lowercase
413 (\kwd{:downcase}), capitalized (\kwd{:capitalize}).
415 \IT{\V*{*print-readably*}\DF{\NIL}}
416 If \T, print \FU{read}ably.
418 \IT{\V*{*print-array*}}
419 If \T, print array \FU{read}ably.
421 \IT{\V*{*print-escape*}\DF{\T}}
422 If \NIL, do not print escape characters and package prefixes.
424 \IT{\V*{*print-gensym*}\DF{\T}}
425 If \T, print \kwd{:\#} before uninterned symbols.
427 \IT{\V*{*print-radix*}\DF{\NIL}}
428 If \T, print rationals with a radix indicator.
430 \IT{\V*{*print-base*}\DF{10}}
431 Radix for printing rationals, between 2 and 36.
433 \IT{\V*{*print-circle*}\DF{\NIL}}
434 If \T, avoid indefinite recursion while printing circular
435 structure.
437 \IT{\V*{*print-lines*}\DF{\NIL}}
438 Number of lines to pretty-print.
440 \IT{\V*{*print-length*}\DF{\NIL}}
441 If integer, restrict printing of objects to that number per level.
443 \IT{\V*{*print-level*}\DF{\NIL}}
444 If integer, restrict printing of nested object to that depth.
446 \IT{\V*{*print-right-margin*}\DF{\NIL}}
447 Right margin width in ems while pretty-printing.
449 \IT{\V*{*print-miser-width*}}
450 Width below which a compact pretty-printing style is used.
452 \IT{\V*{*print-pprint-dispatch*}}
453 Current pretty print dispatch table.
455 \end{LIST}
459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460 \subsection{Format}
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
462 \label{section:Format}
464 \begin{LIST}{1cm}
466 \IT{(\SF*{FORMATTER} \VAR{control})}
467 Return \retval{function} applying \FU{format} to
468 \kwd{*standard-output*}, \VAR{control}, and a \kwd{\&rest} argument
469 returning \NIL\ or any excess arguments.
471 \IT{(\FU*{FORMAT} \Goo{\T\XOR\NIL\XOR\VAR{out-string}\XOR\VAR{out-stream}}
472 \VAR{control} \OPn{arg})}
473 Output string \VAR{control} which may
474 contain \kwd{\TLD}-directives possibly taking some
475 \VAR{args}.
476 Output to \VAR{out-string}, \VAR{out-stream}, or, if first
477 argument is \T, to \V{*standard-output*}. Return \retval{\NIL}. If
478 first argument is \NIL, return \retval{formatted output}.
480 \begin{LIST}{.5cm}
482 \IT{\KWD{\TLD}\Op{\VAR{min-col}\DF{\LIT{0}}\Op{\KWD{,}\VAR{col-inc}\DF{\LIT{1}}
483 \Op{\KWD{,}\VAR{min-pad}\DF{\LIT{0}}
484 \Op{\KWD{,}\VAR{pad-char}\DF{\LIT{\#$\backslash$Space}}}}}}
485 \KWD{\Op{:}\Op{@}\Goo{A\XOR S}}}
486 Print argument of any type for consumption by humans/by the
487 reader, resp. With \kwd{@}, add \VAR{pad-char}s on the left
488 rather than on the right. With \kwd{:} print \NIL\ as \LIT{()} rather
489 than \LIT{nil}.
491 \IT{\KWD{\TLD}\Op{\VAR{radix}\DF{\LIT{10}} \Op{\KWD{,}\VAR{width}
492 \Op{\KWD{,}\VAR{pad-char}\DF{\KWD{\#$\backslash$Space}}
493 \Op{\KWD{,}\VAR{comma-char}\DF{\KWD{,}}
494 \Op{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}}} \KWD{\Op{:}\Op{@}R}}
495 Print argument as number, with \KWD{:}, group digits
496 \VAR{comma-interval} each, with \kwd{@}, always prepend a sign.
498 \IT{\KWD{\TLD}\Op{\VAR{width}
499 \Op{\KWD{,}\VAR{pad-char}\DF{\KWD{\#$\backslash$Space}}
500 \Op{\KWD{,}\VAR{comma-char}\DF{\KWD{,}}
501 \Op{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}} \KWD{\Op{:}\Op{@}\Goo{D\XOR
502 B\XOR O\XOR X}}}
503 Print integer argument as number (decimal, binary, octal, or
504 hexadecimal, resp.) with \kwd{:} group digits
505 \VAR{comma-interval} each, with \kwd{@} always prepend a sign.
507 \IT{\KWD{\TLD}\Op{\VAR{width}\Op{\KWD{,}\VAR{dec-digits} \Op{\KWD{,}\VAR{shift}\DF{\LIT{0}}
508 \Op{\KWD{,}\VAR{overflow-char}
509 \Op{\KWD{,}\VAR{pad-char}\DF{\LIT{\#$\backslash$Space}}}}}}} \KWD{\Op{@}F}}
510 Print argument as floating-point number. With \kwd{@}, always prepend a sign.
512 \IT{\KWD{\TLD}\Op{\VAR{width}\Op{\KWD{,}\VAR{int-digits} \Op{\KWD{,}\VAR{exp-digits}
513 \Op{\KWD{,}\VAR{scale-factor}\DF{\LIT{1}} \Op{\KWD{,}\VAR{overflow-char}
514 \Op{\KWD{,}\VAR{pad-char}\DF{\LIT{\#$\backslash$Space}}
515 \Op{\KWD{,}\VAR{exp-char}}}}}}}} \KWD{\Op{@}\Goo{E\XOR G}}}
516 Print argument as floating-point number with \VAR{int-digits}
517 before decimal point and \VAR{exp-digits} in the
518 exponent. With \KWD{\TLD G}, chose either \KWD{\TLD E} or \KWD{\TLD F}. With \KWD{@}, always prepend a sign.
520 \IT{\Goo{\KWD{\TLD R}\XOR\KWD{\TLD :R}\XOR\KWD{\TLD @R}\XOR\KWD{\TLD @:R}}}
521 Take argument as number and print it as English cardinal number,
522 as English ordinal number, as Roman numeral, or as old Roman
523 numeral, resp.
525 \IT{\Goo{\KWD{\TLD C}\XOR\KWD{\TLD :C}\XOR\KWD{\TLD @:C}}}
526 Print, spell out, or tell how to type, resp., argument as
527 (possibly non-printing) character.
529 \IT{\Goo{%
530 \KWD{\TLD(}\VAR{text}\KWD{\TLD)}\XOR
531 \KWD{\TLD:(}\VAR{text}\KWD{\TLD)}\XOR
532 \KWD{\TLD @(}\VAR{text}\KWD{\TLD)}\XOR
533 \KWD{\TLD:@(}\VAR{text}\KWD{\TLD)}}}
534 Convert to lowercase, convert first letter of each word to
535 uppercase, capitalize first word and convert
536 the rest to lowercase, or convert to uppercase, resp.
538 \IT{\Goo{\KWD{\TLD P}\XOR\KWD{\TLD:P}
539 \XOR\KWD{\TLD @P}\XOR\KWD{\TLD:@P}}}
540 If argument \kwd{eql} 1 print nothing, otherwise print \LIT{s};
541 do the same after backing up 1 argument; if argument \kwd{eql} 1
542 print \LIT{y}, otherwise print \LIT{ies}, resp.
544 \IT{\Goo{\KWD{\TLD\%}\XOR\KWD{\TLD}\VAR{n}\KWD{\%}}}
545 Print one or \VAR{n} newline(s).
547 \IT{\Goo{\KWD{\TLD\&}\XOR\KWD{\TLD}\VAR{n}\KWD{\&}}}
548 Print one or \VAR{n} newline(s) unless output stream is at the
549 beginning of a line.
551 \IT{\Goo{\KWD{\TLD}\_\XOR\KWD{\TLD:}\_\XOR\KWD{\TLD@}\_\XOR\KWD{\TLD}:@\_}}
552 Print newline like \kwd{pprint-newline} with argument
553 \kwd{:linear}, \kwd{:fill}, \kwd{:miser}, or \kwd{:mandatory}, resp.
555 \IT{\KWD{\TLD}\Op{\KWD{@}}}
556 (Tilde-newline) Ignore newline and following
557 whitespace. With \kwd{@}, ignore only newline.
559 \IT{\Goo{\KWD{\TLD\boldmath$|$}\XOR\KWD{\TLD}\VAR{n}\KWD{\boldmath$|$}}}
560 Print one or \VAR{n} page separator(s).
562 \IT{\Goo{\KWD{\TLD\TLD}\XOR\KWD{\TLD}\VAR{n}\KWD{\TLD}}}
563 Print one or \VAR{n} tilde(s).
565 \IT{\KWD{\TLD}\Op{\VAR{min-col}\DF{\LIT{0}}
566 \Op{\KWD{,}\VAR{col-inc}\DF{\LIT{1}}
567 \Op{\KWD{,}\VAR{min-pad}\DF{\LIT{0}}
568 \Op{\KWD{,}\VAR{pad-char}\DF{\LIT{\#$\backslash$Space}}}}}}
569 \KWD{\Op{:}\Op{@}\boldmath{$<$}}
570 \Op{\VAR{text}\KWD{\TLD}\VAR{a},\VAR{b}\kwd{:;}}
571 \Goos{\VAR{text}\KWD{\TLD;}} \KWD{\TLD\boldmath{$>$}}}
572 Justify text produced by \VAR{text}s in a field of at least
573 \VAR{min-col} columns.
575 \IT{\KWD{\TLD}\Op{\VAR{c}\Op{\KWD{,}\VAR{i}}}\Op{\KWD{:}}\Op{\KWD{@}}\KWD{T}}
576 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
577 as possible.
579 \IT{\Goo{\KWD{\TLD}\Op{\VAR{n}\DF{\LIT{0}}}\kwd{I}\XOR\KWD{\TLD}\Op{\VAR{n}\DF{\LIT{0}}}\kwd{:I}}}
580 Same as (\kwd{pprint-indent} \kwd{:block} \VAR{n}) or
581 (\kwd{pprint-indent} \kwd{:current} \VAR{n}), resp.
583 \IT{\KWD{\TLD}\Op{\VAR{n}}\DF{\LIT{0}}\Op{\KWD{:}}\Op{\KWD{@}}\KWD{*}}
584 Jump \VAR{n} arguments forward, or, with \kwd{:}, backward. With
585 \kwd{@}, jump to argument \VAR{n}.
587 \IT{\KWD{\TLD}\Op{\VAR{limit}}\Op{\KWD{{:}}\Op{\kwd{@}}}%
588 \KWD{\boldmath{$\{$}}\VAR{text}\KWD{\TLD\boldmath{$\}$}}}
589 \VAR{text} is used repeatedly, up to \VAR{limit}, as control
590 string for every element of argument, which should be a list. With
591 \kwd{@}, take all remaining arguments. \kwd{:}, argument should be
592 a list of sublists. At each iteration step the elements of a
593 sublist can be used by \VAR{str}.
595 \IT{\KWD{\TLD\^{}}}
596 Leave immediately \kwd{\TLD\boldmath{$<$}} or \kwd{\TLD\boldmath{$\{$}}.
598 \IT{\KWD{\TLD}\Op{\VAR{i}}\Op{\KWD{:}}\Op{\KWD{@}}\KWD{[}\Goos{\VAR{text}\KWD{\TLD;}}\KWD{\TLD]}}
599 The \VAR{text}s are clauses the argumenth (or the \VAR{i}th if given) of wich is chosen. With
600 \kwd{:}, the boolean argument takes first \VAR{str} for \NIL\ and
601 second for \T.
603 \IT{\KWD{\TLD\Op{:}\Op{@}?}}
604 Process two arguments as format string and argument list. With
605 \kwd{@}, take one argument as format string and use then the
606 original argument list
608 \IT{\KWD{\TLD\Op{:}\Op{@}/}\VAR{foo}\KWD{/}}
609 Call function \VAR{foo} with arguments stream, format-argument,
610 bool-colon, and bool-at for printing format-argument.
612 \IT{\KWD{\TLD\Op{:}\Op{@}W}}
613 Print obeying every printer control variable. \kwd{:} makes it
614 pretty-print. With \kwd{@}, print without limits on length or depth.
616 \end{LIST}
618 \end{LIST}
621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622 \subsection{Streams}
623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625 \begin{LIST}{1cm}
627 \IT{(\FU*{OPEN} \VAR{path}
628 \orGOO{\kwd{:direction} \xorGOO{\kwd{:input}\\\kwd{:output}\\\kwd{:io}\\\kwd{:closed}}{.}\\
629 \kwd{:element-type} \VAR{ type}\\
630 \kwd{:if-exists}
631 \xorGOO{\kwd{:new-version}\\\kwd{:rename}\\
632 \kwd{:rename-and-delete}\\\kwd{:overwrite}\\
633 \kwd{:append}\\\kwd{:supersede}\\\NIL}{.}\\
634 \kwd{:if-does-not exist} \xorGOO{\kwd{:error}\\
635 \kwd{:create}\\\NIL}{.}}{\}})}
636 Open \retval{stream to \VAR{path}}.
638 \IT{(\FU*{CLOSE} \VAR{stream} \Op{\kwd{:abort} \VAR{bool}\DF{\NIL}})}
639 Close \VAR{stream}. If \kwd{:abort} is \T, delete associated file.
641 \IT{(\FU*{MAKE-STRING-OUTPUT-STREAM} \Op{\kwd{:element-type}
642 \VAR{type}\DF{\kwd{character}}})}
643 Return a \retval{stream} accepting characters.
645 \IT{(\FU*{MAKE-CONCATENATED-STREAM} \OPn{\VAR{stream}})}
646 Return \retval{concatenated stream}.
648 \IT{(\FU*{CONCATENATED-STREAM-STREAMS} \VAR{concatenated-stream})}
649 Return \retval{list of streams} \VAR{concatenated-stream} still
650 has to read from.
652 \IT{(\FU*{MAKE-BROADCAST-STREAM} \OPn{\VAR{stream}})}
653 Return \retval{broadcast stream}.
655 \IT{(\FU*{BROADCAST-STREAM-STREAMS} \VAR{broadcast-stream})}
656 Return \retval{list of streams} \VAR{broadcast-stream} is
657 broadcasting to.
659 \IT{(\FU*{MAKE-ECHO-STREAM} \VAR{input-stream} \VAR{output-stream})}
660 Place \retval{echo stream} between \VAR{input-stream} and
661 \VAR{output-stream}.
663 \IT{\arrGOO{(\FU*{ECHO-STREAM-INPUT-STREAM}\VAR{ echo-stream})\\
664 (\FU*{ECHO-STREAM-OUTPUT-STREAM}\VAR{ echo-stream})}{\}}}
665 Return \retval{stream} \VAR{echo-stream} receives from or sends
666 to, resp.
668 \IT{(\FU*{MAKE-STRING-INPUT-STREAM} \VAR{string}
669 \orGOO{\kwd{:start}\VAR{ start}\\
670 \kwd{:end} \VAR{ end}}{\}})}
671 Return \retval{stream} supplying the characters from \VAR{string}.
673 \IT{(\FU*{MAKE-SYNONYM-STREAM} \VAR{symbol})}
674 Return \retval{synonym stream}.
676 \IT{(\FU*{SYNONYM-STREAM-SYMBOL} \VAR{synonym-stream})}
677 Return \retval{symbol} of \VAR{synonym-stream}.
679 \IT{(\FU*{MAKE-TWO-WAY-STREAM} \VAR{input-stream}
680 \VAR{output-stream})} Return \retval{two-way stream}.
682 \IT{\arrGOO{(\FU*{TWO-WAY-STREAM-INPUT-STREAM} \VAR{
683 two-way-stream})\\
684 (\FU*{TWO-WAY-STREAM-OUTPUT-STREAM} \VAR{ two-way-stream})}{\}}}
685 Return \retval{stream} \VAR{two-way-stream} receives from or sends
686 to, resp.
688 \IT{(\FU*{LISTEN} \Op{\VAR{stream}\DF{\kwd{*standard-input*}}})}
689 \retval{\T} if there is a character in input \VAR{stream}.
691 \IT{(\FU*{GET-OUTPUT-STREAM-STRING} \VAR{stream})}
692 Clear and return as a \retval{string} characters on \VAR{stream}.
694 \IT{(\FU*{CLEAR-INPUT}
695 \Op{\VAR{stream}\DF{\kwd{*standard-input*}}})}
696 Clear input from \VAR{stream}, return \retval{\NIL}.
698 \IT{(\xorGOO{\FU*{CLEAR-OUTPUT}\\
699 \FU*{FORCE-OUTPUT}\\
700 \FU*{FINISH-OUTPUT}}{\}}%
701 \Op{\VAR{stream}\DF{\kwd{standard-output}}})}
702 End output to \VAR{stream} and return \retval{\NIL} immediately,
703 after initiating flushing of buffers, or after flushing of buffers,
704 resp.
706 \IT{(\SF*{WITH-OPEN-STREAM} (\VAR{foo} \VAR{stream})
707 \OPn{(\kwd{declare} \OPn{\VAR{decl}})} \OPn{\VAR{form}})}
708 Evaluate \VAR{form}s with \VAR{foo} locally bound to
709 \VAR{stream}. Return \retval{value of \VAR{form}s}.
711 \IT{(\SF*{WITH-INPUT-FROM-STRING} (\VAR{foo} \VAR{string}
712 \orGOO{\kwd{:index} \VAR{ index}\\\kwd{:start} \VAR{
713 start}\\\kwd{:end} \VAR{ end}}{\}}) \OPn{(\kwd{declare}
714 \OPn{\VAR{decl}})} \OPn{\VAR{form}})}
715 Evaluate \VAR{form}s with \VAR{foo} locally bound to input stream
716 from \VAR{string}. \VAR{index} contains the reading position in
717 \VAR{string} after leaving. Return \retval{value of \VAR{form}s}.
719 \IT{(\SF*{WITH-OUTPUT-TO-STRING}(\VAR{foo}
720 \Op{\VAR{string}}\DF{\NIL} \Op{\kwd{:element-type}
721 \VAR{type}\DF{\kwd{character}}}) \OPn{(\kwd{declare}
722 \OPn{\VAR{decl}})} \OPn{\VAR{form}})}
723 Evaluate \VAR{form}s with \VAR{foo} locally bound to output
724 stream. Append output to \VAR{string} and return \retval{value of
725 \VAR{foo}} if \VAR{string} is given. Return \retval{string
726 containing output} otherwise.
728 \IT{(\FU*{STREAM-EXTERNAL-FORMAT} \VAR{stream})}
729 \retval{External file format designator}.
731 \IT{\V*{*terminal-io*}}
732 Bidirectional stream to user terminal.
734 \IT{\arrGOO{\V*{*standard-input*}\\
735 \V*{*standard-output*}\\
736 \V*{*error-output*}}{\}}}
737 Standard input stream, standard output stream,
738 or standard error output stream, resp.
740 \IT{\arrGOO{\V*{*debug-io*}\\
741 \V*{*query-io*}}{\}}}
742 Streams for debugging and user interaction.
744 \end{LIST}
747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
748 \subsection{Files}
749 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
751 \begin{LIST}{1cm}
753 \IT{(\FU*{MAKE-PATHNAME}
754 \orGOO{\kwd{:host} \VAR{ host}\\
755 \kwd{:device} \VAR{ dev}\\
756 \kwd{:directory} \VAR{ dir}\\
757 \kwd{:name} \VAR{ name}\\
758 \kwd{:type} \VAR{ type}\\
759 \kwd{:version} \VAR{ ver}\\
760 \kwd{:defaults} \VAR{ path}\\
761 \kwd{:case \Goo{\kwd{:local}\XOR\kwd{:common}}\DF{\kwd{:local}}}}{\}})}
762 Construct \retval{pathname}.
764 \IT{(\FU*{MERGE-PATHNAMES} \VAR{pathname}
765 \Op{\VAR{default-pathname}\DF{\V{*default-pathname-defaults*}}}\XOR\Op{\VAR{version}\DF{\kwd{:newest}}})}
766 Return \retval{\VAR{pathname}} after filling in missing parts from defaults.
768 \IT{\V*{*default-pathname-defaults*}}
769 Pathname to use if one is needed but none supplied.
771 \IT{(\FU*{PATHNAME} \VAR{path})}
772 \retval{Pathname} of \VAR{path}.
774 \IT{(\FU*{ENOUGH-NAMESTRING} \VAR{path}
775 \Op{\VAR{root-path}\DF{\V{*default-pathname-defaults*}}})}
776 Return \retval{minimal path string} to sufficiently describe path relative to \VAR{root-path.}
778 \IT{\arrGOO{(\FU*{NAMESTRING}\VAR{ path})\\
779 (\FU*{FILE-NAMESTRING}\VAR{ path})\\
780 (\FU*{DIRECTORY-NAMESTRING}\VAR{ path})\\
781 (\FU*{HOST-NAMESTRING}\VAR{ path})}{\}}}
782 Return string representing \retval{full pathname}, \retval{name, type, and version},
783 \retval{directory name}, or \retval{host name}, resp., of \VAR{path}.
785 \IT{(\FU*{PARSE-NAMESTRING} \VAR{foo} \VAR{host}
786 \VAR{default-pathname}\DF{\V{*default-pathname-defaults*}}
787 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
788 \kwd{:end} \VAR{ end}\DF{\NIL}\\
789 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}})}
790 Return \retval{pathname} and \retval{position} converted from
791 string, pathname, or stream \VAR{foo}.
793 \IT{(\xorGOO{\FU*{PATHNAME-HOST}\\
794 \FU*{PATHNAME-DEVICE}\\
795 \FU*{PATHNAME-DIRECTORY}\\
796 \FU*{PATHNAME-NAME}\\
797 \FU*{PATHNAME-TYPE}\\
798 \FU*{PATHNAME-VERSION}}{\}}
799 \VAR{path}
800 \Op{\xorGOO{\kwd{:local}\\\kwd{:common}}{\}}\DF{\kwd{:local}}})}
801 Return \retval{pathname component}.
803 \IT{(\FU*{LOGICAL-PATHNAME} \VAR{path})}
804 \retval{Logical name} of \VAR{path}.
806 \IT{(\FU*{TRANSLATE-PATHNAME} \VAR{path-a} \VAR{path-b}
807 \VAR{path-c})}
808 Translate \VAR{path-a} from wildcard \VAR{path-b} into wildcard
809 \VAR{path-c}. Return \retval{new path}.
811 \IT{(\FU*{LOGICAL-PATHNAME-TRANSLATIONS} \VAR{host})}
812 \retval{\VAR{host}'s list of translations}.
814 \IT{(\FU*{LOAD-LOGICAL-PATHNAME-TRANSLATIONS} \VAR{host})}
815 Load \VAR{host}'s translations. Return \retval{\NIL} if already
816 loded, return \retval{\T} if successful.
818 \IT{(\FU*{TRANSLATE-LOGICAL-PATHNAME} \VAR{path})}
819 Physical \retval{pathname} of \VAR{path}.
821 \IT{(\FU*{TRUENAME} \VAR{file})}
822 \retval{Canonical name} of \VAR{file}.
824 \IT{(\FU*{PROBE-FILE} \VAR{path})}
825 Return \retval{canonical file name} or \retval{\NIL} if file does
826 not exist.
828 \IT{(\FU*{FILE-WRITE-DATE} \VAR{path})}
829 Return \retval{time} at which file was last written.
831 \IT{(\FU*{FILE-AUTHOR} \VAR{path})}
832 Return \retval{name of file owner}.
834 \IT{(\FU*{FILE-LENGTH} \VAR{stream})}
835 Return \retval{length of \VAR{stream}}.
837 \IT{(\FU*{FILE-POSITION} \VAR{stream} \Op{\VAR{position}})}
838 Return \retval{position within stream}, or set it to
839 \retval{\VAR{position}} and return \retval{\T} on success.
841 \IT{(\FU*{FILE-STRING-LENGTH} \VAR{stream} \VAR{foo})}
842 \retval{Length} \VAR{foo} would have in \VAR{stream}.
844 \IT{(\FU*{RENAME-FILE} \VAR{foo} \VAR{bar})}
845 Rename file \VAR{foo} to \VAR{bar}. Unspecified parts of path
846 \VAR{bar} default to those of \VAR{foo}. Return \retval{new
847 pathname}, \retval{old file name}, and \retval{new file name}.
849 \IT{(\FU*{DELETE-FILE} \VAR{path})}
850 Delete file \VAR{path}, return \retval{\T}.
852 \IT{(\FU*{DIRECTORY} \VAR{path})}
853 Return \retval{list of pathnames}.
855 \IT{(\FU*{ENSURE-DIRECTORIES-EXIST} \VAR{path} \Op{\kwd{:verbose}
856 \VAR{bool}})}
857 Create parts of \retval{path} if necessary. Second return value is
858 \retval{\T} if something was created.
860 \IT{(\SF*{WITH-OPEN-FILE} (\VAR{stream path}
861 \OPn{\VAR{option-form}}) \OPn{(\kwd{declare} \OPn{\VAR{decl}})}
862 \OPn{\VAR{form}})}
863 Use \FU*{OPEN} with arguments \VAR{option-form}s to temporarily
864 create \VAR{stream}, and return \retval{value of \VAR{form}s}.
866 \IT{(\FU*{USER-HOMEDIR-PATHNAME} \Op{\VAR{host}})}
867 User's \retval{home directory}.
870 \end{LIST}