Tilde-newline entry changed.
[clqr.git] / clqr-input-output.tex
blobb754c6fe8fe2caf373134c7e39988087a3a3c669
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 binary or character \VAR{stream}. Return
158 \retval{index} of \VAR{sequence}'s first unmodified element.
161 \IT{(\FU*{READTABLE-CASE} \VAR{readtable})\DF{\kwd{:upcase}}}
163 \retval{Case sensitivity attribute} (one of \kwd{:upcase},
164 \kwd{:downcase}, \kwd{:preserve}, \kwd{:invert}) of
165 \VAR{readtable}. \kwd{setf}able.
168 \IT{(\FU*{COPY-READTABLE} \OP{\VAR{from-readtable}\DF{\V{\A readtable\A}}
169 \Op{\DES{\VAR{to-readtable}}\DF{\NIL}}})}
171 Return \retval{copy of \VAR{from-readtable}}.
174 \IT{(\FU*{SET-SYNTAX-FROM-CHAR} \VAR{to-char} \VAR{from-char}
175 \OP{\DES{\VAR{to-readtable}}\DF{\V{\A readtable\A}}
176 \Op{\VAR{from-readtable}\DF{standard readtable}}})}
178 Copy syntax of \VAR{from-char} to \VAR{to-readtable}. Return \retval{\T}.
181 \IT{\V{\A readtable\A}}
182 {\index{*READTABLE*@\A READTABLE\A}
183 Current readtable.
186 \IT{\V{\A read-base\A}\DF{\LIT{10}}}
187 {\index{*READ-BASE*@\A READ-BASE\A}
188 Radix for reading \kwd{integer}s and \kwd{ratio}s.
191 \IT{\V{\A read-default-float-format\A}\DF{\kwd{single-float}}}
192 {\index{*READ-DEFAULT-FLOAT-FORMAT*@\A READ-DEFAULT-FLOAT-FORMAT\A}
193 Floating point format to use when not indicated in the number read.
196 \IT{\V{\A read-suppress\A}\DF{\NIL}}
197 {\index{*READ-SUPPRESS*@\A READ-SUPPRESS\A}
198 If \T, reader is syntactically more tolerant.
201 \IT{(\FU*{SET-MACRO-CHARACTER} \VAR{char} \VAR{function}
202 \OP{\VAR{non-term-p}\DF{\NIL}
203 \Op{\DES{\VAR{rt}}\DF{\V{\A readtable\A}}}})}
205 Make \VAR{char} a macro character associated with
206 \VAR{function} of stream and \VAR{char}. Return \retval{\T}.
209 \IT{(\FU*{GET-MACRO-CHARACTER} \VAR{char}
210 \Op{\VAR{rt}\DF{\V{\A readtable\A}}})}
212 \retval{Reader macro function} associated with \VAR{char}, and
213 \retvalii{\T} if \VAR{char} is a non-terminating macro character.
216 \IT{(\FU*{MAKE-DISPATCH-MACRO-CHARACTER} \VAR{char}
217 \OP{\VAR{non-term-p}\DF{\NIL}
218 \Op{\VAR{rt}\DF{\V{\A readtable\A}}}})}
220 Make \VAR{char} a dispatching macro character. Return \retval{\T}.
223 \IT{(\FU*{SET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char}
224 \VAR{function}
225 \Op{\DES{\VAR{rt}}\DF{\V{\A readtable\A}}})}
227 Make \VAR{function} of stream, \VAR{n}, \VAR{sub-char} a dispatch
228 function of \VAR{char} followed by \VAR{n}, followed by
229 \VAR{sub-char}. Return \retval{\T}.
232 \IT{(\FU*{GET-DISPATCH-MACRO-CHARACTER} \VAR{char} \VAR{sub-char}
233 \Op{\VAR{rt}\DF{\V{\A readtable\A}}})}
235 \retval{Dispatch function} associated with \VAR{char} followed by
236 \VAR{sub-char}.
239 \end{LIST}
241 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
242 \subsection{Character Syntax}
243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
245 \begin{LIST}{1cm}
247 \IT{\arrGOO{%
248 \KWD{\#\boldmath$|$ }\OPn{\VAR{multi-line-comment}}\KWD{ \boldmath$|$\#}\\
249 \KWD*{; }\OPn{\VAR{one-line-comment}}}{.}}
250 {\index{\#{$"|$} {$"|$}\#}
251 Comments. There are conventions:
253 \begin{LIST}{.5cm}
254 \IT{\KWD{;;;;} \VAR{title}\qquad\qquad}
255 {Short title for a block of code.}
257 \IT{\KWD{;;;} \VAR{intro}\qquad\qquad}
258 {Description before a block of code.}
260 \IT{\KWD{;;} \VAR{state}\qquad\qquad}
261 {State of program or of following code.}
263 \IT{\KWD{;} \VAR{explanation}}
264 {Regarding line on which it appears.}
266 \end{LIST}
268 \IT{\KWD*{(}\OPn{\VAR{foo}}\Op{ \KWD*{.} \VAR{bar}\DF{\NIL}}\KWD*{)}}
270 List of \VAR{foo}s with the terminating cdr \VAR{bar}.
273 \IT{\KWD{"}\qquad\qquad}
274 {\index{""}
275 Begin and end of a string.
278 \IT{\KWD*{'}\VAR{foo}\quad\qquad}
280 (\SO*{quote} \VAR{foo}); \VAR{foo} unevaluated.
283 \IT{\KWD{\char18}(\Op{\VAR{foo}} \Op{\KWD*{,}\VAR{bar}} \Op{\KWD{,@}\VAR{baz}}
284 \Op{\KWD*{,.}\DES{\VAR{quux}}} \Op{\VAR{bing}})}
285 {\index{,"@}\index{`@\char18}
286 Backquote. \SO{quote} \VAR{foo} and \VAR{bing}; evaluate \VAR{bar}
287 and splice the lists \VAR{baz} and \VAR{quux} into their
288 elements. When nested, outermost commas inside the innermost
289 backquote expression belong to this backquote.
292 \IT{\KWD{\#\boldmath{$\backslash$}}\VAR{c}}
294 (\FU*{character} \LIT{"}\VAR{c}\LIT{"}), the character \VAR{c}.
296 \index{\#@\#$\backslash$}%
298 \IT{\KWD*{\#b}\VAR{n}; \KWD*{\#o}\VAR{n}; \VAR{n}\kwd{.};
299 \KWD*{\#x}\VAR{n}; \KWD{\#}\VAR{r}\KWD{R}\VAR{n}}
300 {\index{\#R}%
301 Integer of radix 2, 8, 10, 16, or \VAR{r}; $2\le r \le 36$.
304 \IT{\VAR{n}\kwd*{/}\VAR{d}\quad\qquad}
306 The \kwd*{ratio} $\frac{n}{d}$.
309 \IT{\GOO{\Op{\VAR{m}}\kwd{.}\VAR{n}%
310 \OP{\Goo{\KWD{S}\XOR\KWD{F}\XOR\KWD{D}\XOR\KWD{L}\XOR\KWD{E}}%
311 \VAR{x}\DF{\KWD{E}\LIT{0}}}%
312 \XOR%
313 \VAR{m}\OP{\kwd{.}\Op{\VAR{n}}}%
314 \Goo{\KWD{S}\XOR\KWD{F}\XOR\KWD{D}\XOR\KWD{L}\XOR\KWD{E}}\VAR{x}}}
316 $m.n\cdot10^x$ as \kwd*{short-float}, \kwd*{single-float},
317 \kwd*{double-float}, \kwd*{long-float}, or the type from \kwd{\A
318 read-default-float-format\A}.
321 \IT{\KWD*{\#C(}\VAR{a b}\kwd{)}\qquad\qquad}
323 (\FU*{complex} \VAR{a} \VAR{b}), the complex number
324 $\VAR{a}+\VAR{b}\text{i}$.
327 \IT{\KWD*{\#'}\VAR{foo}\qquad\qquad\qquad}
329 (\SO*{function} \VAR{foo}); the function named \VAR{foo}.
332 \IT{\KWD{\#}\VAR{n}\KWD{A}\VAR{sequence}}
333 {\index{\#A}%
334 \VAR{n}-dimensional array.
337 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{(}\OPn{\VAR{foo}}\kwd{)}}
338 {\index{\#(}%
339 Vector of some (or \VAR{n})
340 \VAR{foo}s filled with last \VAR{foo} if necessary.
343 \IT{\KWD{\#}\Op{\VAR{n}}\kwd{\A}\OPn{\VAR{b}}}
344 {\index{\#*@\#\A}%
345 Bit vector of some (or \VAR{n})
346 \VAR{b}s filled with last \VAR{b} if necessary.
349 \IT{\KWD*{\#S(}\VAR{type} \Goos{\VAR{slot} \VAR{value}}\kwd{)}}
351 Structure of \VAR{type}.
354 \IT{\KWD*{\#P}\VAR{string}\qquad\qquad}
356 A pathname.
359 \IT{\KWD*{\#:}\VAR{foo}\qquad\qquad\qquad}
361 Uninterned symbol \VAR{foo}.
364 \IT{\KWD*{\#.}\VAR{form}\qquad\qquad}
366 Read-time value of \VAR{form}.
369 \IT{\V{\A read-eval\A}\DF{\T}}
370 {\index{*READ-EVAL*@\A READ-EVAL\A}
371 If \NIL, a \kwd{reader-error} is signalled at \kwd{\#.}.
374 \IT{\KWD{\#}\VAR{integer}\kwd{=} \VAR{foo}\qquad}
375 {\index{\#=}%
376 Give \VAR{foo} the label \VAR{integer}.
379 \IT{\KWD{\#}\VAR{integer}\kwd{\#}\qquad\qquad}
380 {\index{\#\#}%
381 Object labelled \VAR{integer}.
384 \IT{\KWD{\#\boldmath$<$}\qquad\qquad\qquad}
385 {\index{\#<@\#$<$}%
386 Have the reader signal \kwd{reader-error}.
389 \IT{\arrGOO{\KWD*{\#+}\VAR{feature } \VAR{when-feature}\\
390 \KWD*{\#--}\VAR{feature } \VAR{unless-feature}}{.}}
392 Means \VAR{when-feature} if \VAR{feature} is \T; means
393 \VAR{unless-feature} if \VAR{feature} is \NIL. \VAR{feature} is a
394 symbol from \V{\A features\A}, or (\Goo{\kwd*{AND}\XOR\kwd*{OR}}
395 \OPn{\VAR{feature}}), or (\kwd*{NOT} \VAR{feature}).
398 \IT{\V{\A features\A}}
399 {\index{*FEATURES*@\A FEATURES\A}
400 List of symbols denoting implementation-dependent features.
403 \IT{\kwd{\boldmath$|$}\OPn{\VAR{c}}\kwd{\boldmath$|$};
404 \kwd{\boldmath$\backslash$}\VAR{c}}
406 \index{{$"|$} {$"|$}}%
407 Treat arbitrary character(s) \VAR{c} as alphabetic preserving case.
409 \index{\@{$\backslash$}}%
410 \end{LIST}
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
414 \subsection{Printer}
415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418 \begin{LIST}{1cm}
420 \IT{(\xorGOO{\FU*{PRIN1}\\
421 \FU*{PRINT}\\
422 \FU*{PPRINT}\\
423 \FU*{PRINC}}{\}}
424 \VAR{foo} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
426 Print \VAR{foo} to \VAR{stream} \FU{read}ably,
427 \FU{read}ably between a newline and a space,
428 \FU{read}ably after a newline, or human-readably without any extra
429 characters, respectively. \FU{prin1}, \FU{print} and \FU{princ}
430 return \retval{\VAR{foo}}.
433 \IT{\arrGOO{(\FU*{PRIN1-TO-STRING} \VAR{ foo})\\
434 (\FU*{PRINC-TO-STRING} \VAR{ foo})}{.}}
436 Print \VAR{foo} to \retval{\VAR{string}} \FU{read}ably or
437 human-readably, respectively.
440 \IT{(\GFU*{PRINT-OBJECT} \VAR{object} \DES{\VAR{stream}})}
442 Print \retval{\VAR{object}} to \VAR{stream}. Called by the Lisp
443 printer.
446 \IT{(\MC*{PRINT-UNREADABLE-OBJECT} (\VAR{foo} \DES{\VAR{stream}}
447 \orGOO{\kwd{:type } \VAR{bool}\DF{\NIL}\\
448 \kwd{:identity } \VAR{bool}\DF{\NIL}}{\}})
449 \PROGN{\VAR{form}})}
451 Enclosed in \kwd{\#\boldmath$<$} and \kwd{\boldmath$>$}, print
452 \VAR{foo} by means of \VAR{form}s to \VAR{stream}. Return \retval{\NIL}.
455 \IT{(\FU*{TERPRI} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
457 Output a newline to \VAR{stream}. Return \retval{\NIL}.
460 \IT{(\FU*{FRESH-LINE})
461 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}}}
463 Output a newline to \VAR{stream} and return \retval{\T} unless
464 \VAR{stream} is already at the start of a line.
467 \IT{(\FU*{WRITE-CHAR} \VAR{char}
468 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
470 Output \retval{\VAR{char}} to \VAR{stream}.
473 \IT{(\xorGOO{\FU*{WRITE-STRING}\\
474 \FU*{WRITE-LINE}}{\}} \VAR{string}
475 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}
476 \OP{\orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\\kwd{:end} \VAR{
477 end}\DF{\NIL}}{\}}}})}
479 Write \retval{\VAR{string}} to \VAR{stream} without/with a
480 trailing newline.
483 \IT{(\FU*{WRITE-BYTE} \VAR{byte} \DES{\VAR{stream}})}
485 Write \retval{\VAR{byte}} to binary \VAR{stream}.
488 \IT{(\FU*{WRITE-SEQUENCE} \VAR{sequence}
489 \DES{\VAR{stream}} \orGOO{\kwd{:start}\VAR{ start}\DF{\LIT{0}}\\
490 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
492 Write elements of \retval{\VAR{sequence}} to binary or character
493 \VAR{stream}.
496 \IT{(\xorGOO{\FU*{WRITE}\\
497 \FU*{WRITE-TO-STRING}}{\}} \VAR{foo} \orGOO{%
498 \kwd{:array} \VAR{ bool}\\
499 \kwd{:base} \VAR{ radix}\\
500 \kwd{:case } \xorGOO{\kwd{:upcase}\\
501 \kwd{:downcase}\\
502 \kwd{:capitalize}}{.}\\
503 \kwd{:circle} \VAR{ bool}\\
504 \kwd{:escape} \VAR{ bool}\\
505 \kwd{:gensym} \VAR{ bool}\\
506 \kwd{:length } \Goo{\VAR{int}\XOR\NIL}\\
507 \kwd{:level } \Goo{\VAR{int}\XOR\NIL}\\
508 \kwd{:lines } \Goo{\VAR{int}\XOR\NIL}\\
509 \kwd{:miser-width } \Goo{\VAR{int}\XOR\NIL}\\
510 \kwd{:pprint-dispatch} \VAR{ dispatch-table}\\
511 \kwd{:pretty} \VAR{ bool}\\
512 \kwd{:radix} \VAR{ bool}\\
513 \kwd{:readably} \VAR{ bool}\\
514 \kwd{:right-margin } \Goo{\VAR{int}\XOR\NIL}\\
515 \kwd{:stream } \DES{\VAR{stream}}\DF{\V{\A standard-output\A}}%
516 }{\}})}
518 Print \VAR{foo} to \VAR{stream} and return \retval{\VAR{foo}}, or
519 print \VAR{foo} into \retval{string}, respectively, after
520 dynamically setting printer variables corresponding to keyword
521 parameters (\kwd{\A print-}\VAR{bar}\kwd{\A} becoming
522 \kwd{:}\VAR{bar}). (\kwd{:stream} keyword with \FU{write} only.)
525 \IT{\arrGOO{%
526 (\FU*{PPRINT-FILL } \DES{\VAR{stream}} \VAR{ foo }
527 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
528 (\FU*{PPRINT-TABULAR } \DES{\VAR{stream}} \VAR{ foo }
529 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop} \text{ }
530 \Op{\VAR{n}\DF{\LIT{16}}}}})\\
531 (\FU*{PPRINT-LINEAR } \DES{\VAR{stream}} \VAR{ foo }
532 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
533 }{.}}
535 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print as
536 many elements per line as possible; do the same in a table with
537 a column width of \VAR{n} ems; or print either all elements on
538 one line or each on its own line, respectively. Return
539 \retval{\NIL}. Usable with \FU{format} directive \KWD{\TLD//}.
542 \IT{(\MC*{PPRINT-LOGICAL-BLOCK} (\DES{\VAR{stream}} \VAR{list}
543 \orGOO{\xorGOO{\kwd{:prefix} \VAR{ string}\\
544 \kwd{:per-line-prefix} \VAR{ string}}{\}}\\
545 \kwd{:suffix} \VAR{ string}\DF{\LIT{""}}}{\}})
546 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
548 Evaluate \VAR{form}s, which should print \VAR{list}, with
549 \VAR{stream} locally bound to a pretty
550 printing stream which outputs to the original \VAR{stream}. If
551 \VAR{list} is in fact not a list, it is printed by
552 \FU{write}. Return \retval{\NIL}.
555 \begin{LIST}{.5cm}
557 \IT{(\MC*{PPRINT-POP})}
559 Take \retval{next element} off \VAR{list}. If there is no remaining
560 tail of \VAR{list}, or \V{\A print-length\A} or \V{\A print-circle\A} indicate
561 printing should end, send element together with an appropriate
562 indicator to \VAR{stream}.
565 \IT{(\FU*{PPRINT-TAB} \xorGOO{\kwd{:line}\\
566 \kwd{:line-relative}\\
567 \kwd{:section}\\
568 \kwd{:section-relative}}{\}} \VAR{c}
569 \VAR{i} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
571 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
572 as possible.
575 \IT{(\FU*{PPRINT-INDENT} \xorGOO{%
576 \kwd{:block}\\
577 \kwd{:current}}{\}} \VAR{n}
578 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
580 Specify indentation for innermost logical block relative to
581 leftmost position/to current position. Return \retval{\NIL}.
584 \IT{(\MC*{PPRINT-EXIT-IF-LIST-EXHAUSTED})}
586 If \VAR{list} is empty, terminate logical block. Return
587 \retval{\NIL} otherwise.
590 \end{LIST}
592 \IT{(\FU*{PPRINT-NEWLINE} \xorGOO{%
593 \kwd{:linear}\\
594 \kwd{:fill}\\
595 \kwd{:miser}\\
596 \kwd{:mandatory}}{\}}
597 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
599 Print a conditional newline if \VAR{stream} is a pretty printing
600 stream. Return \retval{\NIL}.
603 \IT{\V{\A print-array\A}}
604 {\index{*PRINT-ARRAY*@\A PRINT-ARRAY\A}
605 If \T, print arrays \FU{read}ably.
608 \IT{\V{\A print-base\A}\DF{\LIT{10}}}
609 {\index{*PRINT-BASE*@\A PRINT-BASE\A}
610 Radix for printing rationals, from 2 to 36.
613 \IT{\V{\A print-case\A}\DF{\kwd{:upcase}}}
614 {\index{*PRINT-CASE*@\A PRINT-CASE\A}
615 Print symbol names all uppercase (\kwd{:upcase}), all lowercase
616 (\kwd{:downcase}), capitalized (\kwd{:capitalize}).
619 \IT{\V{\A print-circle\A}\DF{\NIL}}
620 {\index{*PRINT-CIRCLE*@\A PRINT-CIRCLE\A}
621 If \T, avoid indefinite recursion while printing circular
622 structure.
625 \IT{\V{\A print-escape\A}\DF{\T}}
626 {\index{*PRINT-ESCAPE*@\A PRINT-ESCAPE\A}
627 If \NIL, do not print escape characters and package prefixes.
630 \IT{\V{\A print-gensym\A}\DF{\T}}
631 {\index{*PRINT-GENSYM*@\A PRINT-GENSYM\A}
632 If \T, print \kwd{\#:} before uninterned symbols.
635 \IT{\arrGOO{\V{\A print-length\A}\DF{\NIL}\\
636 \V{\A print-level\A}\DF{\NIL}\\
637 \V{\A print-lines\A}\DF{\NIL}
638 }{.}}
639 {\index{*PRINT-LENGTH*@\A PRINT-LENGTH\A}\index{*PRINT-LEVEL*@\A PRINT-LEVEL\A}\index{*PRINT-LINES*@\A PRINT-LINES\A}
640 If integer, restrict printing of objects to that number of
641 elements per level/to that depth/to that number of lines.
644 \IT{\V{\A print-miser-width\A}}
645 {\index{*PRINT-MISER-WIDTH*@\A PRINT-MISER-WIDTH\A}
646 If integer and greater than the width available for printing a
647 substructure, switch to the more compact miser style.
650 \IT{\V{\A print-pretty\A}}
651 {\index{*PRINT-PRETTY*@\A PRINT-PRETTY\A}
652 If \T, print pretty.
655 \IT{\V{\A print-radix\A}\DF{\NIL}}
656 {\index{*PRINT-RADIX*@\A PRINT-RADIX\A}
657 If \T, print rationals with a radix indicator.
660 \IT{\V{\A print-readably\A}\DF{\NIL}}
661 {\index{*PRINT-READABLY*@\A PRINT-READABLY\A}
662 If \T, print \FU{read}ably or signal error
663 \kwd{print-not-readable}.
666 \IT{\V{\A print-right-margin\A}\DF{\NIL}}
667 {\index{*PRINT-RIGHT-MARGIN*@\A PRINT-RIGHT-MARGIN\A}
668 Right margin width in ems while pretty-printing.
671 \IT{(\FU*{SET-PPRINT-DISPATCH} \VAR{type} \VAR{function}
672 \OP{\VAR{priority}\DF{\LIT{0}}
673 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}}})}
675 Install entry comprising \VAR{function} of arguments stream and
676 object to print; and \VAR{priority} as
677 \VAR{type} into \VAR{table}. If \VAR{function}
678 is \NIL, remove \VAR{type} from \VAR{table}. Return \retval{\NIL}.
681 \IT{(\FU*{PPRINT-DISPATCH} \VAR{foo}
682 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
684 Return highest priority \retval{\VAR{function}} associated with
685 type of \VAR{foo} and \retvalii{\T} if there was a matching type
686 specifier in \VAR{table}.
689 \IT{(\FU*{COPY-PPRINT-DISPATCH}
690 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
692 Return \retval{copy of \VAR{table}} or, if \VAR{table} is \NIL,
693 initial value of \V{\A print-pprint-dispatch\A}.
696 \IT{\V{\A print-pprint-dispatch\A}}
697 {\index{*PRINT-PPRINT-DISPATCH*@\A PRINT-PPRINT-DISPATCH\A}
698 Current pretty print dispatch table.
701 \end{LIST}
705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
706 \subsection{Format}
707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
708 \label{section:Format}
710 \begin{LIST}{1cm}
712 \IT{(\MC*{FORMATTER} \NEV{\VAR{control}})}
714 Return \retval{function} of stream and a \kwd{\&rest} argument applying \FU{format} to
715 stream, \VAR{control}, and the \kwd{\&rest} argument
716 returning \NIL\ or any excess arguments.
719 \IT{(\FU*{FORMAT} \Goo{\T\XOR\NIL\XOR\VAR{out-string}\XOR\VAR{out-stream}}
720 \VAR{control} \OPn{\VAR{arg}})}
722 Output string \VAR{control} which may
723 contain \kwd{\TLD} directives possibly taking some
724 \VAR{arg}s. Alternatively, \VAR{control} can be a function returned
725 by \MC{formatter} which is then applied to \VAR{out-stream} and \OPn{\VAR{arg}}.
726 Output to \VAR{out-string}, \VAR{out-stream} or, if first
727 argument is \T, to \V{\A standard-output\A}. Return \retval{\NIL}. If
728 first argument is \NIL, return \retval{formatted output}.
731 \begin{LIST}{.5cm}
733 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}} \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
734 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
735 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
736 \KWD{\Op{:} \Op{@} \Goo{A\XOR S}}}
737 {\index{\~S@$\sim$S}\index{\~A@$\sim$A}%
738 \EM{Aesthetic/Standard. }
739 Print argument of any type for consumption by humans/by the
740 reader, respectively. With \kwd{:}, print \NIL\ as \LIT{()} rather
741 than \LIT{nil}; with \kwd{@}, add \VAR{pad-char}s on the left
742 rather than on the right.
745 \IT{\KWD{\TLD} \Op{\VAR{radix}\DF{\LIT{10}}} \OP{\KWD{,}\Op{\VAR{width}}
746 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
747 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
748 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}}
749 \KWD{\Op{:} \Op{@} R}}
750 {\index{\~R@$\sim$R}%
751 \EM{Radix. }
752 (With one or more prefix arguments.) Print argument as number; with
753 \KWD{:}, group digits \VAR{comma-interval} each; with \kwd{@},
754 always prepend a sign.
757 \IT{\Goo{\KWD{\TLD R}\XOR\KWD{\TLD :R}\XOR\KWD{\TLD
758 @R}\XOR\KWD{\TLD @:R}}}
760 \EM{Roman. }
761 Take argument as number and print it as English cardinal number,
762 as English ordinal number, as Roman numeral, or as old Roman
763 numeral, respectively.
766 \IT{\KWD{\TLD} \Op{\VAR{width}}
767 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
768 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
769 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}
770 \KWD{\Op{:} \Op{@} \Goo{D\XOR B\XOR O\XOR X}}}
771 {\index{\~D@$\sim$D}\index{\~B@$\sim$B}\index{\~O@$\sim$O}\index{\~X@$\sim$X}%
772 \EM{Decimal/Binary/Octal/Hexadecimal. }
773 Print integer argument as number. With \kwd{:}, group digits
774 \VAR{comma-interval} each; with \kwd{@}, always prepend a sign.
777 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{dec-digits}}
778 \OP{\KWD{,}\Op{\VAR{shift}\DF{\LIT{0}}}
779 \OP{\KWD{,}\Op{\VAR{overflow-char}}
780 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}}
781 \KWD{\Op{@} F}}
782 {\index{\~F@$\sim$F}%
783 \EM{Fixed-Format Floating-Point. } With
784 \kwd{@}, always pre\-pend a sign.
787 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{int-digits}}
788 \OP{\KWD{,}\Op{\VAR{exp-digits}}
789 \OP{\KWD{,}\Op{\VAR{scale-factor}\DF{\LIT{1}}}
790 \OP{\KWD{,}\Op{\VAR{overflow-char}}
791 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
792 \OP{\KWD{,}\VAR{exp-char}}}}}}}
793 \KWD{\Op{@} \Goo{E\XOR G}}}
794 {\index{\~E@$\sim$E}\index{\~G@$\sim$G}%
795 \EM{Exponential/General Floating-Point. }
796 Print argument as floating-point number with \VAR{int-digits}
797 before decimal point and \VAR{exp-digits} in the signed
798 exponent. With \KWD{\TLD G}, choose either \KWD{\TLD E} or
799 \KWD{\TLD F}. With \KWD{@}, always prepend a sign.
802 \IT{\KWD{\TLD} \Op{\VAR{dec-digits}\DF{\LIT{2}}}
803 \OP{\KWD{,}\Op{\VAR{int-digits}\DF{\LIT{1}}}
804 \OP{\KWD{,}\Op{\VAR{width}\DF{\LIT{0}}}
805 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
806 \Op{\KWD{:}} \Op{\kwd{@}} \KWD{\$}}
807 {\index{\~\$@$\sim$\$}%
808 \EM{Monetary Floating-Point. }
809 Print argument as fixed-format floating-point number. With \KWD{:},
810 put sign before any padding; with \KWD{@}, always prepend a
811 sign.
814 \IT{\Goo{\KWD{\TLD C}\XOR\KWD{\TLD :C}\XOR\KWD{\TLD
815 @C}\XOR\KWD{\TLD @:C}}}
816 {\index{\~C@$\sim$C}%
817 \EM{Character. }
818 Print, spell out, print in \kwd{\#$\backslash$} syntax, or tell
819 how to type, respectively, argument as (possibly non-printing)
820 character.
823 \IT{\Goo{%
824 \KWD{\TLD(} \VAR{text} \KWD{\TLD)}\XOR
825 \KWD{\TLD:(} \VAR{text} \KWD{\TLD)}\XOR
826 \KWD{\TLD @(} \VAR{text} \KWD{\TLD)}\XOR
827 \KWD{\TLD:@(} \VAR{text} \KWD{\TLD)}}}
828 {\index{\~(\~)@$\sim$( $\sim$)}%
829 \EM{Case-Conversion. }
830 Convert \VAR{text} to lowercase, convert first letter of each word
831 to uppercase, capitalize first word and convert the rest to
832 lowercase, or convert to uppercase, respectively.
835 \IT{\Goo{\KWD{\TLD P}\XOR\KWD{\TLD:P}
836 \XOR\KWD{\TLD @P}\XOR\KWD{\TLD:@P}}}
837 {\index{\~P@$\sim$P}%
838 \EM{Plural. }
839 If argument \kwd{eql} \LIT{1} print nothing, otherwise print \LIT{s};
840 do the same for the previous argument; if argument \kwd{eql} \LIT{1}
841 print \LIT{y}, otherwise print \LIT{ies}; do the same for the
842 previous argument, respectively.
845 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\%}}
846 {\index{\~\%@$\sim$\%}%
847 \EM{Newline. }
848 Print \VAR{n} newlines.
851 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\&}}
852 {\index{\~\&@$\sim$\&}%
853 \EM{Fresh-Line. }
854 Print $n-1$ newlines if output stream is at the
855 beginning of a line, or \VAR{n} newlines otherwise.
858 \IT{\Goo{\KWD{\TLD\_}\XOR\KWD{\TLD:\_}\XOR\KWD{\TLD@\_}\XOR\KWD{\TLD:@\_}}}
859 {\index{\~\_{}@$\sim$\_{}}%
860 \EM{Conditional Newline. }
861 Print a newline like \kwd{pprint-newline} with argument
862 \kwd{:linear}, \kwd{:fill}, \kwd{:miser}, or \kwd{:mandatory}, respectively.
865 \IT{\Goo{\KWD{\TLD:$\hookleftarrow$}\XOR\KWD{\TLD@$\hookleftarrow$}\XOR\KWD{\TLD$\hookleftarrow$}}}
866 {\index{\~\~bogus-ordering{}@$\sim\hookleftarrow$}%
867 \EM{Ignored Newline. } Ignore newline, or whitespace following
868 newline, or both, respectively.
871 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\boldmath$|$}}
872 {\index{\~\textbar@$\sim${$"|$}}%
873 \EM{Page. }
874 Print \VAR{n} page separators.
877 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\TLD}}
878 {\index{\~\~@$\sim$$\sim$}%
879 \EM{Tilde. }
880 Print \VAR{n} tildes.
883 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}}
884 \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
885 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
886 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
887 \KWD{\Op{:} \Op{@} \boldmath{$<$}}
888 \OP{\VAR{nl-text} \KWD{\TLD}\Op{\VAR{spare}\DF{\LIT{0}} \Op{\KWD{,}\VAR{width}}}\kwd{:;}}
889 \Goos{\VAR{text} \KWD{\TLD;}} \VAR{text} \KWD{\TLD\boldmath{$>$}}}
890 {\index{\~<\~>@$\sim$$<$ $\sim$$>$}%
891 \EM{Justification. }
892 Justify text produced by \VAR{text}s in a field of at least
893 \VAR{min-col} columns. With \kwd{:}, right justify; with \kwd{@},
894 left justify. If this would leave less than \VAR{spare} characters
895 on the current line, output \VAR{nl-text} first.
898 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{\boldmath{$<$}}
899 \GOo{\Op{\VAR{prefix}\DF{\LIT{""}}
900 \KWD{\TLD;}}\XOR\Op{\VAR{per-line-prefix}
901 \KWD{\TLD@;}}}
902 \VAR{body} \OP{\KWD{\TLD;} \VAR{suffix}\DF{\LIT{""}}}
903 \KWD{\TLD:} \Op{\KWD{@}} \KWD{\boldmath{$>$}}}
904 {\index{\~<\~:>@$\sim$$<$ $\sim$:$>$}%
905 \EM{Logical Block. }
906 Act like \kwd{pprint-logical-block} using \VAR{body} as \FU{format}
907 control string on the elements of the list argument or, with \KWD{@},
908 on the remaining arguments, which are extracted by
909 \kwd{pprint-pop}. With \KWD{:}, \VAR{prefix} and \VAR{suffix}
910 default to \LIT{(} and \LIT{)}. When closed by
911 \KWD{\TLD:@\boldmath{$>$}}, spaces in \VAR{body} are replaced with
912 conditional newlines.
915 \IT{\Goo{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}}
916 \kwd{I}\XOR\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \kwd{:I}}}
917 {\index{\~I@$\sim$I}%
918 \EM{Indent. }
919 Set indentation to \VAR{n} relative to leftmost/to current
920 position.
923 \IT{\KWD{\TLD} \Op{\VAR{c}\DF{\LIT{1}}}
924 \Op{\KWD{,}\VAR{i}\DF{\LIT{1}}} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{T}}
925 {\index{\~T@$\sim$T}%
926 \EM{Tabulate. }
927 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
928 as possible. With \kwd{:}, calculate column numbers relative to
929 the immediately enclosing section. With \kwd{@}, move to column
930 number $c_0 + c + ki$ where $c_0$ is the current position.
933 \IT{\Goo{%
934 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{\A}\XOR
935 \KWD{\TLD} \Op{\VAR{m}\DF{\LIT{1}}} \KWD{:}\KWD{\A}\XOR
936 \KWD{\TLD} \Op{\VAR{n}\DF{\LIT{0}}} \KWD{@}\KWD{\A}}}
937 {\index{\~*@$\sim$\A}%
938 \EM{Go-To. }
939 Jump \VAR{m} arguments forward, or backward, or to argument \VAR{n}.
942 \IT{\KWD{\TLD} \Op{\VAR{limit}} \Op{\KWD{{:}}} \Op{\kwd{@}}
943 \KWD{\boldmath{$\{$}} \VAR{text} \KWD{\TLD\boldmath{$\}$}}}
944 {\index{\~\{\~\}@$\sim$$\{$ $\sim\}$}%
945 \EM{Iteration. }
946 Use \VAR{text} repeatedly, up to \VAR{limit}, as control
947 string for the elements of the list argument or (with
948 \kwd{@}) for the remaining arguments. With \kwd{:} or \kwd{:@},
949 list elements or remaining arguments should be
950 lists of which a new one is used at each iteration step.
953 \IT{\KWD{\TLD} \OP{\VAR{x} \OP{\kwd{,}\VAR{y} \Op{\kwd{,}\VAR{z}}}}
954 \KWD{\^{}}}
955 {\index{\~\^{}@$\sim$\^{}}%
956 \EM{Escape Upward. }
957 Leave immediately \kwd{\TLD\boldmath{$<$} \TLD\boldmath{$>$}},
958 \kwd{\TLD\boldmath{$<$} \TLD:\boldmath{$>$}},
959 \kwd{\TLD\boldmath{$\{$} \TLD\boldmath{$\}$}}, \kwd{\TLD?}, or the
960 entire \FU{format} operation. With one to three prefixes, act only
961 if $x=0$, $x=y$, or $x\leq y \leq z$, respectively.
964 \IT{\KWD{\TLD} \Op{\VAR{i}} \Op{\KWD{:}} \Op{\KWD{@}}
965 \KWD{[} \Op{\Goos{\VAR{text} \KWD{\TLD;}} \VAR{text}}
966 \Op{\kwd{\TLD:;} \VAR{default}} \KWD{\TLD]}}
967 {\index{\~[\~]@$\sim$[ $\sim$]}%
968 \EM{Conditional Expression. }
969 Use the zero-indexed argumenth (or
970 \VAR{i}th if given) \VAR{text} as a \FU{format} control subclause.
971 With \kwd{:}, use the first \VAR{text} if the argument value is
972 \NIL, or the second \VAR{text} if it is \T. With \kwd{@}, do nothing
973 for an argument value of \NIL. Use the only \VAR{text} and leave
974 the argument to be read again if it is \T.
977 \IT{\KWD{\TLD} \Op{\KWD{@}} \KWD{?}}
978 {\index{\~?@$\sim$?}%
979 \EM{Recursive Processing. }
980 Process two arguments as control string and argument list. With
981 \kwd{@}, take one argument as control string and use then the
982 rest of the original arguments.
985 \IT{\KWD{\TLD} \OP{\VAR{prefix} \Goos{\kwd{,}%
986 \VAR{prefix}}} \Op{\kwd{:}} \Op{\kwd{@}} \KWD{/}\VAR{function}\KWD{/}}
987 {\index{\~/ /@$\sim$/ /}%
988 \EM{Call Function. }
989 Call \VAR{function} with the arguments stream, format-ar\-gu\-ment,
990 colon-p, at-sign-p and \VAR{prefix}es for printing format-argument.
993 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} \KWD{W}}
994 {\index{\~W@$\sim$W}%
995 \EM{Write. }
996 Print argument of any type obeying every printer control variable. With \kwd{:},
997 pretty-print. With \kwd{@}, print without limits on length or depth.
1000 \IT{\Goo{\KWD{V}\XOR\KWD{\#}}}
1001 {\index{V}\index{\#}
1002 In place of the comma-separated prefix parameters: use next
1003 argument or number of remaining unprocessed arguments, respectively.
1006 \end{LIST}
1008 \end{LIST}
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 \subsection{Streams}
1013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1015 \begin{LIST}{1cm}
1017 \IT{(\FU*{OPEN} \VAR{path}
1018 \orGOO{\kwd{:direction }
1019 \xorGOO{\kwd{:input}\\
1020 \kwd{:output}\\
1021 \kwd{:io}\\
1022 \kwd{:probe}}{\}}\DF{\kwd{:input}}\\
1023 \kwd{:element-type }
1024 \xorGOO{\VAR{type}\\
1025 \kwd{:default}}{\}}\DF{\kwd{character}}\\
1026 \kwd{:if-exists }
1027 \xorGOO{\kwd{:new-version}\\
1028 \kwd{:error}\\
1029 \kwd{:rename}\\
1030 \kwd{:rename-and-delete}\\
1031 \kwd{:overwrite}\\
1032 \kwd{:append}\\
1033 \kwd{:supersede}\\
1034 \NIL}{\}}\DF{\parbox{20mm}{%
1035 \kwd{:new-version} if \VAR{path} specifies \kwd{:newest};\\
1036 \NIL\ otherwise}}\\
1037 \kwd{:if-does-not-exist }
1038 \xorGOO{\kwd{:error}\\
1039 \kwd{:create}\\
1040 \NIL}{\}}\DF{\parbox{27mm}{%
1041 \NIL\ for \kwd{:direction :probe};\\
1042 \mbox{\Goo{\kwd{:create}\XOR\kwd{:error}} otherwise}}}\\
1043 \kwd{:external-format } \VAR{format}\DF{\kwd{:default}}%
1044 }{\}})}
1045 {\label{open}
1046 Open \retval{\kwd{file-stream} to \VAR{path}}.
1049 \IT{\arrGOO{%
1050 (\FU*{MAKE-CONCATENATED-STREAM } \OPn{\VAR{input-stream}})\\
1051 (\FU*{MAKE-BROADCAST-STREAM } \OPn{\VAR{output-stream}})\\
1052 (\FU*{MAKE-TWO-WAY-STREAM } \VAR{input-stream-part } \VAR{output-stream-part})\\
1053 (\FU*{MAKE-ECHO-STREAM } \VAR{from-input-stream } \VAR{to-output-stream})\\
1054 (\FU*{MAKE-SYNONYM-STREAM } \VAR{variable-bound-to-stream})}{.}}
1056 Return \retval{stream} of indicated type.
1059 \IT{(\FU*{MAKE-STRING-INPUT-STREAM} \VAR{string}
1060 \OP{\VAR{start}\DF{\LIT{0}}
1061 \Op{\VAR{end}\DF{\NIL}}})}
1063 Return a \retval{\kwd{string-stream}} supplying the characters from \VAR{string}.
1066 \IT{(\FU*{MAKE-STRING-OUTPUT-STREAM} \Op{\kwd{:element-type}
1067 \VAR{type}\DF{\kwd{character}}})}
1069 Return a \retval{\kwd{string-stream}} accepting characters
1070 (available via \FU{get-output-stream-string}).
1073 \IT{\arrGOO{(\FU*{CONCATENATED-STREAM-STREAMS } \VAR{concatenated-stream})\\
1074 (\FU*{BROADCAST-STREAM-STREAMS } \VAR{broadcast-stream})}{.}}
1076 Return \retval{list of streams} \VAR{concatenated-stream} still
1077 has to read from/\VAR{broadcast-stream} is
1078 broadcasting to.
1081 \IT{\arrGOO{%
1082 (\FU*{TWO-WAY-STREAM-INPUT-STREAM} \VAR{ two-way-stream})\\
1083 (\FU*{TWO-WAY-STREAM-OUTPUT-STREAM} \VAR{ two-way-stream})\\
1084 (\FU*{ECHO-STREAM-INPUT-STREAM} \VAR{ echo-stream})\\
1085 (\FU*{ECHO-STREAM-OUTPUT-STREAM} \VAR{ echo-stream})}{.}}
1087 Return \retval{source stream} or \retval{sink stream} of
1088 \VAR{two-way-stream}\slash\VAR{echo-stream}, respectively.
1091 \IT{(\FU*{SYNONYM-STREAM-SYMBOL} \VAR{synonym-stream})}
1093 Return \retval{symbol} of \VAR{synonym-stream}.
1096 \IT{(\FU*{GET-OUTPUT-STREAM-STRING} \DES{\VAR{string-stream}})}
1098 Clear and return as a \retval{string} characters on
1099 \VAR{string-stream}.
1102 \IT{(\FU*{FILE-POSITION} \VAR{stream} \Op{\xorGOO{\kwd{:start}\\
1103 \kwd{:end}\\
1104 \VAR{position}}{\}}})}
1106 Return \retval{position within stream}, or set it to
1107 \retval{\VAR{position}} and return \retval{\T} on success.
1110 \IT{(\FU*{FILE-STRING-LENGTH} \VAR{stream} \VAR{foo})}
1112 \retval{Length} \VAR{foo} would have in \VAR{stream}.
1115 \IT{(\FU*{LISTEN} \Op{\VAR{stream}\DF{\V{\A standard-input\A}}})}
1117 \retval{\T} if there is a character in input \VAR{stream}.
1120 \IT{(\FU*{CLEAR-INPUT}
1121 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}})}
1123 Clear input from \VAR{stream}, return \retval{\NIL}.
1126 \IT{(\xorGOO{\FU*{CLEAR-OUTPUT}\\
1127 \FU*{FORCE-OUTPUT}\\
1128 \FU*{FINISH-OUTPUT}}{\}}
1129 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
1131 End output to \VAR{stream} and return \retval{\NIL} immediately,
1132 after initiating flushing of buffers, or after flushing of
1133 buffers, respectively.
1136 \IT{(\FU*{CLOSE} \DES{\VAR{stream}} \Op{\kwd{:abort}
1137 \VAR{bool}\DF{\NIL}})}
1139 Close \VAR{stream}. Return \retval{\T} if \VAR{stream} had been
1140 open. If \kwd{:abort} is \T, delete associated file.
1143 \IT{(\MC*{WITH-OPEN-FILE} (\VAR{stream} \VAR{path}
1144 \OPn{\VAR{open-arg}}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
1145 \PROGN{\VAR{form}})}
1147 Use \FU{OPEN} with \VAR{open-arg}s to temporarily create
1148 \VAR{stream} to \VAR{path}; return \retval{values of
1149 \VAR{form}s}.
1152 \IT{(\MC*{WITH-OPEN-STREAM} (\VAR{foo} \DES{\VAR{stream}})
1153 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1155 Evaluate \VAR{form}s with \VAR{foo} locally bound to
1156 \VAR{stream}. Return \retval{values of \VAR{form}s}.
1159 \IT{(\MC*{WITH-INPUT-FROM-STRING} (\VAR{foo} \VAR{string}
1160 \orGOO{\kwd{:index } \DES{\VAR{index}}\\
1161 \kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1162 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}}) \OPn{(\kwd{declare}
1163 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1165 Evaluate \VAR{form}s with \VAR{foo} locally bound to input
1166 \kwd{string-stream} from \VAR{string}. Return \retval{values of
1167 \VAR{form}s}; store next reading position into \VAR{index}.
1170 \IT{(\MC*{WITH-OUTPUT-TO-STRING} (\VAR{foo}
1171 \Op{\DES{\VAR{string}}\DF{\NIL}} \Op{\kwd{:element-type}
1172 \VAR{type}\DF{\kwd{character}}}) \OPn{(\kwd{declare}
1173 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1175 Evaluate \VAR{form}s with \VAR{foo} locally bound to an output
1176 \kwd{string-stream}. Append output to \VAR{string} and return
1177 \retval{values of \VAR{form}s} if \VAR{string} is given. Return
1178 \retval{string containing output} otherwise.
1181 \IT{(\FU*{STREAM-EXTERNAL-FORMAT} \VAR{stream})}
1183 \retval{External file format designator}.
1186 \IT{\V{\A terminal-io\A}}
1187 {\index{*TERMINAL-IO*@\A TERMINAL-IO\A}
1188 Bidirectional stream to user terminal.
1191 \IT{\arrGOO{\V{\A standard-input\A}\\
1192 \V{\A standard-output\A}\\
1193 \V{\A error-output\A}}{.}}
1194 {\index{*STANDARD-INPUT*@\A STANDARD-INPUT\A}%
1195 \index{*STANDARD-OUTPUT*@\A STANDARD-OUTPUT\A}%
1196 \index{*ERROR-OUTPUT*@\A ERROR-OUTPUT\A}
1197 Standard input stream, standard output stream,
1198 or standard error output stream, respectively.
1201 \IT{\arrGOO{\V{\A debug-io\A}\\
1202 \V{\A query-io\A}}{.}}
1203 {\index{*DEBUG-IO*@\A DEBUG-IO\A}\index{*QUERY-IO*@\A QUERY-IO\A}
1204 Bidirectional streams for debugging and user interaction.
1207 \end{LIST}
1210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1211 \subsection[Paths and Files]{Pathnames and Files}
1212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 \begin{LIST}{1cm}
1216 \IT{(\FU*{MAKE-PATHNAME}
1217 \orGOO{\kwd{:host } \Goo{\VAR{host}\XOR\NIL\XOR\kwd{:unspecific}}\\
1218 \kwd{:device } \Goo{\VAR{device}\XOR\NIL\XOR\kwd{:unspecific}}\\
1219 \kwd{:directory } \xorGOO{%
1220 \Goo{\VAR{directory}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1221 (\xorGOO{%
1222 \kwd{:absolute}\\
1223 \kwd{:relative}
1224 }{\}}\text{ }%
1225 \xorGOO{%
1226 \VAR{directory}\\
1227 \kwd{:wild}\\
1228 \kwd{:wild-inferiors}\\
1229 \kwd{:up}\\
1230 \kwd{:back}
1231 }{\}^{\!\!*}})
1232 }{.}\\
1233 \kwd{:name } \Goo{\VAR{file-name}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1234 \kwd{:type } \Goo{\VAR{file-type}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1235 \kwd{:version } \Goo{\kwd{:newest}\XOR\VAR{version}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1236 \kwd{:defaults } \VAR{path}\DF{host from \V{\A default-pathname-defaults\A}}\\
1237 \kwd{:case
1238 \Goo{\kwd{:local}\XOR\kwd{:common}}\DF{\kwd{:local}}}}{\}})}
1240 Construct \retval{pathname}.
1241 For \kwd{:case :local}, leave case of components unchanged.
1242 For \kwd{:case :common}, leave mixed-case components unchanged;
1243 convert all-uppercase components into
1244 local customary case; do the opposite with all-lowercase
1245 components.
1248 \IT{\arrGOO{%
1249 (\xorGOO{\FU*{PATHNAME-HOST}\\
1250 \FU*{PATHNAME-DEVICE}\\
1251 \FU*{PATHNAME-DIRECTORY}\\
1252 \FU*{PATHNAME-NAME}\\
1253 \FU*{PATHNAME-TYPE}}{\}}
1254 \VAR{ path }
1255 \Op{\kwd{:case } \xorGOO{\kwd{:local}\\
1256 \kwd{:common}}{\}}\DF{\kwd{:local}}})\\
1257 (\FU*{PATHNAME-VERSION } \VAR{path})}{.}}
1259 Return \retval{pathname component}.
1262 \IT{(\FU*{PARSE-NAMESTRING} \VAR{foo}
1263 \OP{\VAR{host}
1264 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1265 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1266 \kwd{:end} \VAR{ end}\DF{\NIL}\\
1267 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}}}})}
1269 Return \retval{pathname} converted from
1270 string, pathname, or stream \VAR{foo}; and \retvalii{position}
1271 where parsing stopped.
1274 \IT{(\FU*{MERGE-PATHNAMES} \VAR{pathname}
1275 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1276 \Op{\VAR{default-version}\DF{\kwd{:newest}}}})}
1278 Return \retval{\VAR{pathname}} after filling in missing components
1279 from \VAR{default-pathname}.
1282 \IT{\V{\A default-pathname-defaults\A}}
1283 {\index{*DEFAULT-PATHNAME-DEFAULTS*@\A DEFAULT-PATHNAME-DEFAULTS\A}
1284 Pathname to use if one is needed and none supplied.
1287 \IT{(\FU*{USER-HOMEDIR-PATHNAME} \Op{\VAR{host}})}
1289 User's \retval{home directory}.
1292 \IT{(\FU*{ENOUGH-NAMESTRING} \VAR{path}
1293 \Op{\VAR{root-path}\DF{\V{\A default-pathname-defaults\A}}})}
1295 Return \retval{minimal path string} to sufficiently describe
1296 \VAR{path} relative to \VAR{root-path.}
1299 \IT{\arrGOO{(\FU*{NAMESTRING}\VAR{ path})\\
1300 (\FU*{FILE-NAMESTRING}\VAR{ path})\\
1301 (\FU*{DIRECTORY-NAMESTRING}\VAR{ path})\\
1302 (\FU*{HOST-NAMESTRING}\VAR{ path})}{.}}
1304 Return string representing \retval{full pathname}; \retval{name,
1305 type, and version}; \retval{directory name}; or \retval{host
1306 name}, respectively, of \VAR{path}.
1309 \IT{(\FU*{TRANSLATE-PATHNAME} \VAR{path} \VAR{wildcard-path-a}
1310 \VAR{wildcard-path-b})}
1312 Translate \VAR{path} from \VAR{wildcard-path-a} into
1313 \VAR{wildcard-path-b}. Return \retval{new path}.
1316 \IT{(\FU*{PATHNAME} \VAR{path})}
1318 \retval{Pathname} of \VAR{path}.
1321 \IT{(\FU*{LOGICAL-PATHNAME} \VAR{logical-path})}
1323 \retval{Logical pathname} of \VAR{logical-path}.
1324 Logical pathnames are represented as all-uppercase
1325 \LIT{\#P"}%
1326 \Op{\VAR{host}\LIT{:}}\Op{\LIT{:}}%
1327 \Goos{\xorGOO{%
1328 \Goop{\VAR{dir}\XOR\LIT{*}}\\
1329 \LIT{**}}{\}}\LIT{;}}%
1330 \penalty-5
1331 \Goos{\VAR{name}\XOR\LIT{*}}%
1332 \OP{\LIT{.}%
1333 \xorGOO{%
1334 \Goop{\VAR{type}\XOR\LIT{*}}\\
1335 \LIT{LISP}}{\}}%
1336 \Op{\LIT{.}%
1337 \Goo{%
1338 \VAR{version}\XOR\LIT{*}\XOR\LIT{newest}\XOR\LIT{NEWEST}}}}%
1339 \LIT{"}.
1340 \index{*@\A}\index{**@\A\A}%
1343 \IT{(\FU*{LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1345 \retval{List of (\VAR{from-wildcard to-wildcard}) translations}
1346 for \VAR{logical-host}. \kwd{setf}able.
1349 \IT{(\FU*{LOAD-LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1351 Load \VAR{logical-host}'s translations. Return \retval{\NIL} if already
1352 loaded; return \retval{\T} if successful.
1355 \IT{(\FU*{TRANSLATE-LOGICAL-PATHNAME} \VAR{pathname})}
1357 \retval{Physical pathname} corresponding to (possibly logical)
1358 \VAR{pathname}.
1361 \IT{\arrGOO{(\FU*{PROBE-FILE} \VAR{ file})\\
1362 (\FU*{TRUENAME} \VAR{ file})}{.}}
1364 \retval{Canonical name} of \VAR{file}. If \VAR{file} does not exist,
1365 return \retval{\NIL}/signal \kwd{file-error}, respectively.
1368 \IT{(\FU*{FILE-WRITE-DATE} \VAR{file})}
1370 \retval{Time} at which \VAR{file} was last written.
1373 \IT{(\FU*{FILE-AUTHOR} \VAR{file})\qquad\qquad}
1375 Return \retval{name of \VAR{file} owner}.
1378 \IT{(\FU*{FILE-LENGTH} \VAR{stream})}
1380 Return \retval{length of \VAR{stream}}.
1383 \IT{(\FU*{RENAME-FILE} \VAR{foo} \VAR{bar})}
1385 Rename file \VAR{foo} to \VAR{bar}. Unspecified components of path
1386 \VAR{bar} default to those of \VAR{foo}. Return \retval{new
1387 pathname}, \retvalii{old physical file name}, and \retvaliii{new
1388 physical file name}.
1391 \IT{(\FU*{DELETE-FILE} \VAR{file})}
1393 Delete \VAR{file}. Return \retval{\T}.
1396 \IT{(\FU*{DIRECTORY} \VAR{path})}
1398 \retval{List of pathnames} matching \VAR{path}.
1401 \IT{(\FU*{ENSURE-DIRECTORIES-EXIST} \VAR{path} \Op{\kwd{:verbose}
1402 \VAR{bool}})}
1404 Create parts of \retval{\VAR{path}} if necessary. Second return value is
1405 \retvalii{\T} if something has been created.
1408 \end{LIST}
1412 % LocalWords: ies argumenth ar gu ment
1414 %%% Local Variables:
1415 %%% mode: latex
1416 %%% TeX-master: "clqr"
1417 %%% End: