Typo fixes and minor changes in several places.
[clqr.git] / clqr-input-output.tex
blobfb8ab175916027266f8dfe35099a76c7da494c78
1 % Copyright (C) 2008, 2009, 2010 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2 or any later version published by the Free Software
6 % Foundation; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Input/Output}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 \begin{LIST}{1cm}
20 \IT{\arrGOO{(\FU*{STREAMP} \VAR{ foo})\\
21 (\FU*{PATHNAMEP} \VAR{ foo})\\
22 (\FU*{READTABLEP} \VAR{ foo})}{.}}
24 \retval{\T} if \VAR{foo} is of indicated type.
27 \IT{\arrGOO{(\FU*{INPUT-STREAM-P} \VAR{ stream})\\
28 (\FU*{OUTPUT-STREAM-P} \VAR{ stream})\\
29 (\FU*{INTERACTIVE-STREAM-P} \VAR{ stream})\\
30 (\FU*{OPEN-STREAM-P} \VAR{ stream})}{.}}
32 Return \retval{\T} if \VAR{stream} is for input, for output,
33 interactive, or open, respectively.
36 \IT{(\FU*{PATHNAME-MATCH-P} \VAR{path} \VAR{wildcard})}
38 \retval{\T} if \VAR{path} matches \VAR{wildcard}.
41 \IT{(\FU*{WILD-PATHNAME-P} \VAR{path}
42 \OP{\Goo{\kwd{:host}\XOR
43 \kwd{:device}\XOR
44 \kwd{:directory}\XOR
45 \kwd{:name}\XOR
46 \kwd{:type}\XOR
47 \kwd{:version}\XOR\NIL}})}
49 Return \retval{\T} if indicated component in \VAR{path} is
50 wildcard. (\NIL\ indicates any component.)
53 \end{LIST}
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 \subsection{Reader}
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 \begin{LIST}{1cm}
62 \IT{(\xorGOO{\FU*{Y-OR-N-P}\\
63 \FU*{YES-OR-NO-P}}{\}} \Op{\VAR{control} \OPn{\VAR{arg}}})}
65 Ask user a question and return \retval{\T} or \retval{\NIL}
66 depending on their answer. See p.\ \pageref{section:Format},
67 \FU{format}, for \VAR{control} and \VAR{arg}s.
70 \IT{(\MC*{WITH-STANDARD-IO-SYNTAX} \PROGN{\VAR{form}})}
72 Evaluate \VAR{form}s with standard behaviour of reader and
73 printer. Return \retval{values of \VAR{form}s}.
76 \IT{(\xorGOO{\FU*{READ}\\
77 \FU*{READ-PRESERVING-WHITESPACE}}{\}}
78 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}} % standard-input not explicitly in standard
79 \OP{\VAR{eof-err}\DF{\T}
80 \Op{\VAR{eof-val}\DF{\NIL} \Op{\VAR{recursive}\DF{\NIL}}}}})}
82 Read printed representation of \retval{object}.
85 \IT{(\FU*{READ-FROM-STRING} \VAR{string}
86 \OP{\VAR{eof-error}\DF{\T}
87 \OP{\VAR{eof-val}\DF{\NIL}
88 \OP{\orGOO{%
89 \kwd{:start}\VAR{ start}\DF{\LIT{0}}\\
90 \kwd{:end}\VAR{ end}\DF{\NIL}\\
91 \kwd{:preserve-whitespace}\VAR{ bool}\DF{\NIL}}{\}}}}})}
93 Return \retval{object} read from string and zero-indexed \retvalii{position} of
94 next character.
97 \IT{(\FU*{READ-DELIMITED-LIST} \VAR{char}
98 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}
99 \Op{\VAR{recursive}\DF{\NIL}}})}
101 Continue reading until encountering \VAR{char}. Return \retval{list}
102 of objects read. Signal error if no \VAR{char} is found in stream.
105 \IT{(\FU*{READ-CHAR} \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}
106 \OP{\VAR{eof-err}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
107 \Op{\VAR{recursive}\DF{\NIL}}}}})}
109 Return \retval{next character} from \VAR{stream}.
112 \IT{(\FU*{READ-CHAR-NO-HANG}
113 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}
114 \OP{\VAR{eof-error}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
115 \Op{\VAR{recursive}\DF{\NIL}}}}})}
117 \retval{Next character} from \VAR{stream} or \retval{\NIL} if none
118 is available.
121 \IT{(\FU*{PEEK-CHAR}
122 \OP{\VAR{mode}\DF{\NIL} \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}
123 \OP{\VAR{eof-error}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
124 \Op{\VAR{recursive}\DF{\NIL}}}}}})}
126 Next, or if \VAR{mode} is \T, next non-whitespace
127 \retval{character}, or if \VAR{mode} is a character, \retval{next instance}
128 of it, from \VAR{stream} without removing it there.
131 \IT{(\FU*{UNREAD-CHAR} \VAR{character}
132 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}})}
134 Put last \FU{read-char}ed \VAR{character} back into \VAR{stream}; return
135 \retval{\NIL}.
138 \IT{(\FU*{READ-BYTE} \DES{\VAR{stream}} \OP{\VAR{eof-err}\DF{\T}
139 \Op{\VAR{eof-val}\DF{\NIL}}})}
141 Read \retval{next byte} from binary \VAR{stream}.
144 \IT{(\FU*{READ-LINE} \OP{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}
145 \OP{\VAR{eof-err}\DF{\T} \Op{\VAR{eof-val}\DF{\NIL}
146 \Op{\VAR{recursive}\DF{\NIL}}}}})}
148 Return a \retval{line of text} from \VAR{stream} and
149 \retvalii{\T} if line has been ended by end of file.
152 \IT{(\FU*{READ-SEQUENCE} \DES{\VAR{sequence}} \DES{\VAR{stream}}
153 \Op{\kwd{:start} \VAR{start}\DF{\LIT{0}}}\Op{\kwd{:end}
154 \VAR{end}\DF{\NIL}})}
156 Replace elements of \VAR{sequence} between \VAR{start} and \VAR{end}
157 with elements from \VAR{stream}. Return \retval{index} of
158 \VAR{sequence}'s first unmodified
159 element.
162 \IT{(\FU*{READTABLE-CASE} \VAR{readtable})\DF{\kwd{:upcase}}}
164 \retval{Case sensitivity attribute} (one of \kwd{:upcase},
165 \kwd{:downcase}, \kwd{:preserve}, \kwd{:invert}) of
166 \VAR{readtable}. \kwd{setf}able.
169 \IT{(\FU*{COPY-READTABLE} \OP{\VAR{from-readtable}\DF{\V{\A readtable\A}}
170 \Op{\DES{\VAR{to-readtable}}\DF{\NIL}}})}
172 Return \retval{copy of \VAR{from-readtable}}.
175 \IT{(\FU*{SET-SYNTAX-FROM-CHAR} \VAR{to-char} \VAR{from-char}
176 \OP{\DES{\VAR{to-readtable}}\DF{\V{\A readtable\A}}
177 \Op{\VAR{from-readtable}\DF{standard readtable}}})}
179 Copy syntax of \VAR{from-char} to \VAR{to-readtable}. Return \retval{\T}.
182 \IT{\V{\A readtable\A}}
183 {\index{*READTABLE*@\A READTABLE\A}
184 Current readtable.
187 \IT{\V{\A read-base\A}\DF{\LIT{10}}}
188 {\index{*READ-BASE*@\A READ-BASE\A}
189 Radix for reading \kwd{integer}s and \kwd{ratio}s.
192 \IT{\V{\A read-default-float-format\A}\DF{\kwd{single-float}}}
193 {\index{*READ-DEFAULT-FLOAT-FORMAT*@\A READ-DEFAULT-FLOAT-FORMAT\A}
194 Floating point format to use when not indicated in the number read.
197 \IT{\V{\A read-suppress\A}\DF{\NIL}}
198 {\index{*READ-SUPPRESS*@\A READ-SUPPRESS\A}
199 If \T, reader is syntactically more tolerant.
202 \IT{(\FU*{SET-MACRO-CHARACTER} \VAR{char} \VAR{function}
203 \OP{\VAR{non-term-p}\DF{\NIL}
204 \Op{\DES{\VAR{rt}}\DF{\V{\A readtable\A}}}})}
206 Make \VAR{char} a macro character associated with
207 \VAR{function}. Return \retval{\T}.
210 \IT{(\FU*{GET-MACRO-CHARACTER} \VAR{char}
211 \Op{\VAR{rt}\DF{\V{\A readtable\A}}})}
213 \retval{Reader macro function} associated with \VAR{char}, and
214 \retvalii{\T} if \VAR{char} is a non-terminating macro character.
217 \IT{(\FU*{MAKE-DISPATCH-MACRO-CHARACTER} \VAR{char}
218 \OP{\VAR{non-term-p}\DF{\NIL}
219 \Op{\VAR{rt}\DF{\V{\A readtable\A}}}})}
221 Make \VAR{char} a dispatching macro character. Return \retval{\T}.
224 \IT{(\FU*{SET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char} \VAR{function}
225 \Op{\DES{\VAR{rt}}\DF{\V{\A readtable\A}}})}
227 Make \VAR{function} a dispatch function of \VAR{char} followed by
228 \VAR{sub-char}. Return \retval{\T}.
231 \IT{(\FU*{GET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char}
232 \Op{\VAR{rt}\DF{\V{\A readtable\A}}})}
234 \retval{Dispatch function} associated with \VAR{char} followed by \VAR{sub-char}.
237 \end{LIST}
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 \subsection{Character Syntax}
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 \begin{LIST}{1cm}
245 \IT{\arrGOO{%
246 \KWD{\#\boldmath$|$ }\OPn{\VAR{multi-line-comment}}\KWD{ \boldmath$|$\#}\\
247 \KWD*{; }\OPn{\VAR{one-line-comment}}}{.}}
248 {\index{\#{$"|$} {$"|$}\#}
249 Comments. There are conventions:
251 \begin{LIST}{.5cm}
252 \IT{\KWD{;;;;} \VAR{title}\qquad\qquad}
253 {Short title for a block of code.}
255 \IT{\KWD{;;;} \VAR{intro}\qquad\qquad}
256 {Description before a block of code.}
258 \IT{\KWD{;;} \VAR{state}\qquad\qquad}
259 {State of program or of following code.}
261 \IT{\KWD{;} \VAR{explanation}}
262 {Regarding line on which it appears.}
264 \end{LIST}
266 \IT{\KWD*{(}\OPn{\VAR{foo}}\Op{ \KWD*{.} \VAR{bar}\DF{\NIL}}\KWD*{)}}
268 List of \VAR{foo}s with the terminating cdr \VAR{bar}.
271 \IT{\KWD{"}\qquad\qquad}
272 {\index{""}
273 Begin and end of a string.
276 \IT{\KWD*{'}\VAR{foo}\quad\qquad}
278 (\SO*{quote} \VAR{foo}); \VAR{foo} unevaluated.
281 \IT{\KWD{\char18}(\Op{\VAR{foo}} \Op{\KWD*{,}\VAR{bar}} \Op{\KWD{,@}\VAR{baz}}
282 \Op{\KWD*{,.}\DES{\VAR{quux}}} \Op{\VAR{bing}})}
283 {\index{,"@}\index{`@\char18}
284 Backquote. \SO{quote} \VAR{foo} and \VAR{bing}; evaluate \VAR{bar}
285 and splice the lists \VAR{baz} and \VAR{quux} into their
286 elements. When nested, outermost commas inside the innermost
287 backquote expression belong to this backquote.
290 \IT{\KWD{\#\boldmath{$\backslash$}}\VAR{c}}
292 (\FU*{character} \LIT{"}\VAR{c}\LIT{"}), the character \VAR{c}.
294 \index{\#@\#$\backslash$}%
296 \IT{\KWD*{\#b}\VAR{n}; \KWD*{\#o}\VAR{n}; \VAR{n}\kwd{.};
297 \KWD*{\#x}\VAR{n}; \KWD{\#}\VAR{r}\KWD{R}\VAR{n}}
298 {\index{\#R}%
299 Integer of radix 2, 8, 10, 16, or \VAR{r}; $2\le r \le 36$.
302 \IT{\VAR{n}\kwd*{/}\VAR{d}\quad\qquad}
304 The \kwd*{ratio} $\frac{n}{d}$.
307 \IT{\GOO{\Op{\VAR{m}}\kwd{.}\VAR{n}%
308 \OP{\Goo{\KWD{S}\XOR\KWD{F}\XOR\KWD{D}\XOR\KWD{L}\XOR\KWD{E}}%
309 \VAR{x}\DF{\KWD{E}\LIT{0}}}%
310 \XOR%
311 \VAR{m}\OP{\kwd{.}\Op{\VAR{n}}}%
312 \Goo{\KWD{S}\XOR\KWD{F}\XOR\KWD{D}\XOR\KWD{L}\XOR\KWD{E}}\VAR{x}}}
314 $m.n\cdot10^x$ as \kwd*{short-float}, \kwd*{single-float},
315 \kwd*{double-float}, \kwd*{long-float}, or the type from \kwd{\A
316 read-default-float-format\A}.
319 \IT{\KWD*{\#C(}\VAR{a b}\kwd{)}\qquad\qquad}
321 (\FU*{complex} \VAR{a} \VAR{b}), the complex number
322 $\VAR{a}+\VAR{b}\text{i}$.
325 \IT{\KWD*{\#'}\VAR{foo}\qquad\qquad\qquad}
327 (\SO*{function} \VAR{foo}); the function named \VAR{foo}.
330 \IT{\KWD{\#}\VAR{n}\KWD{A}\VAR{sequence}}
331 {\index{\#A}%
332 \VAR{n}-dimensional array.
335 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{(}\OPn{\VAR{foo}}\kwd{)}}
336 {\index{\#(}%
337 Vector of some (or \VAR{n})
338 \VAR{foo}s filled with last \VAR{foo} if necessary.
341 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{\A}\OPn{\VAR{b}}}
342 {\index{\#*@\#\A}%
343 Bit vector of some (or \VAR{n})
344 \VAR{b}s filled with last \VAR{b} if necessary.
347 \IT{\KWD*{\#S(}\VAR{type} \Goos{\VAR{slot} \VAR{value}}\kwd{)}}
349 Structure of \VAR{type}.
352 \IT{\KWD*{\#P}\VAR{string}\qquad\qquad}
354 A pathname.
357 \IT{\KWD*{\#:}\VAR{foo}\qquad\qquad\qquad}
359 Uninterned symbol \VAR{foo}.
362 \IT{\KWD*{\#.}\VAR{form}\qquad\qquad}
364 Read-time value of \VAR{form}.
367 \IT{\V{\A read-eval\A}\DF{\T}}
368 {\index{*READ-EVAL*@\A READ-EVAL\A}
369 If \NIL, a \kwd{reader-error} is signalled at \kwd{\#.}.
372 \IT{\KWD{\#}\VAR{int}\kwd{=} \VAR{foo}\qquad\quad}
373 {\index{\#=}%
374 Give \VAR{foo} the label \VAR{int}.
377 \IT{\KWD{\#}\VAR{int}\kwd{\#}\qquad\qquad}
378 {\index{\#\#}%
379 Object labelled \VAR{int}.
382 \IT{\KWD{\#\boldmath$<$}\qquad\qquad\qquad}
383 {\index{\#<@\#$<$}%
384 Have the reader signal \kwd{reader-error}.
387 \IT{\arrGOO{\KWD*{\#+}\VAR{feature } \VAR{when-feature}\\
388 \KWD*{\#--}\VAR{feature } \VAR{unless-feature}}{.}}
390 Means \VAR{when-feature} if \VAR{feature} is \T; means
391 \VAR{unless-feature} if \VAR{feature} is \NIL. \VAR{feature} is a
392 symbol from \V{\A features\A}, or (\Goo{\kwd*{AND}\XOR\kwd*{OR}}
393 \OPn{\VAR{feature}}), or (\kwd*{NOT} \VAR{feature}).
396 \IT{\V{\A features\A}}
397 {\index{*FEATURES*@\A FEATURES\A}
398 List of symbols denoting implementation-dependent features.
401 \IT{\kwd{\boldmath$|$}\OPn{\VAR{c}}\kwd{\boldmath$|$};
402 \kwd{\boldmath$\backslash$}\VAR{c}}
404 \index{{$"|$} {$"|$}}%
405 Treat arbitrary character(s) \VAR{c} as alphabetic preserving case.
407 \index{\@{$\backslash$}}%
408 \end{LIST}
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412 \subsection{Printer}
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 \begin{LIST}{1cm}
418 \IT{(\xorGOO{\FU*{PRIN1}\\
419 \FU*{PRINT}\\
420 \FU*{PPRINT}\\
421 \FU*{PRINC}}{\}}
422 \VAR{foo} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
424 Print \VAR{foo} to \VAR{stream} \FU{read}ably,
425 \FU{read}ably between a newline and a space,
426 \FU{read}ably after a newline, or human-readably without any extra
427 characters, respectively. \FU{prin1}, \FU{print} and \FU{princ}
428 return \retval{\VAR{foo}}.
431 \IT{\arrGOO{(\FU*{PRIN1-TO-STRING} \VAR{ foo})\\
432 (\FU*{PRINC-TO-STRING} \VAR{ foo})}{.}}
434 Print \VAR{foo} to \retval{\VAR{string}} \FU{read}ably or
435 human-readably, respectively.
438 \IT{(\GFU*{PRINT-OBJECT} \VAR{object} \DES{\VAR{stream}})}
440 Print \retval{\VAR{object}} to \VAR{stream}. Called by the Lisp
441 printer.
444 \IT{(\MC*{PRINT-UNREADABLE-OBJECT} (\VAR{foo} \DES{\VAR{stream}}
445 \orGOO{\kwd{:type } \VAR{bool}\DF{\NIL}\\
446 \kwd{:identity } \VAR{bool}\DF{\NIL}}{\}})
447 \PROGN{\VAR{form}})}
449 Enclosed in \kwd{\#\boldmath$<$} and \kwd{\boldmath$>$}, print
450 \VAR{foo} by means of \VAR{form}s to \VAR{stream}. Return \retval{\NIL}.
453 \IT{(\FU*{TERPRI} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
455 Output a newline to \VAR{stream}. Return \retval{\NIL}.
458 \IT{(\FU*{FRESH-LINE})
459 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}}}
461 Output a newline to \VAR{stream} and return \retval{\T} unless \VAR{stream}
462 is already at the start of a line.
465 \IT{(\FU*{WRITE-CHAR} \VAR{char}
466 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
468 Output \retval{\VAR{char}} to \VAR{stream}.
471 \IT{(\xorGOO{\FU*{WRITE-STRING}\\
472 \FU*{WRITE-LINE}}{\}} \VAR{string}
473 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}
474 \OP{\orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\\kwd{:end} \VAR{
475 end}\DF{\NIL}}{\}}}})}
477 Write \retval{\VAR{string}} to \VAR{stream} without/with a trailing newline.
480 \IT{(\FU*{WRITE-BYTE} \VAR{byte} \DES{\VAR{stream}})}
482 Write \retval{\VAR{byte}} to binary \VAR{stream}.
485 \IT{(\FU*{WRITE-SEQUENCE} \VAR{sequence}
486 \DES{\VAR{stream}} \orGOO{\kwd{:start}\VAR{ start}\DF{\LIT{0}}\\
487 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
489 Write elements of \retval{\VAR{sequence}} to \VAR{stream}.
492 \IT{(\xorGOO{\FU*{WRITE}\\
493 \FU*{WRITE-TO-STRING}}{\}} \VAR{foo} \orGOO{%
494 \kwd{:array} \VAR{ bool}\\
495 \kwd{:base} \VAR{ radix}\\
496 \kwd{:case } \xorGOO{\kwd{:upcase}\\
497 \kwd{:downcase}\\
498 \kwd{:capitalize}}{.}\\
499 \kwd{:circle} \VAR{ bool}\\
500 \kwd{:escape} \VAR{ bool}\\
501 \kwd{:gensym} \VAR{ bool}\\
502 \kwd{:length } \Goo{\VAR{int}\XOR\NIL}\\
503 \kwd{:level } \Goo{\VAR{int}\XOR\NIL}\\
504 \kwd{:lines } \Goo{\VAR{int}\XOR\NIL}\\
505 \kwd{:miser-width } \Goo{\VAR{int}\XOR\NIL}\\
506 \kwd{:pprint-dispatch} \VAR{ dispatch-table}\\
507 \kwd{:pretty} \VAR{ bool}\\
508 \kwd{:radix} \VAR{ bool}\\
509 \kwd{:readably} \VAR{ bool}\\
510 \kwd{:right-margin } \Goo{\VAR{int}\XOR\NIL}\\
511 \kwd{:stream } \DES{\VAR{stream}}\DF{\V{\A standard-output\A}}%
512 }{\}})}
514 Print \VAR{foo} to \VAR{stream} and return \retval{\VAR{foo}}, or
515 print \VAR{foo} into \retval{string}, respectively, after
516 dynamically setting printer variables corresponding to keyword
517 parameters (\kwd{\A print-}\VAR{bar}\kwd{\A} becoming
518 \kwd{:}\VAR{bar}). (\kwd{:stream} keyword with \FU{write} only.)
521 \IT{\arrGOO{%
522 (\FU*{PPRINT-FILL } \DES{\VAR{stream}} \VAR{ foo }
523 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
524 (\FU*{PPRINT-TABULAR } \DES{\VAR{stream}} \VAR{ foo }
525 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop} \text{ }
526 \Op{\VAR{n}\DF{\LIT{16}}}}})\\
527 (\FU*{PPRINT-LINEAR } \DES{\VAR{stream}} \VAR{ foo }
528 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
529 }{.}}
531 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print as
532 many elements per line as possible; do the same in a table with
533 a column width of \VAR{n} ems; or print either all elements on
534 one line or each on its own line, respectively. Return
535 \retval{\NIL}. Usable with \FU{format} directive \KWD{\TLD//}.
538 \IT{(\MC*{PPRINT-LOGICAL-BLOCK} (\DES{\VAR{stream}} \VAR{list}
539 \orGOO{\xorGOO{\kwd{:prefix} \VAR{ string}\\
540 \kwd{:per-line-prefix} \VAR{ string}}{\}}\\
541 \kwd{:suffix} \VAR{ string}\DF{\LIT{""}}}{\}})
542 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
544 Evaluate \VAR{form}s, which should print \VAR{list}, with
545 \VAR{stream} locally bound to a pretty
546 printing stream which outputs to the original \VAR{stream}. If
547 \VAR{list} is in fact not a list, it is printed by
548 \FU{write}. Return \retval{\NIL}.
551 \begin{LIST}{.5cm}
553 \IT{(\MC*{PPRINT-POP})}
555 Take \retval{next element} off \VAR{list}. If there is no remaining
556 tail of \VAR{list}, or \V{\A print-length\A} or \V{\A print-circle\A} indicate
557 printing should end, send element together with an appropriate
558 indicator to \VAR{stream}.
561 \IT{(\FU*{PPRINT-TAB} \xorGOO{\kwd{:line}\\
562 \kwd{:line-relative}\\
563 \kwd{:section}\\
564 \kwd{:section-relative}}{\}} \VAR{c}
565 \VAR{i} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
567 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
568 as possible.
571 \IT{(\FU*{PPRINT-INDENT} \xorGOO{%
572 \kwd{:block}\\
573 \kwd{:current}}{\}} \VAR{n}
574 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
576 Specify indentation for innermost logical block relative to
577 leftmost position/to current position. Return \retval{\NIL}.
580 \IT{(\MC*{PPRINT-EXIT-IF-LIST-EXHAUSTED})}
582 If \VAR{list} is empty, terminate logical block. Return
583 \retval{\NIL} otherwise.
586 \end{LIST}
588 \IT{(\FU*{PPRINT-NEWLINE} \xorGOO{%
589 \kwd{:linear}\\
590 \kwd{:fill}\\
591 \kwd{:miser}\\
592 \kwd{:mandatory}}{\}}
593 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
595 Print a conditional newline if \VAR{stream} is a pretty printing
596 stream. Return \retval{\NIL}.
599 \IT{\V{\A print-array\A}}
600 {\index{*PRINT-ARRAY*@\A PRINT-ARRAY\A}
601 If \T, print arrays \FU{read}ably.
604 \IT{\V{\A print-base\A}\DF{\LIT{10}}}
605 {\index{*PRINT-BASE*@\A PRINT-BASE\A}
606 Radix for printing rationals, from 2 to 36.
609 \IT{\V{\A print-case\A}\DF{\kwd{:upcase}}}
610 {\index{*PRINT-CASE*@\A PRINT-CASE\A}
611 Print symbol names all uppercase (\kwd{:upcase}), all lowercase
612 (\kwd{:downcase}), capitalized (\kwd{:capitalize}).
615 \IT{\V{\A print-circle\A}\DF{\NIL}}
616 {\index{*PRINT-CIRCLE*@\A PRINT-CIRCLE\A}
617 If \T, avoid indefinite recursion while printing circular
618 structure.
621 \IT{\V{\A print-escape\A}\DF{\T}}
622 {\index{*PRINT-ESCAPE*@\A PRINT-ESCAPE\A}
623 If \NIL, do not print escape characters and package prefixes.
626 \IT{\V{\A print-gensym\A}\DF{\T}}
627 {\index{*PRINT-GENSYM*@\A PRINT-GENSYM\A}
628 If \T, print \kwd{\#:} before uninterned symbols.
631 \IT{\arrGOO{\V{\A print-length\A}\DF{\NIL}\\
632 \V{\A print-level\A}\DF{\NIL}\\
633 \V{\A print-lines\A}\DF{\NIL}
634 }{.}}
635 {\index{*PRINT-LENGTH*@\A PRINT-LENGTH\A}\index{*PRINT-LEVEL*@\A PRINT-LEVEL\A}\index{*PRINT-LINES*@\A PRINT-LINES\A}
636 If integer, restrict printing of objects to that number of
637 elements per level/to that depth/to that number of lines.
640 \IT{\V{\A print-miser-width\A}}
641 {\index{*PRINT-MISER-WIDTH*@\A PRINT-MISER-WIDTH\A}
642 If integer and greater than the width available for printing a
643 substructure, switch to the more compact miser style.
646 \IT{\V{\A print-pretty\A}}
647 {\index{*PRINT-PRETTY*@\A PRINT-PRETTY\A}
648 If \T, print pretty.
651 \IT{\V{\A print-radix\A}\DF{\NIL}}
652 {\index{*PRINT-RADIX*@\A PRINT-RADIX\A}
653 If \T, print rationals with a radix indicator.
656 \IT{\V{\A print-readably\A}\DF{\NIL}}
657 {\index{*PRINT-READABLY*@\A PRINT-READABLY\A}
658 If \T, print \FU{read}ably or signal error
659 \kwd{print-not-readable}.
662 \IT{\V{\A print-right-margin\A}\DF{\NIL}}
663 {\index{*PRINT-RIGHT-MARGIN*@\A PRINT-RIGHT-MARGIN\A}
664 Right margin width in ems while pretty-printing.
667 \IT{(\FU*{SET-PPRINT-DISPATCH} \VAR{type} \VAR{function}
668 \OP{\VAR{priority}\DF{\LIT{0}}
669 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}}})}
671 Install entry comprising \VAR{function} of arguments stream and
672 object to print; and \VAR{priority} as
673 \VAR{type} into \VAR{table}. If \VAR{function}
674 is \NIL, remove \VAR{type} from \VAR{table}. Return \retval{\NIL}.
677 \IT{(\FU*{PPRINT-DISPATCH} \VAR{foo}
678 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
680 Return highest priority \retval{\VAR{function}} associated with
681 type of \VAR{foo} and \retvalii{\T} if there was a matching type
682 specifier in \VAR{table}.
685 \IT{(\FU*{COPY-PPRINT-DISPATCH}
686 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
688 Return \retval{copy of \VAR{table}} or, if \VAR{table} is \NIL,
689 initial value of \V{\A print-pprint-dispatch\A}.
692 \IT{\V{\A print-pprint-dispatch\A}}
693 {\index{*PRINT-PPRINT-DISPATCH*@\A PRINT-PPRINT-DISPATCH\A}
694 Current pretty print dispatch table.
697 \end{LIST}
701 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
702 \subsection{Format}
703 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
704 \label{section:Format}
706 \begin{LIST}{1cm}
708 \IT{(\MC*{FORMATTER} \NEV{\VAR{control}})}
710 Return \retval{function} of stream and a \kwd{\&rest} argument applying \FU{format} to
711 stream, \VAR{control}, and the \kwd{\&rest} argument
712 returning \NIL\ or any excess arguments.
715 \IT{(\FU*{FORMAT} \Goo{\T\XOR\NIL\XOR\VAR{out-string}\XOR\VAR{out-stream}}
716 \VAR{control} \OPn{\VAR{arg}})}
718 Output string \VAR{control} which may
719 contain \kwd{\TLD} directives possibly taking some
720 \VAR{arg}s. Alternatively, \VAR{control} can be a function returned
721 by \MC{formatter} which is then applied to \VAR{out-stream} and \OPn{\VAR{arg}}.
722 Output to \VAR{out-string}, \VAR{out-stream} or, if first
723 argument is \T, to \V{\A standard-output\A}. Return \retval{\NIL}. If
724 first argument is \NIL, return \retval{formatted output}.
727 \begin{LIST}{.5cm}
729 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}} \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
730 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
731 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
732 \KWD{\Op{:} \Op{@} \Goo{A\XOR S}}}
733 {\index{\~S@$\sim$S}\index{\~A@$\sim$A}%
734 \EM{Aesthetic/Standard. }
735 Print argument of any type for consumption by humans/by the
736 reader, respectively. With \kwd{:}, print \NIL\ as \LIT{()} rather
737 than \LIT{nil}; with \kwd{@}, add \VAR{pad-char}s on the left
738 rather than on the right.
741 \IT{\KWD{\TLD} \Op{\VAR{radix}\DF{\LIT{10}}} \OP{\KWD{,}\Op{\VAR{width}}
742 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
743 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
744 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}}
745 \KWD{\Op{:} \Op{@} R}}
746 {\index{\~R@$\sim$R}%
747 \EM{Radix. }
748 (With one or more prefix arguments.) Print argument as number; with
749 \KWD{:}, group digits \VAR{comma-interval} each; with \kwd{@},
750 always prepend a sign.
753 \IT{\Goo{\KWD{\TLD R}\XOR\KWD{\TLD :R}\XOR\KWD{\TLD
754 @R}\XOR\KWD{\TLD @:R}}}
756 \EM{Roman. }
757 Take argument as number and print it as English cardinal number,
758 as English ordinal number, as Roman numeral, or as old Roman
759 numeral, respectively.
762 \IT{\KWD{\TLD} \Op{\VAR{width}}
763 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
764 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
765 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}
766 \KWD{\Op{:} \Op{@} \Goo{D\XOR B\XOR O\XOR X}}}
767 {\index{\~D@$\sim$D}\index{\~B@$\sim$B}\index{\~O@$\sim$O}\index{\~X@$\sim$X}%
768 \EM{Decimal/Binary/Octal/Hexadecimal. }
769 Print integer argument as number. With \kwd{:}, group digits
770 \VAR{comma-interval} each; with \kwd{@}, always prepend a sign.
773 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{dec-digits}}
774 \OP{\KWD{,}\Op{\VAR{shift}\DF{\LIT{0}}}
775 \OP{\KWD{,}\Op{\VAR{overflow-char}}
776 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}}
777 \KWD{\Op{@} F}}
778 {\index{\~F@$\sim$F}%
779 \EM{Fixed-Format Floating-Point. } With
780 \kwd{@}, always pre\-pend a sign.
783 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{int-digits}}
784 \OP{\KWD{,}\Op{\VAR{exp-digits}}
785 \OP{\KWD{,}\Op{\VAR{scale-factor}\DF{\LIT{1}}}
786 \OP{\KWD{,}\Op{\VAR{overflow-char}}
787 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
788 \OP{\KWD{,}\VAR{exp-char}}}}}}}
789 \KWD{\Op{@} \Goo{E\XOR G}}}
790 {\index{\~E@$\sim$E}\index{\~G@$\sim$G}%
791 \EM{Exponential/General Floating-Point. }
792 Print argument as floating-point number with \VAR{int-digits}
793 before decimal point and \VAR{exp-digits} in the signed
794 exponent. With \KWD{\TLD G}, choose either \KWD{\TLD E} or
795 \KWD{\TLD F}. With \KWD{@}, always prepend a sign.
798 \IT{\KWD{\TLD} \Op{\VAR{dec-digits}\DF{\LIT{2}}}
799 \OP{\KWD{,}\Op{\VAR{int-digits}\DF{\LIT{1}}}
800 \OP{\KWD{,}\Op{\VAR{width}\DF{\LIT{0}}}
801 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
802 \Op{\KWD{:}} \Op{\kwd{@}} \KWD{\$}}
803 {\index{\~\$@$\sim$\$}%
804 \EM{Monetary Floating-Point. }
805 Print argument as fixed-format floating-point number. With \KWD{:},
806 put sign before any padding; with \KWD{@}, always prepend a sign.}
808 \IT{\Goo{\KWD{\TLD C}\XOR\KWD{\TLD :C}\XOR\KWD{\TLD
809 @C}\XOR\KWD{\TLD @:C}}}
810 {\index{\~C@$\sim$C}%
811 \EM{Character. }
812 Print, spell out, print in \kwd{\#$\backslash$} syntax, or tell
813 how to type, respectively, argument as (possibly non-printing)
814 character.
817 \IT{\Goo{%
818 \KWD{\TLD(} \VAR{text} \KWD{\TLD)}\XOR
819 \KWD{\TLD:(} \VAR{text} \KWD{\TLD)}\XOR
820 \KWD{\TLD @(} \VAR{text} \KWD{\TLD)}\XOR
821 \KWD{\TLD:@(} \VAR{text} \KWD{\TLD)}}}
822 {\index{\~(\~)@$\sim$( $\sim$)}%
823 \EM{Case-Conversion. }
824 Convert \VAR{text} to lowercase, convert first letter of each word
825 to uppercase, capitalize first word and convert the rest to
826 lowercase, or convert to uppercase, respectively.
829 \IT{\Goo{\KWD{\TLD P}\XOR\KWD{\TLD:P}
830 \XOR\KWD{\TLD @P}\XOR\KWD{\TLD:@P}}}
831 {\index{\~P@$\sim$P}%
832 \EM{Plural. }
833 If argument \kwd{eql} \LIT{1} print nothing, otherwise print \LIT{s};
834 do the same for the previous argument; if argument \kwd{eql} \LIT{1}
835 print \LIT{y}, otherwise print \LIT{ies}; do the same for the
836 previous argument, respectively.
839 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\%}}
840 {\index{\~\%@$\sim$\%}%
841 \EM{Newline. }
842 Print \VAR{n} newlines.
845 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\&}}
846 {\index{\~\&@$\sim$\&}%
847 \EM{Fresh-Line. }
848 Print $n-1$ newlines if output stream is at the
849 beginning of a line, or \VAR{n} newlines otherwise.
852 \IT{\Goo{\KWD{\TLD\_}\XOR\KWD{\TLD:\_}\XOR\KWD{\TLD@\_}\XOR\KWD{\TLD:@\_}}}
853 {\index{\~\_{}@$\sim$\_{}}%
854 \EM{Conditional Newline. }
855 Print a newline like \kwd{pprint-newline} with argument
856 \kwd{:linear}, \kwd{:fill}, \kwd{:miser}, or \kwd{:mandatory}, respectively.
859 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} $\hookleftarrow$}
861 \EM{Ignored Newline. } Ignore newline and following
862 whitespace. With \kwd{:}, ignore only newline; with \kwd{@},
863 ignore only following whitespace.
866 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\boldmath$|$}}
867 {\index{\~\textbar@$\sim${$"|$}}%
868 \EM{Page. }
869 Print \VAR{n} page separators.
872 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\TLD}}
873 {\index{\~\~@$\sim$$\sim$}%
874 \EM{Tilde. }
875 Print \VAR{n} tildes.
878 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}}
879 \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
880 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
881 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
882 \KWD{\Op{:} \Op{@} \boldmath{$<$}}
883 \OP{\VAR{nl-text} \KWD{\TLD}\Op{\VAR{spare}\DF{\LIT{0}} \Op{\KWD{,}\VAR{width}}}\kwd{:;}}
884 \Goos{\VAR{text} \KWD{\TLD;}} \VAR{text} \KWD{\TLD\boldmath{$>$}}}
885 {\index{\~<\~>@$\sim$$<$ $\sim$$>$}%
886 \EM{Justification. }
887 Justify text produced by \VAR{text}s in a field of at least
888 \VAR{min-col} columns. With \kwd{:}, right justify; with \kwd{@},
889 left justify. If this would leave less than \VAR{spare} characters
890 on the current line, output \VAR{nl-text} first.
893 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{\boldmath{$<$}}
894 \GOo{\Op{\VAR{prefix}\DF{\LIT{""}}
895 \KWD{\TLD;}}\XOR\Op{\VAR{per-line-prefix}
896 \KWD{\TLD@;}}}
897 \VAR{body} \OP{\KWD{\TLD;} \VAR{suffix}\DF{\LIT{""}}}
898 \KWD{\TLD:} \Op{\KWD{@}} \KWD{\boldmath{$>$}}}
899 {\index{\~<\~:>@$\sim$$<$ $\sim$:$>$}%
900 \EM{Logical Block. }
901 Act like \kwd{pprint-logical-block} using \VAR{body} as \FU{format}
902 control string on the elements of the list argument or, with \KWD{@},
903 on the remaining arguments, which are extracted by
904 \kwd{pprint-pop}. With \KWD{:}, \VAR{prefix} and \VAR{suffix}
905 default to \LIT{(} and \LIT{)}. When closed by
906 \KWD{\TLD:@\boldmath{$>$}}, spaces in \VAR{body} are replaced with
907 conditional newlines.
910 \IT{\Goo{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}}
911 \kwd{I}\XOR\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \kwd{:I}}}
912 {\index{\~I@$\sim$I}%
913 \EM{Indent. }
914 Set indentation to \VAR{n} relative to leftmost/to current
915 position.
918 \IT{\KWD{\TLD} \Op{\VAR{c}\DF{\LIT{1}}}
919 \Op{\KWD{,}\VAR{i}\DF{\LIT{1}}} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{T}}
920 {\index{\~T@$\sim$T}%
921 \EM{Tabulate. }
922 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
923 as possible. With \kwd{:}, calculate column numbers relative to
924 the immediately enclosing section. With \kwd{@}, move to column
925 number $c_0 + c + ki$ where $c_0$ is the current position.
928 \IT{\Goo{%
929 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{\A}\XOR
930 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{:}\KWD{\A}\XOR
931 \KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \KWD{@}\KWD{\A}}}
932 {\index{\~*@$\sim$\A}%
933 \EM{Go-To. }
934 Jump \VAR{m} arguments forward, or backward, or to argument \VAR{n}.
937 \IT{\KWD{\TLD} \Op{\VAR{limit}} \Op{\KWD{{:}}} \Op{\kwd{@}}
938 \KWD{\boldmath{$\{$}} \VAR{text} \KWD{\TLD\boldmath{$\}$}}}
939 {\index{\~\{\~\}@$\sim$$\{$ $\sim\}$}%
940 \EM{Iteration. }
941 Use \VAR{text} repeatedly, up to \VAR{limit}, as control
942 string for the elements of the list argument or (with
943 \kwd{@}) for the remaining arguments. With \kwd{:} or \kwd{:@},
944 list elements or remaining arguments should be
945 lists of which a new one is used at each iteration step.
948 \IT{\KWD{\TLD} \OP{\VAR{x} \OP{\kwd{,}\VAR{y} \Op{\kwd{,}\VAR{z}}}}
949 \KWD{\^{}}}
950 {\index{\~\^{}@$\sim$\^{}}%
951 \EM{Escape Upward. }
952 Leave immediately \kwd{\TLD\boldmath{$<$} \TLD\boldmath{$>$}},
953 \kwd{\TLD\boldmath{$<$} \TLD:\boldmath{$>$}},
954 \kwd{\TLD\boldmath{$\{$} \TLD\boldmath{$\}$}}, \kwd{\TLD?}, or the
955 entire \FU{format} operation. With one to three prefixes, act only
956 if $x=0$, $x=y$, or $x\leq y \leq z$, respectively.
959 \IT{\KWD{\TLD} \Op{\VAR{i}} \Op{\KWD{:}} \Op{\KWD{@}}
960 \KWD{[} \Op{\Goos{\VAR{text} \KWD{\TLD;}} \VAR{text}}
961 \Op{\kwd{\TLD:;} \VAR{default}} \KWD{\TLD]}}
962 {\index{\~[\~]@$\sim$[ $\sim$]}%
963 \EM{Conditional Expression. }
964 Use the zero-indexed argumenth (or
965 \VAR{i}th if given) \VAR{text} as a \FU{format} control subclause.
966 With \kwd{:}, use the first \VAR{text} if the argument value is
967 \NIL, or the second \VAR{text} if it is \T. With \kwd{@}, do nothing
968 for an argument value of \NIL. Use the only \VAR{text} and leave
969 the argument to be read again if it is \T.
972 \IT{\KWD{\TLD} \Op{\KWD{@}} \KWD{?}}
973 {\index{\~?@$\sim$?}%
974 \EM{Recursive Processing. }
975 Process two arguments as control string and argument list. With
976 \kwd{@}, take one argument as control string and use then the
977 rest of the original arguments.
980 \IT{\KWD{\TLD} \OP{\VAR{prefix} \Goos{\kwd{,}%
981 \VAR{prefix}}} \Op{\kwd{:}} \Op{\kwd{@}} \KWD{/}\VAR{function}\KWD{/}}
982 {\index{\~/ /@$\sim$/ /}%
983 \EM{Call Function. }
984 Call \VAR{function} with the arguments stream, format-ar\-gu\-ment,
985 colon-p, at-sign-p and \VAR{prefix}es for printing format-argument.
988 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{W}}
989 {\index{\~W@$\sim$W}%
990 \EM{Write. }
991 Print argument of any type obeying every printer control variable. With \kwd{:},
992 pretty-print. With \kwd{@}, print without limits on length or depth.
995 \IT{\Goo{\KWD{V}\XOR\KWD{\#}}}
996 {\index{V}\index{\#}
997 In place of the comma-separated prefix parameters: use next
998 argument or number of remaining unprocessed arguments, respectively.
1001 \end{LIST}
1003 \end{LIST}
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 \subsection{Streams}
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 \begin{LIST}{1cm}
1012 \IT{(\FU*{OPEN} \VAR{path}
1013 \orGOO{\kwd{:direction } \xorGOO{\kwd{:input}\\
1014 \kwd{:output}\\
1015 \kwd{:io}\\
1016 \kwd{:probe}}{\}}\DF{\kwd{:input}}\\
1017 \kwd{:element-type} \VAR{ type}\DF{\kwd{character}}\\
1018 \kwd{:if-exists }
1019 \xorGOO{\kwd{:new-version}\\
1020 \kwd{:error}\\
1021 \kwd{:rename}\\
1022 \kwd{:rename-and-delete}\\
1023 \kwd{:overwrite}\\
1024 \kwd{:append}\\
1025 \kwd{:supersede}\\
1026 \NIL}{.}\\
1027 \kwd{:if-does-not-exist } \xorGOO{\kwd{:error}\\
1028 \kwd{:create}\\
1029 \NIL}{.}\\
1030 \kwd{:external-format } \VAR{format}\DF{\kwd{:default}}%
1031 }{\}})}
1032 {\label{open}
1033 Open \retval{\kwd{file-stream} to \VAR{path}}.
1036 \IT{\arrGOO{%
1037 (\FU*{MAKE-CONCATENATED-STREAM } \OPn{\VAR{input-stream}})\\
1038 (\FU*{MAKE-BROADCAST-STREAM } \OPn{\VAR{output-stream}})\\
1039 (\FU*{MAKE-TWO-WAY-STREAM } \VAR{input-stream-part } \VAR{output-stream-part})\\
1040 (\FU*{MAKE-ECHO-STREAM } \VAR{from-input-stream } \VAR{to-output-stream})\\
1041 (\FU*{MAKE-SYNONYM-STREAM } \VAR{variable-bound-to-stream})}{.}}
1043 Return \retval{stream} of indicated type.
1046 \IT{(\FU*{MAKE-STRING-INPUT-STREAM} \VAR{string}
1047 \OP{\VAR{start}\DF{\LIT{0}}
1048 \Op{\VAR{end}\DF{\NIL}}})}
1050 Return a \retval{\kwd{string-stream}} supplying the characters from \VAR{string}.
1053 \IT{(\FU*{MAKE-STRING-OUTPUT-STREAM} \Op{\kwd{:element-type}
1054 \VAR{type}\DF{\kwd{character}}})}
1056 Return a \retval{\kwd{string-stream}} accepting characters
1057 (available via \FU{get-output-stream-string}).
1060 \IT{\arrGOO{(\FU*{CONCATENATED-STREAM-STREAMS } \VAR{concatenated-stream})\\
1061 (\FU*{BROADCAST-STREAM-STREAMS } \VAR{broadcast-stream})}{.}}
1063 Return \retval{list of streams} \VAR{concatenated-stream} still
1064 has to read from/\VAR{broadcast-stream} is
1065 broadcasting to.
1068 \IT{\arrGOO{%
1069 (\FU*{TWO-WAY-STREAM-INPUT-STREAM} \VAR{ two-way-stream})\\
1070 (\FU*{TWO-WAY-STREAM-OUTPUT-STREAM} \VAR{ two-way-stream})\\
1071 (\FU*{ECHO-STREAM-INPUT-STREAM} \VAR{ echo-stream})\\
1072 (\FU*{ECHO-STREAM-OUTPUT-STREAM} \VAR{ echo-stream})}{.}}
1074 Return \retval{source stream} or \retval{sink stream} of
1075 \VAR{two-way-stream}\slash\VAR{echo-stream}, respectively.
1078 \IT{(\FU*{SYNONYM-STREAM-SYMBOL} \VAR{synonym-stream})}
1080 Return \retval{symbol} of \VAR{synonym-stream}.
1083 \IT{(\FU*{GET-OUTPUT-STREAM-STRING} \DES{\VAR{string-stream}})}
1085 Clear and return as a \retval{string} characters on \VAR{string-stream}.
1088 \IT{(\FU*{LISTEN} \Op{\VAR{stream}\DF{\V{\A standard-input\A}}})}
1090 \retval{\T} if there is a character in input \VAR{stream}.
1093 \IT{(\FU*{CLEAR-INPUT}
1094 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}})}
1096 Clear input from \VAR{stream}, return \retval{\NIL}.
1099 \IT{(\xorGOO{\FU*{CLEAR-OUTPUT}\\
1100 \FU*{FORCE-OUTPUT}\\
1101 \FU*{FINISH-OUTPUT}}{\}}
1102 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
1104 End output to \VAR{stream} and return \retval{\NIL} immediately,
1105 after initiating flushing of buffers, or after flushing of buffers,
1106 respectively.
1109 \IT{(\FU*{CLOSE} \DES{\VAR{stream}} \Op{\kwd{:abort}
1110 \VAR{bool}\DF{\NIL}})}
1112 Close \VAR{stream}. Return \retval{\T} if \VAR{stream} had been
1113 open. If \kwd{:abort} is \T, delete associated file.
1116 \IT{(\MC*{WITH-OPEN-STREAM} (\VAR{foo} \DES{\VAR{stream}})
1117 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1119 Evaluate \VAR{form}s with \VAR{foo} locally bound to
1120 \VAR{stream}. Return \retval{values of \VAR{form}s}.
1123 \IT{(\MC*{WITH-INPUT-FROM-STRING} (\VAR{foo} \VAR{string}
1124 \orGOO{\kwd{:index } \DES{\VAR{index}}\\
1125 \kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1126 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}}) \OPn{(\kwd{declare}
1127 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1129 Evaluate \VAR{form}s with \VAR{foo} locally bound to input \kwd{string-stream}
1130 from \VAR{string}. Return \retval{values of \VAR{form}s}; store next
1131 reading position into \VAR{index}.
1134 \IT{(\MC*{WITH-OUTPUT-TO-STRING} (\VAR{foo}
1135 \Op{\DES{\VAR{string}}\DF{\NIL}} \Op{\kwd{:element-type}
1136 \VAR{type}\DF{\kwd{character}}}) \OPn{(\kwd{declare}
1137 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1139 Evaluate \VAR{form}s with \VAR{foo} locally bound to an output
1140 \kwd{string-stream}. Append output to \VAR{string} and return
1141 \retval{values of \VAR{form}s} if \VAR{string} is given. Return
1142 \retval{string containing output} otherwise.
1145 \IT{(\FU*{STREAM-EXTERNAL-FORMAT} \VAR{stream})}
1147 \retval{External file format designator}.
1150 \IT{\V{\A terminal-io\A}}
1151 {\index{*TERMINAL-IO*@\A TERMINAL-IO\A}
1152 Bidirectional stream to user terminal.
1155 \IT{\arrGOO{\V{\A standard-input\A}\\
1156 \V{\A standard-output\A}\\
1157 \V{\A error-output\A}}{.}}
1158 {\index{*STANDARD-INPUT*@\A STANDARD-INPUT\A}%
1159 \index{*STANDARD-OUTPUT*@\A STANDARD-OUTPUT\A}%
1160 \index{*ERROR-OUTPUT*@\A ERROR-OUTPUT\A}
1161 Standard input stream, standard output stream,
1162 or standard error output stream, respectively.
1165 \IT{\arrGOO{\V{\A debug-io\A}\\
1166 \V{\A query-io\A}}{.}}
1167 {\index{*DEBUG-IO*@\A DEBUG-IO\A}\index{*QUERY-IO*@\A QUERY-IO\A}
1168 Bidirectional streams for debugging and user interaction.
1171 \end{LIST}
1174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1175 \subsection{Files}
1176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1178 \begin{LIST}{1cm}
1180 \IT{(\FU*{MAKE-PATHNAME}
1181 \orGOO{\kwd{:host } \Goo{\VAR{host}\XOR\NIL\XOR\kwd{:unspecific}}\\
1182 \kwd{:device } \Goo{\VAR{device}\XOR\NIL\XOR\kwd{:unspecific}}\\
1183 \kwd{:directory } \xorGOO{%
1184 \Goo{\VAR{directory}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1185 (\xorGOO{%
1186 \kwd{:absolute}\\
1187 \kwd{:relative}
1188 }{\}}\text{ }%
1189 \xorGOO{%
1190 \VAR{directory}\\
1191 \kwd{:wild}\\
1192 \kwd{:wild-inferiors}\\
1193 \kwd{:up}\\
1194 \kwd{:back}
1195 }{\}^{\!\!*}})
1196 }{.}\\
1197 \kwd{:name } \Goo{\VAR{file-name}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1198 \kwd{:type } \Goo{\VAR{file-type}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1199 \kwd{:version } \Goo{\kwd{:newest}\XOR\VAR{version}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1200 \kwd{:defaults } \VAR{path}\DF{host from \V{\A default-pathname-defaults\A}}\\
1201 \kwd{:case
1202 \Goo{\kwd{:local}\XOR\kwd{:common}}\DF{\kwd{:local}}}}{\}})}
1204 Construct \retval{pathname}.
1205 For \kwd{:case :local}, leave case of components unchanged.
1206 For \kwd{:case :common}, leave mixed-case components unchanged;
1207 convert all-uppercase components into
1208 local customary case; do the opposite with all-lowercase
1209 components.
1212 \IT{\arrGOO{%
1213 (\xorGOO{\FU*{PATHNAME-HOST}\\
1214 \FU*{PATHNAME-DEVICE}\\
1215 \FU*{PATHNAME-DIRECTORY}\\
1216 \FU*{PATHNAME-NAME}\\
1217 \FU*{PATHNAME-TYPE}}{\}}
1218 \VAR{ path }
1219 \Op{\kwd{:case } \xorGOO{\kwd{:local}\\
1220 \kwd{:common}}{\}}\DF{\kwd{:local}}})\\
1221 (\FU*{PATHNAME-VERSION } \VAR{path})}{.}}
1223 Return \retval{pathname component}.
1226 \IT{(\FU*{PARSE-NAMESTRING} \VAR{foo}
1227 \OP{\VAR{host}
1228 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1229 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1230 \kwd{:end} \VAR{ end}\DF{\NIL}\\
1231 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}}}})}
1233 Return \retval{pathname} converted from
1234 string, pathname, or stream \VAR{foo}; and \retvalii{position}
1235 where parsing stopped.
1238 \IT{(\FU*{MERGE-PATHNAMES} \VAR{pathname}
1239 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1240 \Op{\VAR{default-version}\DF{\kwd{:newest}}}})}
1242 Return \retval{\VAR{pathname}} after filling in missing components
1243 from \VAR{default-pathname}.
1246 \IT{\V{\A default-pathname-defaults\A}}
1247 {\index{*DEFAULT-PATHNAME-DEFAULTS*@\A DEFAULT-PATHNAME-DEFAULTS\A}
1248 Pathname to use if one is needed and none supplied.
1251 \IT{(\FU*{USER-HOMEDIR-PATHNAME} \Op{\VAR{host}})}
1253 User's \retval{home directory}.
1256 \IT{(\FU*{ENOUGH-NAMESTRING} \VAR{path}
1257 \Op{\VAR{root-path}\DF{\V{\A default-pathname-defaults\A}}})}
1259 Return \retval{minimal path string} to sufficiently describe
1260 \VAR{path} relative to \VAR{root-path.}
1263 \IT{\arrGOO{(\FU*{NAMESTRING}\VAR{ path})\\
1264 (\FU*{FILE-NAMESTRING}\VAR{ path})\\
1265 (\FU*{DIRECTORY-NAMESTRING}\VAR{ path})\\
1266 (\FU*{HOST-NAMESTRING}\VAR{ path})}{.}}
1268 Return string representing \retval{full pathname}; \retval{name,
1269 type, and version}; \retval{directory name}; or \retval{host
1270 name}, respectively, of \VAR{path}.
1273 \IT{(\FU*{TRANSLATE-PATHNAME} \VAR{path} \VAR{wildcard-path-a}
1274 \VAR{wildcard-path-b})}
1276 Translate \VAR{path} from \VAR{wildcard-path-a} into
1277 \VAR{wildcard-path-b}. Return \retval{new path}.
1280 \IT{(\FU*{PATHNAME} \VAR{path})}
1282 \retval{Pathname} of \VAR{path}.
1285 \IT{(\FU*{LOGICAL-PATHNAME} \VAR{logical-path})}
1287 \retval{Logical pathname} of \VAR{logical-path}.
1288 Logical pathnames are represented as all-uppercase
1289 \LIT{\#P"}%
1290 \Op{\VAR{host}\LIT{:}}\Op{\LIT{:}}%
1291 \Goos{\xorGOO{%
1292 \Goop{\VAR{dir}\XOR\LIT{*}}\\
1293 \LIT{**}}{\}}\LIT{;}}%
1294 \penalty-5
1295 \Goos{\VAR{name}\XOR\LIT{*}}%
1296 \OP{\LIT{.}%
1297 \xorGOO{%
1298 \Goop{\VAR{type}\XOR\LIT{*}}\\
1299 \LIT{LISP}}{\}}%
1300 \Op{\LIT{.}%
1301 \Goo{%
1302 \VAR{version}\XOR\LIT{*}\XOR\LIT{newest}\XOR\LIT{NEWEST}}}}%
1303 \LIT{"}.
1306 \IT{(\FU*{LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1308 \retval{List of (\VAR{from-wildcard to-wildcard}) translations}
1309 for \VAR{logical-host}. \kwd{setf}able.
1312 \IT{(\FU*{LOAD-LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1314 Load \VAR{logical-host}'s translations. Return \retval{\NIL} if already
1315 loaded; return \retval{\T} if successful.
1318 \IT{(\FU*{TRANSLATE-LOGICAL-PATHNAME} \VAR{pathname})}
1320 \retval{Physical pathname} corresponding to (possibly logical)
1321 \VAR{pathname}.
1324 \IT{\arrGOO{(\FU*{PROBE-FILE} \VAR{ file})\\
1325 (\FU*{TRUENAME} \VAR{ file})}{.}}
1327 \retval{Canonical name} of \VAR{file}. If \VAR{file} does not exist,
1328 return \retval{\NIL}/signal \kwd{file-error}, respectively.
1331 \IT{(\FU*{FILE-WRITE-DATE} \VAR{file})}
1333 \retval{Time} at which \VAR{file} was last written.
1336 \IT{(\FU*{FILE-AUTHOR} \VAR{file})\qquad\qquad}
1338 Return \retval{name of \VAR{file} owner}.
1341 \IT{(\FU*{FILE-LENGTH} \VAR{stream})}
1343 Return \retval{length of \VAR{stream}}.
1346 \IT{(\FU*{FILE-POSITION} \VAR{stream} \Op{\xorGOO{\kwd{:start}\\
1347 \kwd{:end}\\
1348 \VAR{position}}{\}}})}
1350 Return \retval{position within stream}, or set it to
1351 \retval{\VAR{position}} and return \retval{\T} on success.
1354 \IT{(\FU*{FILE-STRING-LENGTH} \VAR{stream} \VAR{foo})}
1356 \retval{Length} \VAR{foo} would have in \VAR{stream}.
1359 \IT{(\FU*{RENAME-FILE} \VAR{foo} \VAR{bar})}
1361 Rename file \VAR{foo} to \VAR{bar}. Unspecified components of path
1362 \VAR{bar} default to those of \VAR{foo}. Return \retval{new
1363 pathname}, \retvalii{old physical file name}, and \retvaliii{new
1364 physical file name}.
1367 \IT{(\FU*{DELETE-FILE} \VAR{file})}
1369 Delete \VAR{file}. Return \retval{\T}.
1372 \IT{(\FU*{DIRECTORY} \VAR{path})}
1374 \retval{List of pathnames} matching \VAR{path}.
1377 \IT{(\FU*{ENSURE-DIRECTORIES-EXIST} \VAR{path} \Op{\kwd{:verbose}
1378 \VAR{bool}})}
1380 Create parts of \retval{\VAR{path}} if necessary. Second return value is
1381 \retvalii{\T} if something has been created.
1384 \IT{(\MC*{WITH-OPEN-FILE} (\VAR{stream} \VAR{path}
1385 \OPn{\VAR{open-arg}}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
1386 \PROGN{\VAR{form}})}
1388 Use \FU{OPEN} with \VAR{open-arg}s (cf.\ page \pageref{open}) to
1389 temporarily create \VAR{stream} to \VAR{path}; return
1390 \retval{values of \VAR{form}s}.
1393 \end{LIST}
1397 % LocalWords: ies argumenth ar gu ment
1399 %%% Local Variables:
1400 %%% mode: latex
1401 %%% TeX-master: "clqr"
1402 %%% End: