defstruct entry reformatted.
[clqr.git] / clqr-input-output.tex
blobf83857ebca2ff2611bb9fc85cb62010088f17c76
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 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}}
403 {\index{\@{$\backslash$}}\index{{$"|$} {$"|$}}%
404 Treat arbitrary character(s) \VAR{c} as alphabetic preserving case.
407 \end{LIST}
410 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 \subsection{Printer}
412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415 \begin{LIST}{1cm}
417 \IT{(\xorGOO{\FU*{PRIN1}\\
418 \FU*{PRINT}\\
419 \FU*{PPRINT}\\
420 \FU*{PRINC}}{\}}
421 \VAR{foo} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
423 Print \VAR{foo} to \VAR{stream} \FU{read}ably,
424 \FU{read}ably between a newline and a space,
425 \FU{read}ably after a newline, or human-readably without any extra
426 characters, respectively. \FU{prin1}, \FU{print} and \FU{princ}
427 return \retval{\VAR{foo}}.
430 \IT{\arrGOO{(\FU*{PRIN1-TO-STRING} \VAR{ foo})\\
431 (\FU*{PRINC-TO-STRING} \VAR{ foo})}{.}}
433 Print \VAR{foo} to \retval{\VAR{string}} \FU{read}ably or
434 human-readably, respectively.
437 \IT{(\GFU*{PRINT-OBJECT} \VAR{object} \DES{\VAR{stream}})}
439 Print \retval{\VAR{object}} to \VAR{stream}. Called by the Lisp
440 printer.
443 \IT{(\MC*{PRINT-UNREADABLE-OBJECT} (\VAR{foo} \DES{\VAR{stream}}
444 \orGOO{\kwd{:type } \VAR{bool}\DF{\NIL}\\
445 \kwd{:identity } \VAR{bool}\DF{\NIL}}{\}})
446 \PROGN{\VAR{form}})}
448 Enclosed in \kwd{\#\boldmath$<$} and \kwd{\boldmath$>$}, print
449 \VAR{foo} by means of \VAR{form}s to \VAR{stream}. Return \retval{\NIL}.
452 \IT{(\FU*{TERPRI} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
454 Output a newline to \VAR{stream}. Return \retval{\NIL}.
457 \IT{(\FU*{FRESH-LINE})
458 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}}}
460 Output a newline to \VAR{stream} and return \retval{\T} unless \VAR{stream}
461 is already at the start of a line.
464 \IT{(\FU*{WRITE-CHAR} \VAR{char}
465 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
467 Output \retval{\VAR{char}} to \VAR{stream}.
470 \IT{(\xorGOO{\FU*{WRITE-STRING}\\
471 \FU*{WRITE-LINE}}{\}} \VAR{string}
472 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}
473 \OP{\orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\\kwd{:end} \VAR{
474 end}\DF{\NIL}}{\}}}})}
476 Write \retval{\VAR{string}} to \VAR{stream} without/with a trailing newline.
479 \IT{(\FU*{WRITE-BYTE} \VAR{byte} \DES{\VAR{stream}})}
481 Write \retval{\VAR{byte}} to binary \VAR{stream}.
484 \IT{(\FU*{WRITE-SEQUENCE} \VAR{sequence}
485 \DES{\VAR{stream}} \orGOO{\kwd{:start}\VAR{ start}\DF{\LIT{0}}\\
486 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
488 Write elements of \retval{\VAR{sequence}} to \VAR{stream}.
491 \IT{(\xorGOO{\FU*{WRITE}\\
492 \FU*{WRITE-TO-STRING}}{\}} \VAR{foo} \orGOO{%
493 \kwd{:array} \VAR{ bool}\\
494 \kwd{:base} \VAR{ radix}\\
495 \kwd{:case } \xorGOO{\kwd{:upcase}\\
496 \kwd{:downcase}\\
497 \kwd{:capitalize}}{.}\\
498 \kwd{:circle} \VAR{ bool}\\
499 \kwd{:escape} \VAR{ bool}\\
500 \kwd{:gensym} \VAR{ bool}\\
501 \kwd{:length } \Goo{\VAR{int}\XOR\NIL}\\
502 \kwd{:level } \Goo{\VAR{int}\XOR\NIL}\\
503 \kwd{:lines } \Goo{\VAR{int}\XOR\NIL}\\
504 \kwd{:miser-width } \Goo{\VAR{int}\XOR\NIL}\\
505 \kwd{:pprint-dispatch} \VAR{ dispatch-table}\\
506 \kwd{:pretty} \VAR{ bool}\\
507 \kwd{:radix} \VAR{ bool}\\
508 \kwd{:readably} \VAR{ bool}\\
509 \kwd{:right-margin } \Goo{\VAR{int}\XOR\NIL}\\
510 \kwd{:stream } \DES{\VAR{stream}}\DF{\V{\A standard-output\A}}%
511 }{\}})}
513 Print \VAR{foo} to \VAR{stream} and return \retval{\VAR{foo}}, or
514 print \VAR{foo} into \retval{string}, respectively, after
515 dynamically setting printer variables corresponding to keyword
516 parameters (\kwd{\A print-}\VAR{bar}\kwd{\A} becoming
517 \kwd{:}\VAR{bar}). (\kwd{:stream} keyword with \FU{write} only.)
520 \IT{\arrGOO{%
521 (\FU*{PPRINT-FILL } \DES{\VAR{stream}} \VAR{ foo }
522 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
523 (\FU*{PPRINT-TABULAR } \DES{\VAR{stream}} \VAR{ foo }
524 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop} \text{ }
525 \Op{\VAR{n}\DF{\LIT{16}}}}})\\
526 (\FU*{PPRINT-LINEAR } \DES{\VAR{stream}} \VAR{ foo }
527 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
528 }{.}}
530 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print as
531 many elements per line as possible; do the same in a table with
532 a column width of \VAR{n} ems; or print either all elements on
533 one line or each on its own line, respectively. Return
534 \retval{\NIL}. Usable with \FU{format} directive \KWD{\TLD//}.
537 \IT{(\MC*{PPRINT-LOGICAL-BLOCK} (\DES{\VAR{stream}} \VAR{list}
538 \orGOO{\xorGOO{\kwd{:prefix} \VAR{ string}\\
539 \kwd{:per-line-prefix} \VAR{ string}}{\}}\\
540 \kwd{:suffix} \VAR{ string}\DF{\LIT{""}}}{\}})
541 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
543 Evaluate \VAR{form}s, which should print \VAR{list}, with
544 \VAR{stream} locally bound to a pretty
545 printing stream which outputs to the original \VAR{stream}. If
546 \VAR{list} is in fact not a list, it is printed by
547 \FU{write}. Return \retval{\NIL}.
550 \begin{LIST}{.5cm}
552 \IT{(\MC*{PPRINT-POP})}
554 Take \retval{next element} off \VAR{list}. If there is no remaining
555 tail of \VAR{list}, or \V{\A print-length\A} or \V{\A print-circle\A} indicate
556 printing should end, send element together with an appropriate
557 indicator to \VAR{stream}.
560 \IT{(\FU*{PPRINT-TAB} \xorGOO{\kwd{:line}\\
561 \kwd{:line-relative}\\
562 \kwd{:section}\\
563 \kwd{:section-relative}}{\}} \VAR{c}
564 \VAR{i} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
566 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
567 as possible.
570 \IT{(\FU*{PPRINT-INDENT} \xorGOO{%
571 \kwd{:block}\\
572 \kwd{:current}}{\}} \VAR{n}
573 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
575 Specify indentation for innermost logical block relative to
576 leftmost position/to current position. Return \retval{\NIL}.
579 \IT{(\MC*{PPRINT-EXIT-IF-LIST-EXHAUSTED})}
581 If \VAR{list} is empty, terminate logical block. Return
582 \retval{\NIL} otherwise.
585 \end{LIST}
587 \IT{(\FU*{PPRINT-NEWLINE} \xorGOO{%
588 \kwd{:linear}\\
589 \kwd{:fill}\\
590 \kwd{:miser}\\
591 \kwd{:mandatory}}{\}}
592 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
594 Print a conditional newline if \VAR{stream} is a pretty printing
595 stream. Return \retval{\NIL}.
598 \IT{\V{\A print-array\A}}
599 {\index{*PRINT-ARRAY*@\A PRINT-ARRAY\A}
600 If \T, print arrays \FU{read}ably.
603 \IT{\V{\A print-base\A}\DF{\LIT{10}}}
604 {\index{*PRINT-BASE*@\A PRINT-BASE\A}
605 Radix for printing rationals, from 2 to 36.
608 \IT{\V{\A print-case\A}\DF{\kwd{:upcase}}}
609 {\index{*PRINT-CASE*@\A PRINT-CASE\A}
610 Print symbol names all uppercase (\kwd{:upcase}), all lowercase
611 (\kwd{:downcase}), capitalized (\kwd{:capitalize}).
614 \IT{\V{\A print-circle\A}\DF{\NIL}}
615 {\index{*PRINT-CIRCLE*@\A PRINT-CIRCLE\A}
616 If \T, avoid indefinite recursion while printing circular
617 structure.
620 \IT{\V{\A print-escape\A}\DF{\T}}
621 {\index{*PRINT-ESCAPE*@\A PRINT-ESCAPE\A}
622 If \NIL, do not print escape characters and package prefixes.
625 \IT{\V{\A print-gensym\A}\DF{\T}}
626 {\index{*PRINT-GENSYM*@\A PRINT-GENSYM\A}
627 If \T, print \kwd{\#:} before uninterned symbols.
630 \IT{\arrGOO{\V{\A print-length\A}\DF{\NIL}\\
631 \V{\A print-level\A}\DF{\NIL}\\
632 \V{\A print-lines\A}\DF{\NIL}
633 }{.}}
634 {\index{*PRINT-LENGTH*@\A PRINT-LENGTH\A}\index{*PRINT-LEVEL*@\A PRINT-LEVEL\A}\index{*PRINT-LINES*@\A PRINT-LINES\A}
635 If integer, restrict printing of objects to that number of
636 elements per level/to that depth/to that number of lines.
639 \IT{\V{\A print-miser-width\A}}
640 {\index{*PRINT-MISER-WIDTH*@\A PRINT-MISER-WIDTH\A}
641 If integer and greater than the width available for printing a
642 substructure, switch to the more compact miser style.
645 \IT{\V{\A print-pretty\A}}
646 {\index{*PRINT-PRETTY*@\A PRINT-PRETTY\A}
647 If \T, print pretty.
650 \IT{\V{\A print-radix\A}\DF{\NIL}}
651 {\index{*PRINT-RADIX*@\A PRINT-RADIX\A}
652 If \T, print rationals with a radix indicator.
655 \IT{\V{\A print-readably\A}\DF{\NIL}}
656 {\index{*PRINT-READABLY*@\A PRINT-READABLY\A}
657 If \T, print \FU{read}ably or signal error
658 \kwd{print-not-readable}.
661 \IT{\V{\A print-right-margin\A}\DF{\NIL}}
662 {\index{*PRINT-RIGHT-MARGIN*@\A PRINT-RIGHT-MARGIN\A}
663 Right margin width in ems while pretty-printing.
666 \IT{(\FU*{SET-PPRINT-DISPATCH} \VAR{type} \VAR{function}
667 \OP{\VAR{priority}\DF{\LIT{0}}
668 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}}})}
670 Install entry comprising \VAR{function} of arguments stream and
671 object to print; and \VAR{priority} as
672 \VAR{type} into \VAR{table}. If \VAR{function}
673 is \NIL, remove \VAR{type} from \VAR{table}. Return \retval{\NIL}.
676 \IT{(\FU*{PPRINT-DISPATCH} \VAR{foo}
677 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
679 Return highest priority \retval{\VAR{function}} associated with
680 type of \VAR{foo} and \retvalii{\T} if there was a matching type
681 specifier in \VAR{table}.
684 \IT{(\FU*{COPY-PPRINT-DISPATCH}
685 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
687 Return \retval{copy of \VAR{table}} or, if \VAR{table} is \NIL,
688 initial value of \V{\A print-pprint-dispatch\A}.
691 \IT{\V{\A print-pprint-dispatch\A}}
692 {\index{*PRINT-PPRINT-DISPATCH*@\A PRINT-PPRINT-DISPATCH\A}
693 Current pretty print dispatch table.
696 \end{LIST}
700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
701 \subsection{Format}
702 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
703 \label{section:Format}
705 \begin{LIST}{1cm}
707 \IT{(\MC*{FORMATTER} \NEV{\VAR{control}})}
709 Return \retval{function} of stream and a \kwd{\&rest} argument applying \FU{format} to
710 stream, \VAR{control}, and the \kwd{\&rest} argument
711 returning \NIL\ or any excess arguments.
714 \IT{(\FU*{FORMAT} \Goo{\T\XOR\NIL\XOR\VAR{out-string}\XOR\VAR{out-stream}}
715 \VAR{control} \OPn{\VAR{arg}})}
717 Output string \VAR{control} which may
718 contain \kwd{\TLD} directives possibly taking some
719 \VAR{arg}s. Alternatively, \VAR{control} can be a function returned
720 by \MC{formatter} which is then applied to \VAR{out-stream} and \OPn{\VAR{arg}}.
721 Output to \VAR{out-string}, \VAR{out-stream} or, if first
722 argument is \T, to \V{\A standard-output\A}. Return \retval{\NIL}. If
723 first argument is \NIL, return \retval{formatted output}.
726 \begin{LIST}{.5cm}
728 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}} \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
729 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
730 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
731 \KWD{\Op{:} \Op{@} \Goo{A\XOR S}}}
732 {\index{\~S@$\sim$S}\index{\~A@$\sim$A}%
733 \EM{Aesthetic/Standard. }
734 Print argument of any type for consumption by humans/by the
735 reader, respectively. With \kwd{:}, print \NIL\ as \LIT{()} rather
736 than \LIT{nil}; with \kwd{@}, add \VAR{pad-char}s on the left
737 rather than on the right.
740 \IT{\KWD{\TLD} \Op{\VAR{radix}\DF{\LIT{10}}} \OP{\KWD{,}\Op{\VAR{width}}
741 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
742 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
743 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}}
744 \KWD{\Op{:} \Op{@} R}}
745 {\index{\~R@$\sim$R}%
746 \EM{Radix. }
747 (With one or more prefix arguments.) Print argument as number; with
748 \KWD{:}, group digits \VAR{comma-interval} each; with \kwd{@},
749 always prepend a sign.
752 \IT{\Goo{\KWD{\TLD R}\XOR\KWD{\TLD :R}\XOR\KWD{\TLD
753 @R}\XOR\KWD{\TLD @:R}}}
755 \EM{Roman. }
756 Take argument as number and print it as English cardinal number,
757 as English ordinal number, as Roman numeral, or as old Roman
758 numeral, respectively.
761 \IT{\KWD{\TLD} \Op{\VAR{width}}
762 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
763 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
764 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}
765 \KWD{\Op{:} \Op{@} \Goo{D\XOR B\XOR O\XOR X}}}
766 {\index{\~D@$\sim$D}\index{\~B@$\sim$B}\index{\~O@$\sim$O}\index{\~X@$\sim$X}%
767 \EM{Decimal/Binary/Octal/Hexadecimal. }
768 Print integer argument as number. With \kwd{:}, group digits
769 \VAR{comma-interval} each; with \kwd{@}, always prepend a sign.
772 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{dec-digits}}
773 \OP{\KWD{,}\Op{\VAR{shift}\DF{\LIT{0}}}
774 \OP{\KWD{,}\Op{\VAR{overflow-char}}
775 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}}
776 \KWD{\Op{@} F}}
777 {\index{\~F@$\sim$F}%
778 \EM{Fixed-Format Floating-Point. } With
779 \kwd{@}, always pre\-pend a sign.
782 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{int-digits}}
783 \OP{\KWD{,}\Op{\VAR{exp-digits}}
784 \OP{\KWD{,}\Op{\VAR{scale-factor}\DF{\LIT{1}}}
785 \OP{\KWD{,}\Op{\VAR{overflow-char}}
786 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
787 \OP{\KWD{,}\VAR{exp-char}}}}}}}
788 \KWD{\Op{@} \Goo{E\XOR G}}}
789 {\index{\~E@$\sim$E}\index{\~G@$\sim$G}%
790 \EM{Exponential/General Floating-Point. }
791 Print argument as floating-point number with \VAR{int-digits}
792 before decimal point and \VAR{exp-digits} in the signed
793 exponent. With \KWD{\TLD G}, choose either \KWD{\TLD E} or
794 \KWD{\TLD F}. With \KWD{@}, always prepend a sign.
797 \IT{\KWD{\TLD} \Op{\VAR{dec-digits}\DF{\LIT{2}}}
798 \OP{\KWD{,}\Op{\VAR{int-digits}\DF{\LIT{1}}}
799 \OP{\KWD{,}\Op{\VAR{width}\DF{\LIT{0}}}
800 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
801 \Op{\KWD{:}} \Op{\kwd{@}} \KWD{\$}}
802 {\index{\~\$@$\sim$\$}%
803 \EM{Monetary Floating-Point. }
804 Print argument as fixed-format floating-point number. With \KWD{:},
805 put sign before any padding; with \KWD{@}, always prepend a sign.}
807 \IT{\Goo{\KWD{\TLD C}\XOR\KWD{\TLD :C}\XOR\KWD{\TLD
808 @C}\XOR\KWD{\TLD @:C}}}
809 {\index{\~C@$\sim$C}%
810 \EM{Character. }
811 Print, spell out, print in \kwd{\#$\backslash$} syntax, or tell
812 how to type, respectively, argument as (possibly non-printing)
813 character.
816 \IT{\Goo{%
817 \KWD{\TLD(} \VAR{text} \KWD{\TLD)}\XOR
818 \KWD{\TLD:(} \VAR{text} \KWD{\TLD)}\XOR
819 \KWD{\TLD @(} \VAR{text} \KWD{\TLD)}\XOR
820 \KWD{\TLD:@(} \VAR{text} \KWD{\TLD)}}}
821 {\index{\~(\~)@$\sim$( $\sim$)}%
822 \EM{Case-Conversion. }
823 Convert \VAR{text} to lowercase, convert first letter of each word
824 to uppercase, capitalize first word and convert the rest to
825 lowercase, or convert to uppercase, respectively.
828 \IT{\Goo{\KWD{\TLD P}\XOR\KWD{\TLD:P}
829 \XOR\KWD{\TLD @P}\XOR\KWD{\TLD:@P}}}
830 {\index{\~P@$\sim$P}%
831 \EM{Plural. }
832 If argument \kwd{eql} \LIT{1} print nothing, otherwise print \LIT{s};
833 do the same for the previous argument; if argument \kwd{eql} \LIT{1}
834 print \LIT{y}, otherwise print \LIT{ies}; do the same for the
835 previous argument, respectively.
838 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\%}}
839 {\index{\~\%@$\sim$\%}%
840 \EM{Newline. }
841 Print \VAR{n} newlines.
844 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\&}}
845 {\index{\~\&@$\sim$\&}%
846 \EM{Fresh-Line. }
847 Print $n-1$ newlines if output stream is at the
848 beginning of a line, or \VAR{n} newlines otherwise.
851 \IT{\Goo{\KWD{\TLD\_}\XOR\KWD{\TLD:\_}\XOR\KWD{\TLD@\_}\XOR\KWD{\TLD:@\_}}}
852 {\index{\~\_{}@$\sim$\_{}}%
853 \EM{Conditional Newline. }
854 Print a newline like \kwd{pprint-newline} with argument
855 \kwd{:linear}, \kwd{:fill}, \kwd{:miser}, or \kwd{:mandatory}, respectively.
858 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} $\hookleftarrow$}
860 \EM{Ignored Newline. } Ignore newline and following
861 whitespace. With \kwd{:}, ignore only newline; with \kwd{@},
862 ignore only following whitespace.
865 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\boldmath$|$}}
866 {\index{\~\textbar@$\sim${$"|$}}%
867 \EM{Page. }
868 Print \VAR{n} page separators.
871 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\TLD}}
872 {\index{\~\~@$\sim$$\sim$}%
873 \EM{Tilde. }
874 Print \VAR{n} tildes.
877 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}}
878 \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
879 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
880 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
881 \KWD{\Op{:} \Op{@} \boldmath{$<$}}
882 \OP{\VAR{nl-text} \KWD{\TLD}\Op{\VAR{spare}\DF{\LIT{0}} \Op{,\VAR{width}}}\kwd{:;}}
883 \Goos{\VAR{text}\KWD{\TLD;}} \VAR{text} \KWD{\TLD\boldmath{$>$}}}
884 {\index{\~<\~>@$\sim$$<$ $\sim$$>$}%
885 \EM{Justification. }
886 Justify text produced by \VAR{text}s in a field of at least
887 \VAR{min-col} columns. With \kwd{:}, right justify; with \kwd{@},
888 left justify. If this would leave less than \VAR{spare} characters
889 on the current line, output \VAR{nl-text} first.
892 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{\boldmath{$<$}}
893 \GOo{\Op{\VAR{prefix}\DF{\LIT{""}}
894 \KWD{\TLD;}}\XOR\Op{\VAR{per-line-prefix}
895 \KWD{\TLD@;}}}
896 \VAR{body} \OP{\KWD{\TLD;} \VAR{suffix}\DF{\LIT{""}}}
897 \KWD{\TLD:} \Op{\KWD{@}} \KWD{\boldmath{$>$}}}
898 {\index{\~<\~:>@$\sim$$<$ $\sim$:$>$}%
899 \EM{Logical Block. }
900 Act like \kwd{pprint-logical-block} using \VAR{body} as \FU{format}
901 control string on the elements of the list argument or, with \KWD{@},
902 on the remaining arguments, which are extracted by
903 \kwd{pprint-pop}. With \KWD{:}, \VAR{prefix} and \VAR{suffix}
904 default to \LIT{(} and \LIT{)}. When closed by
905 \KWD{\TLD:@\boldmath{$>$}}, spaces in \VAR{body} are replaced with
906 conditional newlines.
909 \IT{\Goo{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}}
910 \kwd{I}\XOR\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \kwd{:I}}}
911 {\index{\~I@$\sim$I}%
912 \EM{Indent. }
913 Set indentation to \VAR{n} relative to leftmost/to current
914 position.
917 \IT{\KWD{\TLD} \Op{\VAR{c}\DF{\LIT{1}}}
918 \Op{\KWD{,}\VAR{i}\DF{\LIT{1}}} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{T}}
919 {\index{\~T@$\sim$T}%
920 \EM{Tabulate. }
921 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
922 as possible. With \kwd{:}, calculate column numbers relative to
923 the immediately enclosing section. With \kwd{@}, move to column
924 number $c_0 + c + ki$ where $c_0$ is the current position.
927 \IT{\Goo{%
928 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{\A}\XOR
929 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{:}\KWD{\A}\XOR
930 \KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \KWD{@}\KWD{\A}}}
931 {\index{\~*@$\sim$\A}%
932 \EM{Go-To. }
933 Jump \VAR{m} arguments forward, or backward, or to argument \VAR{n}.
936 \IT{\KWD{\TLD} \Op{\VAR{limit}} \Op{\KWD{{:}}} \Op{\kwd{@}}
937 \KWD{\boldmath{$\{$}} \VAR{text} \KWD{\TLD\boldmath{$\}$}}}
938 {\index{\~\{\~\}@$\sim$$\{$ $\sim\}$}%
939 \EM{Iteration. }
940 Use \VAR{text} repeatedly, up to \VAR{limit}, as control
941 string for the elements of the list argument or (with
942 \kwd{@}) for the remaining arguments. With \kwd{:} or \kwd{:@},
943 list elements or remaining arguments should be
944 lists of which a new one is used at each iteration step.
947 \IT{\KWD{\TLD} \OP{\VAR{x} \OP{\kwd{,} \VAR{y} \Op{\kwd{,} \VAR{z}}}}
948 \KWD{\^{}}}
949 {\index{\~\^{}@$\sim$\^{}}%
950 \EM{Escape Upward. }
951 Leave immediately \kwd{\TLD\boldmath{$<$} \TLD\boldmath{$>$}},
952 \kwd{\TLD\boldmath{$<$} \TLD:\boldmath{$>$}},
953 \kwd{\TLD\boldmath{$\{$} \TLD\boldmath{$\}$}}, \kwd{\TLD?}, or the
954 entire \FU{format} operation. With one to three prefixes, act only
955 if $x=0$, $x=y$, or $x\leq y \leq z$, respectively.
958 \IT{\KWD{\TLD} \Op{\VAR{i}} \Op{\KWD{:}} \Op{\KWD{@}}
959 \KWD{[} \Op{\Goos{\VAR{text} \KWD{\TLD;}} \VAR{text}}
960 \Op{\kwd{\TLD:;} \VAR{default}} \KWD{\TLD]}}
961 {\index{\~[\~]@$\sim$[ $\sim$]}%
962 \EM{Conditional Expression. }
963 Use the zero-indexed argumenth (or
964 \VAR{i}th if given) \VAR{text} as a \FU{format} control subclause.
965 With \kwd{:}, use the first \VAR{text} if the argument value is
966 \NIL, or the second \VAR{text} if it is \T. With \kwd{@}, do nothing
967 for an argument value of \NIL. Use the only \VAR{text} and leave
968 the argument to be read again if it is \T.
971 \IT{\KWD{\TLD} \Op{\KWD{@}} \KWD{?}}
972 {\index{\~?@$\sim$?}%
973 \EM{Recursive Processing. }
974 Process two arguments as control string and argument list. With
975 \kwd{@}, take one argument as control string and use then the
976 rest of the original arguments.
979 \IT{\KWD{\TLD} \OP{\VAR{prefix}\Goos{\kwd{,}
980 \VAR{prefix}}} \Op{\kwd{:}} \Op{\kwd{@}} \KWD{/}\VAR{function}\KWD{/}}
981 {\index{\~/ /@$\sim$/ /}%
982 \EM{Call Function. }
983 Call \VAR{function} with the arguments stream, format-ar\-gu\-ment,
984 colon-p, at-sign-p and \VAR{prefix}es for printing format-argument.
987 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{W}}
988 {\index{\~W@$\sim$W}%
989 \EM{Write. }
990 Print argument of any type obeying every printer control variable. With \kwd{:},
991 pretty-print. With \kwd{@}, print without limits on length or depth.
994 \IT{\Goo{\KWD{V}\XOR\KWD{\#}}}
995 {\index{V}\index{\#}
996 In place of the comma-separated prefix parameters: use next
997 argument or number of remaining unprocessed arguments, respectively.
1000 \end{LIST}
1002 \end{LIST}
1005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 \subsection{Streams}
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009 \begin{LIST}{1cm}
1011 \IT{(\FU*{OPEN} \VAR{path}
1012 \orGOO{\kwd{:direction } \xorGOO{\kwd{:input}\\
1013 \kwd{:output}\\
1014 \kwd{:io}\\
1015 \kwd{:probe}}{\}}\DF{\kwd{:input}}\\
1016 \kwd{:element-type} \VAR{ type}\DF{\kwd{character}}\\
1017 \kwd{:if-exists }
1018 \xorGOO{\kwd{:new-version}\\
1019 \kwd{:error}\\
1020 \kwd{:rename}\\
1021 \kwd{:rename-and-delete}\\
1022 \kwd{:overwrite}\\
1023 \kwd{:append}\\
1024 \kwd{:supersede}\\
1025 \NIL}{.}\\
1026 \kwd{:if-does-not-exist } \xorGOO{\kwd{:error}\\
1027 \kwd{:create}\\
1028 \NIL}{.}\\
1029 \kwd{:external-format } \VAR{format}\DF{\kwd{:default}}%
1030 }{\}})}
1031 {\label{open}
1032 Open \retval{\kwd{file-stream} to \VAR{path}}.
1035 \IT{\arrGOO{%
1036 (\FU*{MAKE-CONCATENATED-STREAM } \OPn{\VAR{input-stream}})\\
1037 (\FU*{MAKE-BROADCAST-STREAM } \OPn{\VAR{output-stream}})\\
1038 (\FU*{MAKE-TWO-WAY-STREAM } \VAR{input-stream-part } \VAR{output-stream-part})\\
1039 (\FU*{MAKE-ECHO-STREAM } \VAR{from-input-stream } \VAR{to-output-stream})\\
1040 (\FU*{MAKE-SYNONYM-STREAM } \VAR{variable-bound-to-stream})}{.}}
1042 Return \retval{stream} of indicated type.
1045 \IT{(\FU*{MAKE-STRING-INPUT-STREAM} \VAR{string}
1046 \OP{\VAR{start}\DF{\LIT{0}}
1047 \Op{\VAR{end}\DF{\NIL}}})}
1049 Return a \retval{\kwd{string-stream}} supplying the characters from \VAR{string}.
1052 \IT{(\FU*{MAKE-STRING-OUTPUT-STREAM} \Op{\kwd{:element-type}
1053 \VAR{type}\DF{\kwd{character}}})}
1055 Return a \retval{\kwd{string-stream}} accepting characters
1056 (available via \FU{get-output-stream-string}).
1059 \IT{\arrGOO{(\FU*{CONCATENATED-STREAM-STREAMS } \VAR{concatenated-stream})\\
1060 (\FU*{BROADCAST-STREAM-STREAMS } \VAR{broadcast-stream})}{.}}
1062 Return \retval{list of streams} \VAR{concatenated-stream} still
1063 has to read from/\VAR{broadcast-stream} is
1064 broadcasting to.
1067 \IT{\arrGOO{%
1068 (\FU*{TWO-WAY-STREAM-INPUT-STREAM} \VAR{ two-way-stream})\\
1069 (\FU*{TWO-WAY-STREAM-OUTPUT-STREAM} \VAR{ two-way-stream})\\
1070 (\FU*{ECHO-STREAM-INPUT-STREAM} \VAR{ echo-stream})\\
1071 (\FU*{ECHO-STREAM-OUTPUT-STREAM} \VAR{ echo-stream})}{.}}
1073 Return \retval{source stream} or \retval{sink stream} of
1074 \VAR{two-way-stream}\slash\VAR{echo-stream}, respectively.
1077 \IT{(\FU*{SYNONYM-STREAM-SYMBOL} \VAR{synonym-stream})}
1079 Return \retval{symbol} of \VAR{synonym-stream}.
1082 \IT{(\FU*{GET-OUTPUT-STREAM-STRING} \DES{\VAR{string-stream}})}
1084 Clear and return as a \retval{string} characters on \VAR{string-stream}.
1087 \IT{(\FU*{LISTEN} \Op{\VAR{stream}\DF{\V{\A standard-input\A}}})}
1089 \retval{\T} if there is a character in input \VAR{stream}.
1092 \IT{(\FU*{CLEAR-INPUT}
1093 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}})}
1095 Clear input from \VAR{stream}, return \retval{\NIL}.
1098 \IT{(\xorGOO{\FU*{CLEAR-OUTPUT}\\
1099 \FU*{FORCE-OUTPUT}\\
1100 \FU*{FINISH-OUTPUT}}{\}}
1101 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
1103 End output to \VAR{stream} and return \retval{\NIL} immediately,
1104 after initiating flushing of buffers, or after flushing of buffers,
1105 respectively.
1108 \IT{(\FU*{CLOSE} \DES{\VAR{stream}} \Op{\kwd{:abort}
1109 \VAR{bool}\DF{\NIL}})}
1111 Close \VAR{stream}. Return \retval{\T} if \VAR{stream} had been
1112 open. If \kwd{:abort} is \T, delete associated file.
1115 \IT{(\MC*{WITH-OPEN-STREAM} (\VAR{foo} \DES{\VAR{stream}})
1116 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1118 Evaluate \VAR{form}s with \VAR{foo} locally bound to
1119 \VAR{stream}. Return \retval{values of \VAR{form}s}.
1122 \IT{(\MC*{WITH-INPUT-FROM-STRING} (\VAR{foo} \VAR{string}
1123 \orGOO{\kwd{:index } \DES{\VAR{index}}\\
1124 \kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1125 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}}) \OPn{(\kwd{declare}
1126 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1128 Evaluate \VAR{form}s with \VAR{foo} locally bound to input \kwd{string-stream}
1129 from \VAR{string}. Return \retval{values of \VAR{form}s}; store next
1130 reading position into \VAR{index}.
1133 \IT{(\MC*{WITH-OUTPUT-TO-STRING} (\VAR{foo}
1134 \Op{\DES{\VAR{string}}\DF{\NIL}} \Op{\kwd{:element-type}
1135 \VAR{type}\DF{\kwd{character}}}) \OPn{(\kwd{declare}
1136 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1138 Evaluate \VAR{form}s with \VAR{foo} locally bound to an output
1139 \kwd{string-stream}. Append output to \VAR{string} and return
1140 \retval{values of \VAR{form}s} if \VAR{string} is given. Return
1141 \retval{string containing output} otherwise.
1144 \IT{(\FU*{STREAM-EXTERNAL-FORMAT} \VAR{stream})}
1146 \retval{External file format designator}.
1149 \IT{\V{\A terminal-io\A}}
1150 {\index{*TERMINAL-IO*@\A TERMINAL-IO\A}
1151 Bidirectional stream to user terminal.
1154 \IT{\arrGOO{\V{\A standard-input\A}\\
1155 \V{\A standard-output\A}\\
1156 \V{\A error-output\A}}{.}}
1157 {\index{*STANDARD-INPUT*@\A STANDARD-INPUT\A}%
1158 \index{*STANDARD-OUTPUT*@\A STANDARD-OUTPUT\A}%
1159 \index{*ERROR-OUTPUT*@\A ERROR-OUTPUT\A}
1160 Standard input stream, standard output stream,
1161 or standard error output stream, respectively.
1164 \IT{\arrGOO{\V{\A debug-io\A}\\
1165 \V{\A query-io\A}}{.}}
1166 {\index{*DEBUG-IO*@\A DEBUG-IO\A}\index{*QUERY-IO*@\A QUERY-IO\A}
1167 Bidirectional streams for debugging and user interaction.
1170 \end{LIST}
1173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1174 \subsection{Files}
1175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1177 \begin{LIST}{1cm}
1179 \IT{(\FU*{MAKE-PATHNAME}
1180 \orGOO{\kwd{:host } \Goo{\VAR{host}\XOR\NIL\XOR\kwd{:unspecific}}\\
1181 \kwd{:device } \Goo{\VAR{device}\XOR\NIL\XOR\kwd{:unspecific}}\\
1182 \kwd{:directory } \xorGOO{%
1183 \Goo{\VAR{directory}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1184 (\xorGOO{%
1185 \kwd{:absolute}\\
1186 \kwd{:relative}
1187 }{\}}\text{ }%
1188 \xorGOO{%
1189 \VAR{directory}\\
1190 \kwd{:wild}\\
1191 \kwd{:wild-inferiors}\\
1192 \kwd{:up}\\
1193 \kwd{:back}
1194 }{\}^{\!\!*}})
1195 }{.}\\
1196 \kwd{:name } \Goo{\VAR{file-name}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1197 \kwd{:type } \Goo{\VAR{file-type}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1198 \kwd{:version } \Goo{\kwd{:newest}\XOR\VAR{version}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1199 \kwd{:defaults } \VAR{path}\DF{host from \V{\A default-pathname-defaults\A}}\\
1200 \kwd{:case
1201 \Goo{\kwd{:local}\XOR\kwd{:common}}\DF{\kwd{:local}}}}{\}})}
1203 Construct \retval{pathname}.
1204 For \kwd{:case :local}, leave case of components unchanged.
1205 For \kwd{:case :common}, leave mixed-case components unchanged;
1206 convert all-uppercase components into
1207 local customary case; do the opposite with all-lowercase
1208 components.
1211 \IT{\arrGOO{%
1212 (\xorGOO{\FU*{PATHNAME-HOST}\\
1213 \FU*{PATHNAME-DEVICE}\\
1214 \FU*{PATHNAME-DIRECTORY}\\
1215 \FU*{PATHNAME-NAME}\\
1216 \FU*{PATHNAME-TYPE}}{\}}
1217 \VAR{ path }
1218 \Op{\kwd{:case } \xorGOO{\kwd{:local}\\
1219 \kwd{:common}}{\}}\DF{\kwd{:local}}})\\
1220 (\FU*{PATHNAME-VERSION } \VAR{path})}{.}}
1222 Return \retval{pathname component}.
1225 \IT{(\FU*{PARSE-NAMESTRING} \VAR{foo}
1226 \OP{\VAR{host}
1227 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1228 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1229 \kwd{:end} \VAR{ end}\DF{\NIL}\\
1230 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}}}})}
1232 Return \retval{pathname} converted from
1233 string, pathname, or stream \VAR{foo}; and \retvalii{position}
1234 where parsing stopped.
1237 \IT{(\FU*{MERGE-PATHNAMES} \VAR{pathname}
1238 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1239 \Op{\VAR{default-version}\DF{\kwd{:newest}}}})}
1241 Return \retval{\VAR{pathname}} after filling in missing components
1242 from \VAR{default-pathname}.
1245 \IT{\V{\A default-pathname-defaults\A}}
1246 {\index{*DEFAULT-PATHNAME-DEFAULTS*@\A DEFAULT-PATHNAME-DEFAULTS\A}
1247 Pathname to use if one is needed and none supplied.
1250 \IT{(\FU*{USER-HOMEDIR-PATHNAME} \Op{\VAR{host}})}
1252 User's \retval{home directory}.
1255 \IT{(\FU*{ENOUGH-NAMESTRING} \VAR{path}
1256 \Op{\VAR{root-path}\DF{\V{\A default-pathname-defaults\A}}})}
1258 Return \retval{minimal path string} to sufficiently describe
1259 \VAR{path} relative to \VAR{root-path.}
1262 \IT{\arrGOO{(\FU*{NAMESTRING}\VAR{ path})\\
1263 (\FU*{FILE-NAMESTRING}\VAR{ path})\\
1264 (\FU*{DIRECTORY-NAMESTRING}\VAR{ path})\\
1265 (\FU*{HOST-NAMESTRING}\VAR{ path})}{.}}
1267 Return string representing \retval{full pathname}; \retval{name,
1268 type, and version}; \retval{directory name}; or \retval{host
1269 name}, respectively, of \VAR{path}.
1272 \IT{(\FU*{TRANSLATE-PATHNAME} \VAR{path} \VAR{wildcard-path-a}
1273 \VAR{wildcard-path-b})}
1275 Translate \VAR{path} from \VAR{wildcard-path-a} into
1276 \VAR{wildcard-path-b}. Return \retval{new path}.
1279 \IT{(\FU*{PATHNAME} \VAR{path})}
1281 \retval{Pathname} of \VAR{path}.
1284 \IT{(\FU*{LOGICAL-PATHNAME} \VAR{logical-path})}
1286 \retval{Logical pathname} of \VAR{logical-path}.
1287 Logical pathnames are represented as all-uppercase
1288 \LIT{\#P"}%
1289 \Op{\VAR{host}\LIT{:}}\Op{\LIT{:}}%
1290 \Goos{\xorGOO{%
1291 \Goop{\VAR{dir}\XOR\LIT{*}}\\
1292 \LIT{**}}{\}}\LIT{;}}%
1293 \penalty-5
1294 \Goos{\VAR{name}\XOR\LIT{*}}%
1295 \OP{\LIT{.}%
1296 \xorGOO{%
1297 \Goop{\VAR{type}\XOR\LIT{*}}\\
1298 \LIT{LISP}}{\}}%
1299 \Op{\LIT{.}%
1300 \Goo{%
1301 \VAR{version}\XOR\LIT{*}\XOR\LIT{newest}\XOR\LIT{NEWEST}}}}%
1302 \LIT{"}.
1305 \IT{(\FU*{LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1307 \retval{List of (\VAR{from-wildcard to-wildcard}) translations}
1308 for \VAR{logical-host}. \kwd{setf}able.
1311 \IT{(\FU*{LOAD-LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1313 Load \VAR{logical-host}'s translations. Return \retval{\NIL} if already
1314 loaded; return \retval{\T} if successful.
1317 \IT{(\FU*{TRANSLATE-LOGICAL-PATHNAME} \VAR{pathname})}
1319 \retval{Physical pathname} corresponding to (possibly logical)
1320 \VAR{pathname}.
1323 \IT{\arrGOO{(\FU*{PROBE-FILE} \VAR{ file})\\
1324 (\FU*{TRUENAME} \VAR{ file})}{.}}
1326 \retval{Canonical name} of \VAR{file}. If \VAR{file} does not exist,
1327 return \retval{\NIL}/signal \kwd{file-error}, respectively.
1330 \IT{(\FU*{FILE-WRITE-DATE} \VAR{file})}
1332 \retval{Time} at which \VAR{file} was last written.
1335 \IT{(\FU*{FILE-AUTHOR} \VAR{file})\qquad\qquad}
1337 Return \retval{name of \VAR{file} owner}.
1340 \IT{(\FU*{FILE-LENGTH} \VAR{stream})}
1342 Return \retval{length of \VAR{stream}}.
1345 \IT{(\FU*{FILE-POSITION} \VAR{stream} \Op{\xorGOO{\kwd{:start}\\
1346 \kwd{:end}\\
1347 \VAR{position}}{\}}})}
1349 Return \retval{position within stream}, or set it to
1350 \retval{\VAR{position}} and return \retval{\T} on success.
1353 \IT{(\FU*{FILE-STRING-LENGTH} \VAR{stream} \VAR{foo})}
1355 \retval{Length} \VAR{foo} would have in \VAR{stream}.
1358 \IT{(\FU*{RENAME-FILE} \VAR{foo} \VAR{bar})}
1360 Rename file \VAR{foo} to \VAR{bar}. Unspecified components of path
1361 \VAR{bar} default to those of \VAR{foo}. Return \retval{new
1362 pathname}, \retvalii{old physical file name}, and \retvaliii{new
1363 physical file name}.
1366 \IT{(\FU*{DELETE-FILE} \VAR{file})}
1368 Delete \VAR{file}. Return \retval{\T}.
1371 \IT{(\FU*{DIRECTORY} \VAR{path})}
1373 \retval{List of pathnames} matching \VAR{path}.
1376 \IT{(\FU*{ENSURE-DIRECTORIES-EXIST} \VAR{path} \Op{\kwd{:verbose}
1377 \VAR{bool}})}
1379 Create parts of \retval{\VAR{path}} if necessary. Second return value is
1380 \retvalii{\T} if something has been created.
1383 \IT{(\MC*{WITH-OPEN-FILE} (\VAR{stream} \VAR{path}
1384 \OPn{\VAR{open-arg}}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
1385 \PROGN{\VAR{form}})}
1387 Use \FU{OPEN} with \VAR{open-arg}s (cf.\ page \pageref{open}) to
1388 temporarily create \VAR{stream} to \VAR{path}; return
1389 \retval{values of \VAR{form}s}.
1392 \end{LIST}
1396 % LocalWords: ies argumenth ar gu ment
1398 %%% Local Variables:
1399 %%% mode: latex
1400 %%% TeX-master: "clqr"
1401 %%% End: