A few lines on number syntax.
[clqr.git] / clqr-input-output.tex
blobf715d25071fa8256092a3a5bacf71574d8d235f9
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{.}; \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 $\VAR{a}+\VAR{b}\text{i}$.
324 \IT{\KWD*{\#'}\VAR{foo}\qquad\qquad\qquad}
326 (\SO*{function} \VAR{foo}); the function named \VAR{foo}.
329 \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{)}}
337 \index{\#(}%
338 Vector of some (or \VAR{n})
339 \VAR{foo}s filled with last \VAR{foo} if necessary.
342 \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 by \kwd{\#.}.
374 \IT{\KWD{\#}\VAR{int}\kwd{=} \VAR{foo}\qquad\quad}
376 \index{\#=}%
377 Give \VAR{foo} the label \VAR{int}.
380 \IT{\KWD{\#}\VAR{int}\kwd{\#}\qquad\qquad}
382 \index{\#\#}%
383 Object labelled \VAR{int}.
386 \IT{\KWD{\#\boldmath$<$}\qquad\qquad\qquad}
388 \index{\#<@\#$<$}%
389 Have the reader signal \kwd{reader-error}.
392 \IT{\arrGOO{\KWD*{\#+}\VAR{feature } \VAR{when-feature}\\
393 \KWD*{\#--}\VAR{feature } \VAR{unless-feature}}{.}}
395 Means \VAR{when-feature} if \VAR{feature} is \T, means
396 \VAR{unless-feature} if \VAR{feature} is \NIL. \VAR{feature} is a
397 symbol from \V{\A features\A}, or (\Goo{\kwd*{AND}\XOR\kwd*{OR}}
398 \OPn{\VAR{feature}}), or (\kwd*{NOT} \VAR{feature}).
401 \IT{\V{\A features\A}}
402 {\index{*FEATURES*@\A FEATURES\A}
403 List of symbols denoting implementation-dependent features.
406 \IT{\kwd{\boldmath$|$}\OPn{\VAR{c}}\kwd{\boldmath$|$};
407 \kwd{\boldmath$\backslash$}\VAR{c}}
409 Treat arbitrary character(s) \VAR{c} as alphabetic preserving case.
411 \index{\@{$\backslash$}}%
412 \index{{$"|$} {$"|$}}%
414 \end{LIST}
417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
418 \subsection{Printer}
419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
422 \begin{LIST}{1cm}
424 \IT{(\xorGOO{\FU*{PRIN1}\\
425 \FU*{PRINT}\\
426 \FU*{PPRINT}\\
427 \FU*{PRINC}}{\}}
428 \VAR{foo} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
430 Print \VAR{foo} to \VAR{stream} \FU{read}ably,
431 \FU{read}ably between a newline and a space,
432 \FU{read}ably after a newline, or human-readably without any extra
433 characters, respectively. \FU{prin1}, \FU{print} and \FU{princ}
434 return \retval{\VAR{foo}}.
437 \IT{\arrGOO{(\FU*{PRIN1-TO-STRING} \VAR{ foo})\\
438 (\FU*{PRINC-TO-STRING} \VAR{ foo})}{.}}
440 Print \VAR{foo} to \retval{\VAR{string}} \FU{read}ably or
441 human-readably, respectively.
444 \IT{(\GFU*{PRINT-OBJECT} \VAR{object} \DES{\VAR{stream}})}
446 Print \retval{\VAR{object}} to \VAR{stream}. Called by the Lisp
447 printer.
450 \IT{(\MC*{PRINT-UNREADABLE-OBJECT} (\VAR{foo} \DES{\VAR{stream}}
451 \orGOO{\kwd{:type } \VAR{bool}\DF{\NIL}\\
452 \kwd{:identity } \VAR{bool}\DF{\NIL}}{\}})
453 \PROGN{\VAR{form}})}
455 Enclosed in \kwd{\#\boldmath$<$} and \kwd{\boldmath$>$}, print
456 \VAR{foo} by means of \VAR{form}s to \VAR{stream}. Return \retval{\NIL}.
459 \IT{(\FU*{TERPRI} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
461 Output a newline to \VAR{stream}. Return \retval{\NIL}.
464 \IT{(\FU*{FRESH-LINE})
465 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}}}
467 Output a newline to \VAR{stream} and return \retval{\T} unless \VAR{stream}
468 is already at the start of a line.
471 \IT{(\FU*{WRITE-CHAR} \VAR{char}
472 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
474 Output \retval{\VAR{char}} to \VAR{stream}.
477 \IT{(\xorGOO{\FU*{WRITE-STRING}\\
478 \FU*{WRITE-LINE}}{\}} \VAR{string}
479 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}
480 \OP{\orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\\kwd{:end} \VAR{
481 end}\DF{\NIL}}{\}}}})}
483 Write \retval{\VAR{string}} to \VAR{stream} without/with a trailing newline.
486 \IT{(\FU*{WRITE-BYTE} \VAR{byte} \DES{\VAR{stream}})}
488 Write \retval{\VAR{byte}} to binary \VAR{stream}.
491 \IT{(\FU*{WRITE-SEQUENCE} \VAR{sequence}
492 \DES{\VAR{stream}} \orGOO{\kwd{:start}\VAR{ start}\DF{\LIT{0}}\\
493 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}})}
495 Write elements of \retval{\VAR{sequence}} to \VAR{stream}.
498 \IT{(\xorGOO{\FU*{WRITE}\\
499 \FU*{WRITE-TO-STRING}}{\}} \VAR{foo} \orGOO{%
500 \kwd{:array} \VAR{ bool}\\
501 \kwd{:base} \VAR{ radix}\\
502 \kwd{:case } \xorGOO{\kwd{:upcase}\\
503 \kwd{:downcase}\\
504 \kwd{:capitalize}}{.}\\
505 \kwd{:circle} \VAR{ bool}\\
506 \kwd{:escape} \VAR{ bool}\\
507 \kwd{:gensym} \VAR{ bool}\\
508 \kwd{:length } \Goo{\VAR{int}\XOR\NIL}\\
509 \kwd{:level } \Goo{\VAR{int}\XOR\NIL}\\
510 \kwd{:lines } \Goo{\VAR{int}\XOR\NIL}\\
511 \kwd{:miser-width } \Goo{\VAR{int}\XOR\NIL}\\
512 \kwd{:pprint-dispatch} \VAR{ dispatch-table}\\
513 \kwd{:pretty} \VAR{ bool}\\
514 \kwd{:radix} \VAR{ bool}\\
515 \kwd{:readably} \VAR{ bool}\\
516 \kwd{:right-margin } \Goo{\VAR{int}\XOR\NIL}\\
517 \kwd{:stream } \DES{\VAR{stream}}\DF{\V{\A standard-output\A}}%
518 }{\}})}
520 Print \VAR{foo} to \VAR{stream} and return \retval{\VAR{foo}}, or print \VAR{foo} into
521 \retval{string}, respectively, after dynamically setting printer variables
522 corresponding to keyword parameters (\kwd{\A print-}\VAR{bar}\kwd{\A} becoming
523 \kwd{:}\VAR{bar}). (\kwd{:stream} keyword with \FU{write} only.)
526 \IT{\arrGOO{%
527 (\FU*{PPRINT-FILL } \DES{\VAR{stream}} \VAR{ foo }
528 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
529 (\FU*{PPRINT-TABULAR } \DES{\VAR{stream}} \VAR{ foo }
530 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop} \text{ }
531 \Op{\VAR{n}\DF{\LIT{16}}}}})\\
532 (\FU*{PPRINT-LINEAR } \DES{\VAR{stream}} \VAR{ foo }
533 \OP{\VAR{parenthesis}\DF{\T} \text{ } \Op{\VAR{noop}}})\\
534 }{.}}
536 Print \VAR{foo} to \VAR{stream}. If \VAR{foo} is a list, print as
537 many elements per line as possible; do the same in a table with
538 a column width of \VAR{n} ems; or print either all elements on
539 one line or each on its own line, respectively. Return
540 \retval{\NIL}. Usable with \FU{format} directive \KWD{\TLD//}.
543 \IT{(\MC*{PPRINT-LOGICAL-BLOCK} (\DES{\VAR{stream}} \VAR{list}
544 \orGOO{\xorGOO{\kwd{:prefix} \VAR{ string}\\
545 \kwd{:per-line-prefix} \VAR{ string}}{\}}\\
546 \kwd{:suffix} \VAR{ string}\DF{\LIT{""}}}{\}})
547 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
549 Evaluate \VAR{form}s, which should print \VAR{list}, with
550 \VAR{stream} locally bound to a pretty
551 printing stream which outputs to the original \VAR{stream}. If
552 \VAR{list} is in fact not a list, it is printed by
553 \FU{write}. Return \retval{\NIL}.
556 \begin{LIST}{.5cm}
558 \IT{(\MC*{PPRINT-POP})}
560 Take \retval{next element} off \VAR{list}. If there is no remaining
561 tail of \VAR{list}, or \V{\A print-length\A} or \V{\A print-circle\A} indicate
562 printing should end, send element together with an appropriate
563 indicator to \VAR{stream}.
566 \IT{(\FU*{PPRINT-TAB} \xorGOO{\kwd{:line}\\
567 \kwd{:line-relative}\\
568 \kwd{:section}\\
569 \kwd{:section-relative}}{\}} \VAR{c}
570 \VAR{i} \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
572 Move cursor forward to column number $c + ki$, $k \geq 0$ being as small
573 as possible.
576 \IT{(\FU*{PPRINT-INDENT} \xorGOO{%
577 \kwd{:block}\\
578 \kwd{:current}}{\}} \VAR{n}
579 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
581 Specify indentation for innermost logical block relative to
582 leftmost position/to current position. Return \retval{\NIL}.
585 \IT{(\MC*{PPRINT-EXIT-IF-LIST-EXHAUSTED})}
587 If \VAR{list} is empty, terminate logical block. Return
588 \retval{\NIL} otherwise.
591 \end{LIST}
593 \IT{(\FU*{PPRINT-NEWLINE} \xorGOO{%
594 \kwd{:linear}\\
595 \kwd{:fill}\\
596 \kwd{:miser}\\
597 \kwd{:mandatory}}{\}}
598 \OP{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
600 Print a conditional newline if \VAR{stream} is a pretty printing
601 stream. Return \retval{\NIL}.
604 \IT{\V{\A print-array\A}}
605 {\index{*PRINT-ARRAY*@\A PRINT-ARRAY\A}
606 If \T, print arrays \FU{read}ably.
609 \IT{\V{\A print-base\A}\DF{\LIT{10}}}
610 {\index{*PRINT-BASE*@\A PRINT-BASE\A}
611 Radix for printing rationals, from 2 to 36.
614 \IT{\V{\A print-case\A}\DF{\kwd{:upcase}}}
615 {\index{*PRINT-CASE*@\A PRINT-CASE\A}
616 Print symbol names all uppercase (\kwd{:upcase}), all lowercase
617 (\kwd{:downcase}), capitalized (\kwd{:capitalize}).
620 \IT{\V{\A print-circle\A}\DF{\NIL}}
621 {\index{*PRINT-CIRCLE*@\A PRINT-CIRCLE\A}
622 If \T, avoid indefinite recursion while printing circular
623 structure.
626 \IT{\V{\A print-escape\A}\DF{\T}}
627 {\index{*PRINT-ESCAPE*@\A PRINT-ESCAPE\A}
628 If \NIL, do not print escape characters and package prefixes.
631 \IT{\V{\A print-gensym\A}\DF{\T}}
632 {\index{*PRINT-GENSYM*@\A PRINT-GENSYM\A}
633 If \T, print \kwd{\#:} before uninterned symbols.
636 \IT{\arrGOO{\V{\A print-length\A}\DF{\NIL}\\
637 \V{\A print-level\A}\DF{\NIL}\\
638 \V{\A print-lines\A}\DF{\NIL}
639 }{.}}
640 {\index{*PRINT-LENGTH*@\A PRINT-LENGTH\A}\index{*PRINT-LEVEL*@\A PRINT-LEVEL\A}\index{*PRINT-LINES*@\A PRINT-LINES\A}
641 If integer, restrict printing of objects to that number of elements per
642 level/to that depth/to that number of lines.
645 \IT{\V{\A print-miser-width\A}}
646 {\index{*PRINT-MISER-WIDTH*@\A PRINT-MISER-WIDTH\A}
647 If integer and greater than the width available for printing a
648 substructure, switch to the more compact miser style.
651 \IT{\V{\A print-pretty\A}}
652 {\index{*PRINT-PRETTY*@\A PRINT-PRETTY\A}
653 If \T, print pretty.
656 \IT{\V{\A print-radix\A}\DF{\NIL}}
657 {\index{*PRINT-RADIX*@\A PRINT-RADIX\A}
658 If \T, print rationals with a radix indicator.
661 \IT{\V{\A print-readably\A}\DF{\NIL}}
662 {\index{*PRINT-READABLY*@\A PRINT-READABLY\A}
663 If \T, print \FU{read}ably or signal error
664 \kwd{print-not-readable}.
667 \IT{\V{\A print-right-margin\A}\DF{\NIL}}
668 {\index{*PRINT-RIGHT-MARGIN*@\A PRINT-RIGHT-MARGIN\A}
669 Right margin width in ems while pretty-printing.
672 \IT{(\FU*{SET-PPRINT-DISPATCH} \VAR{type} \VAR{function}
673 \OP{\VAR{priority}\DF{\LIT{0}}
674 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}}})}
676 Install entry comprising \VAR{function} of arguments stream and
677 object to print; and \VAR{priority} as
678 \VAR{type} into \VAR{table}. If \VAR{function}
679 is \NIL, remove \VAR{type} from \VAR{table}. Return \retval{\NIL}.
682 \IT{(\FU*{PPRINT-DISPATCH} \VAR{foo}
683 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
685 Return highest priority \retval{\VAR{function}} associated with type of
686 \VAR{foo} and \retvalii{\T} if there was a matching type specifier
687 in \VAR{table}.
690 \IT{(\FU*{COPY-PPRINT-DISPATCH}
691 \Op{\VAR{table}\DF{\V{\A print-pprint-dispatch\A}}})}
693 Return \retval{copy of \VAR{table}} or, if \VAR{table} is \NIL,
694 initial value of \V{\A print-pprint-dispatch\A}.
697 \IT{\V{\A print-pprint-dispatch\A}}
698 {\index{*PRINT-PPRINT-DISPATCH*@\A PRINT-PPRINT-DISPATCH\A}
699 Current pretty print dispatch table.
702 \end{LIST}
706 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
707 \subsection{Format}
708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
709 \label{section:Format}
711 \begin{LIST}{1cm}
713 \IT{(\MC*{FORMATTER} \NEV{\VAR{control}})}
715 Return \retval{function} of stream and a \kwd{\&rest} argument applying \FU{format} to
716 stream, \VAR{control}, and the \kwd{\&rest} argument
717 returning \NIL\ or any excess arguments.
720 \IT{(\FU*{FORMAT} \Goo{\T\XOR\NIL\XOR\VAR{out-string}\XOR\VAR{out-stream}}
721 \VAR{control} \OPn{\VAR{arg}})}
723 Output string \VAR{control} which may
724 contain \kwd{\TLD} directives possibly taking some
725 \VAR{arg}s. Alternatively, \VAR{control} can be a function returned
726 by \MC{formatter} which is then applied to \VAR{out-stream} and \OPn{\VAR{arg}}.
727 Output to \VAR{out-string}, \VAR{out-stream} or, if first
728 argument is \T, to \V{\A standard-output\A}. Return \retval{\NIL}. If
729 first argument is \NIL, return \retval{formatted output}.
732 \begin{LIST}{.5cm}
734 \IT{\KWD{\TLD} \Op{\VAR{min-col}\DF{\LIT{0}}} \OP{\KWD{,}\Op{\VAR{col-inc}\DF{\LIT{1}}}
735 \OP{\KWD{,}\Op{\VAR{min-pad}\DF{\LIT{0}}}
736 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
737 \KWD{\Op{:} \Op{@} \Goo{A\XOR S}}}
738 {\index{\~S@$\sim$S}\index{\~A@$\sim$A}%
739 \EM{Aesthetic/Standard. }
740 Print argument of any type for consumption by humans/by the
741 reader, respectively. With \kwd{:}, print \NIL\ as \LIT{()} rather
742 than \LIT{nil}; with \kwd{@}, add \VAR{pad-char}s on the left
743 rather than on the right.
746 \IT{\KWD{\TLD} \Op{\VAR{radix}\DF{\LIT{10}}} \OP{\KWD{,}\Op{\VAR{width}}
747 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
748 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
749 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}}
750 \KWD{\Op{:} \Op{@} R}}
751 {\index{\~R@$\sim$R}%
752 \EM{Radix. }
753 (With one or more prefix arguments.) Print argument as number; with
754 \KWD{:}, group digits \VAR{comma-interval} each; with \kwd{@},
755 always prepend a sign.
758 \IT{\Goo{\KWD{\TLD R}\XOR\KWD{\TLD :R}\XOR\KWD{\TLD
759 @R}\XOR\KWD{\TLD @:R}}}
761 \EM{Roman. }
762 Take argument as number and print it as English cardinal number,
763 as English ordinal number, as Roman numeral, or as old Roman
764 numeral, respectively.
767 \IT{\KWD{\TLD} \Op{\VAR{width}}
768 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
769 \OP{\KWD{,}\Op{\VAR{comma-char}\DF{\kwd{'}\LIT{,}}}
770 \OP{\KWD{,}\VAR{comma-interval}\DF{\LIT{3}}}}}
771 \KWD{\Op{:} \Op{@} \Goo{D\XOR B\XOR O\XOR X}}}
772 {\index{\~D@$\sim$D}\index{\~B@$\sim$B}\index{\~O@$\sim$O}\index{\~X@$\sim$X}%
773 \EM{Decimal/Binary/Octal/Hexadecimal. }
774 Print integer argument as number. With \kwd{:}, group digits
775 \VAR{comma-interval} each; with \kwd{@}, always prepend a sign.
778 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{dec-digits}}
779 \OP{\KWD{,}\Op{\VAR{shift}\DF{\LIT{0}}}
780 \OP{\KWD{,}\Op{\VAR{overflow-char}}
781 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}}
782 \KWD{\Op{@} F}}
783 {\index{\~F@$\sim$F}%
784 \EM{Fixed-Format Floating-Point. } With
785 \kwd{@}, always pre\-pend a sign.
788 \IT{\KWD{\TLD} \Op{\VAR{width}} \OP{\KWD{,}\Op{\VAR{int-digits}}
789 \OP{\KWD{,}\Op{\VAR{exp-digits}}
790 \OP{\KWD{,}\Op{\VAR{scale-factor}\DF{\LIT{1}}}
791 \OP{\KWD{,}\Op{\VAR{overflow-char}}
792 \OP{\KWD{,}\Op{\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}
793 \OP{\KWD{,}\VAR{exp-char}}}}}}}
794 \KWD{\Op{@} \Goo{E\XOR G}}}
795 {\index{\~E@$\sim$E}\index{\~G@$\sim$G}%
796 \EM{Exponential/General Floating-Point. }
797 Print argument as floating-point number with \VAR{int-digits}
798 before decimal point and \VAR{exp-digits} in the signed
799 exponent. With \KWD{\TLD G}, choose either \KWD{\TLD E} or
800 \KWD{\TLD F}. With \KWD{@}, always prepend a sign.
803 \IT{\KWD{\TLD} \Op{\VAR{dec-digits}\DF{\LIT{2}}}
804 \OP{\KWD{,}\Op{\VAR{int-digits}\DF{\LIT{1}}}
805 \OP{\KWD{,}\Op{\VAR{width}\DF{\LIT{0}}}
806 \OP{\KWD{,}\VAR{pad-char}\DF{\kwd{'}\textvisiblespace}}}}
807 \Op{\KWD{:}} \Op{\kwd{@}} \KWD{\$}}
808 {\index{\~\$@$\sim$\$}%
809 \EM{Monetary Floating-Point. }
810 Print argument as fixed-format floating-point number. With \KWD{:},
811 put sign before any padding; with \KWD{@}, always prepend a sign.}
813 \IT{\Goo{\KWD{\TLD C}\XOR\KWD{\TLD :C}\XOR\KWD{\TLD
814 @C}\XOR\KWD{\TLD @:C}}}
815 {\index{\~C@$\sim$C}%
816 \EM{Character. }
817 Print, spell out, print in \kwd{\#$\backslash$} syntax, or tell
818 how to type, respectively, argument as (possibly non-printing)
819 character.
822 \IT{\Goo{%
823 \KWD{\TLD(} \VAR{text} \KWD{\TLD)}\XOR
824 \KWD{\TLD:(} \VAR{text} \KWD{\TLD)}\XOR
825 \KWD{\TLD @(} \VAR{text} \KWD{\TLD)}\XOR
826 \KWD{\TLD:@(} \VAR{text} \KWD{\TLD)}}}
827 {\index{\~(\~)@$\sim$( $\sim$)}%
828 \EM{Case-Conversion. }
829 Convert \VAR{text} to lowercase, convert first letter of each word
830 to uppercase, capitalize first word and convert the rest to
831 lowercase, or convert to uppercase, respectively.
834 \IT{\Goo{\KWD{\TLD P}\XOR\KWD{\TLD:P}
835 \XOR\KWD{\TLD @P}\XOR\KWD{\TLD:@P}}}
836 {\index{\~P@$\sim$P}%
837 \EM{Plural. }
838 If argument \kwd{eql} \LIT{1} print nothing, otherwise print \LIT{s};
839 do the same for the previous argument; if argument \kwd{eql} \LIT{1}
840 print \LIT{y}, otherwise print \LIT{ies}; do the same for the
841 previous argument, respectively.
844 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\%}}
845 {\index{\~\%@$\sim$\%}%
846 \EM{Newline. }
847 Print \VAR{n} newlines.
850 \IT{\KWD{\TLD} \Op{\VAR{n}\DF{\LIT{1}}} \KWD{\&}}
851 {\index{\~\&@$\sim$\&}%
852 \EM{Fresh-Line. }
853 Print $n-1$ newlines if output stream is at the
854 beginning of a line, or \VAR{n} newlines otherwise.
857 \IT{\Goo{\KWD{\TLD\_}\XOR\KWD{\TLD:\_}\XOR\KWD{\TLD@\_}\XOR\KWD{\TLD:@\_}}}
858 {\index{\~\_{}@$\sim$\_{}}%
859 \EM{Conditional Newline. }
860 Print a newline like \kwd{pprint-newline} with argument
861 \kwd{:linear}, \kwd{:fill}, \kwd{:miser}, or \kwd{:mandatory}, respectively.
864 \IT{\KWD{\TLD} \Op{\KWD{:}} \Op{\KWD{@}} $\hookleftarrow$}
866 \EM{Ignored Newline. } Ignore newline and following
867 whitespace. With \kwd{:}, ignore only newline; with \kwd{@},
868 ignore only following whitespace.
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{,\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} \xorGOO{\kwd{:input}\\
1019 \kwd{:output}\\
1020 \kwd{:io}\\
1021 \kwd{:probe}}{\}}\DF{\kwd{:input}}\\
1022 \kwd{:element-type} \VAR{ type}\DF{\kwd{character}}\\
1023 \kwd{:if-exists}
1024 \xorGOO{\kwd{:new-version}\\
1025 \kwd{:error}\\
1026 \kwd{:rename}\\
1027 \kwd{:rename-and-delete}\\
1028 \kwd{:overwrite}\\
1029 \kwd{:append}\\
1030 \kwd{:supersede}\\
1031 \NIL}{.}\\
1032 \kwd{:if-does-not exist} \xorGOO{\kwd{:error}\\
1033 \kwd{:create}\\
1034 \NIL}{.}\\
1035 \kwd{:external-format } \VAR{format}\DF{\kwd{:default}}%
1036 }{\}})}
1037 {\label{open}
1038 Open \retval{\kwd{file-stream} to \VAR{path}}.
1041 \IT{\arrGOO{%
1042 (\FU*{MAKE-CONCATENATED-STREAM } \OPn{\VAR{input-stream}})\\
1043 (\FU*{MAKE-BROADCAST-STREAM } \OPn{\VAR{output-stream}})\\
1044 (\FU*{MAKE-TWO-WAY-STREAM } \VAR{input-stream-part } \VAR{output-stream-part})\\
1045 (\FU*{MAKE-ECHO-STREAM } \VAR{from-input-stream } \VAR{to-output-stream})\\
1046 (\FU*{MAKE-SYNONYM-STREAM } \VAR{variable-bound-to-stream})}{.}}
1048 Return \retval{stream} of indicated type.
1051 \IT{(\FU*{MAKE-STRING-INPUT-STREAM} \VAR{string}
1052 \OP{\VAR{start}\DF{\LIT{0}}
1053 \Op{\VAR{end}\DF{\NIL}}})}
1055 Return a \retval{\kwd{string-stream}} supplying the characters from \VAR{string}.
1058 \IT{(\FU*{MAKE-STRING-OUTPUT-STREAM} \Op{\kwd{:element-type}
1059 \VAR{type}\DF{\kwd{character}}})}
1061 Return a \retval{\kwd{string-stream}} accepting characters
1062 (available via \FU{get-output-stream-string}).
1065 \IT{\arrGOO{(\FU*{CONCATENATED-STREAM-STREAMS } \VAR{concatenated-stream})\\
1066 (\FU*{BROADCAST-STREAM-STREAMS } \VAR{broadcast-stream})}{.}}
1068 Return \retval{list of streams} \VAR{concatenated-stream} still
1069 has to read from/\VAR{broadcast-stream} is
1070 broadcasting to.
1073 \IT{\arrGOO{%
1074 (\FU*{TWO-WAY-STREAM-INPUT-STREAM} \VAR{ two-way-stream})\\
1075 (\FU*{TWO-WAY-STREAM-OUTPUT-STREAM} \VAR{ two-way-stream})\\
1076 (\FU*{ECHO-STREAM-INPUT-STREAM} \VAR{ echo-stream})\\
1077 (\FU*{ECHO-STREAM-OUTPUT-STREAM} \VAR{ echo-stream})}{.}}
1079 Return \retval{source stream} or \retval{sink stream} of
1080 \VAR{two-way-stream}\slash\VAR{echo-stream}, respectively.
1083 \IT{(\FU*{SYNONYM-STREAM-SYMBOL} \VAR{synonym-stream})}
1085 Return \retval{symbol} of \VAR{synonym-stream}.
1088 \IT{(\FU*{GET-OUTPUT-STREAM-STRING} \DES{\VAR{string-stream}})}
1090 Clear and return as a \retval{string} characters on \VAR{string-stream}.
1093 \IT{(\FU*{LISTEN} \Op{\VAR{stream}\DF{\V{\A standard-input\A}}})}
1095 \retval{\T} if there is a character in input \VAR{stream}.
1098 \IT{(\FU*{CLEAR-INPUT}
1099 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-input\A}}})}
1101 Clear input from \VAR{stream}, return \retval{\NIL}.
1104 \IT{(\xorGOO{\FU*{CLEAR-OUTPUT}\\
1105 \FU*{FORCE-OUTPUT}\\
1106 \FU*{FINISH-OUTPUT}}{\}}
1107 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
1109 End output to \VAR{stream} and return \retval{\NIL} immediately,
1110 after initiating flushing of buffers, or after flushing of buffers,
1111 respectively.
1114 \IT{(\FU*{CLOSE} \DES{\VAR{stream}} \Op{\kwd{:abort}
1115 \VAR{bool}\DF{\NIL}})}
1117 Close \VAR{stream}. Return \retval{\T} if \VAR{stream} had been
1118 open. If \kwd{:abort} is \T, delete associated file.
1121 \IT{(\MC*{WITH-OPEN-STREAM} (\VAR{foo} \DES{\VAR{stream}})
1122 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1124 Evaluate \VAR{form}s with \VAR{foo} locally bound to
1125 \VAR{stream}. Return \retval{values of \VAR{form}s}.
1128 \IT{(\MC*{WITH-INPUT-FROM-STRING} (\VAR{foo} \VAR{string}
1129 \orGOO{\kwd{:index } \DES{\VAR{index}}\\
1130 \kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1131 \kwd{:end} \VAR{ end}\DF{\NIL}}{\}}) \OPn{(\kwd{declare}
1132 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1134 Evaluate \VAR{form}s with \VAR{foo} locally bound to input \kwd{string-stream}
1135 from \VAR{string}. Return \retval{values of \VAR{form}s}; store next
1136 reading position into \VAR{index}.
1139 \IT{(\MC*{WITH-OUTPUT-TO-STRING} (\VAR{foo}
1140 \Op{\DES{\VAR{string}}\DF{\NIL}} \Op{\kwd{:element-type}
1141 \VAR{type}\DF{\kwd{character}}}) \OPn{(\kwd{declare}
1142 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
1144 Evaluate \VAR{form}s with \VAR{foo} locally bound to an output
1145 \kwd{string-stream}. Append output to \VAR{string} and return
1146 \retval{values of \VAR{form}s} if \VAR{string} is given. Return
1147 \retval{string containing output} otherwise.
1150 \IT{(\FU*{STREAM-EXTERNAL-FORMAT} \VAR{stream})}
1152 \retval{External file format designator}.
1155 \IT{\V{\A terminal-io\A}}
1156 {\index{*TERMINAL-IO*@\A TERMINAL-IO\A}
1157 Bidirectional stream to user terminal.
1160 \IT{\arrGOO{\V{\A standard-input\A}\\
1161 \V{\A standard-output\A}\\
1162 \V{\A error-output\A}}{.}}
1163 {\index{*STANDARD-INPUT*@\A STANDARD-INPUT\A}%
1164 \index{*STANDARD-OUTPUT*@\A STANDARD-OUTPUT\A}%
1165 \index{*ERROR-OUTPUT*@\A ERROR-OUTPUT\A}
1166 Standard input stream, standard output stream,
1167 or standard error output stream, respectively.
1170 \IT{\arrGOO{\V{\A debug-io\A}\\
1171 \V{\A query-io\A}}{.}}
1172 {\index{*DEBUG-IO*@\A DEBUG-IO\A}\index{*QUERY-IO*@\A QUERY-IO\A}
1173 Bidirectional streams for debugging and user interaction.
1176 \end{LIST}
1179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1180 \subsection{Files}
1181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1183 \begin{LIST}{1cm}
1185 \IT{(\FU*{MAKE-PATHNAME}
1186 \orGOO{\kwd{:host } \Goo{\VAR{host}\XOR\NIL\XOR\kwd{:unspecific}}\\
1187 \kwd{:device } \Goo{\VAR{device}\XOR\NIL\XOR\kwd{:unspecific}}\\
1188 \kwd{:directory } \xorGOO{%
1189 \Goo{\VAR{directory}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1190 (\xorGOO{%
1191 \kwd{:absolute}\\
1192 \kwd{:relative}
1193 }{\}}\text{ }%
1194 \xorGOO{%
1195 \VAR{directory}\\
1196 \kwd{:wild}\\
1197 \kwd{:wild-inferiors}\\
1198 \kwd{:up}\\
1199 \kwd{:back}
1200 }{\}^{\!\!*}})
1201 }{.}\\
1202 \kwd{:name } \Goo{\VAR{file-name}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1203 \kwd{:type } \Goo{\VAR{file-type}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1204 \kwd{:version } \Goo{\kwd{:newest}\XOR\VAR{version}\XOR\kwd{:wild}\XOR\NIL\XOR\kwd{:unspecific}}\\
1205 \kwd{:defaults } \VAR{path}\DF{host from \V{\A default-pathname-defaults\A}}\\
1206 \kwd{:case
1207 \Goo{\kwd{:local}\XOR\kwd{:common}}\DF{\kwd{:local}}}}{\}})}
1209 Construct \retval{pathname}.
1210 For \kwd{:case :local}, leave case of components unchanged.
1211 For \kwd{:case :common}, leave mixed-case components unchanged;
1212 convert all-uppercase components into
1213 local customary case; do the opposite with all-lowercase
1214 components.
1217 \IT{\arrGOO{%
1218 (\xorGOO{\FU*{PATHNAME-HOST}\\
1219 \FU*{PATHNAME-DEVICE}\\
1220 \FU*{PATHNAME-DIRECTORY}\\
1221 \FU*{PATHNAME-NAME}\\
1222 \FU*{PATHNAME-TYPE}}{\}}
1223 \VAR{ path }
1224 \Op{\kwd{:case } \xorGOO{\kwd{:local}\\
1225 \kwd{:common}}{\}}\DF{\kwd{:local}}})\\
1226 (\FU*{PATHNAME-VERSION } \VAR{path})}{.}}
1228 Return \retval{pathname component}.
1231 \IT{(\FU*{PARSE-NAMESTRING} \VAR{foo}
1232 \OP{\VAR{host}
1233 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1234 \orGOO{\kwd{:start} \VAR{ start}\DF{\LIT{0}}\\
1235 \kwd{:end} \VAR{ end}\DF{\NIL}\\
1236 \kwd{:junk-allowed} \VAR{ bool}\DF{\NIL}}{\}}}})}
1238 Return \retval{pathname} converted from
1239 string, pathname, or stream \VAR{foo}; and \retvalii{position}
1240 where parsing stopped.
1243 \IT{(\FU*{MERGE-PATHNAMES} \VAR{pathname}
1244 \OP{\VAR{default-pathname}\DF{\V{\A default-pathname-defaults\A}}
1245 \Op{\VAR{default-version}\DF{\kwd{:newest}}}})}
1247 Return \retval{\VAR{pathname}} after filling in missing components
1248 from \VAR{default-pathname}.
1251 \IT{\V{\A default-pathname-defaults\A}}
1252 {\index{*DEFAULT-PATHNAME-DEFAULTS*@\A DEFAULT-PATHNAME-DEFAULTS\A}
1253 Pathname to use if one is needed and none supplied.
1256 \IT{(\FU*{USER-HOMEDIR-PATHNAME} \Op{\VAR{host}})}
1258 User's \retval{home directory}.
1261 \IT{(\FU*{ENOUGH-NAMESTRING} \VAR{path}
1262 \Op{\VAR{root-path}\DF{\V{\A default-pathname-defaults\A}}})}
1264 Return \retval{minimal path string} to sufficiently describe
1265 \VAR{path} relative to \VAR{root-path.}
1268 \IT{\arrGOO{(\FU*{NAMESTRING}\VAR{ path})\\
1269 (\FU*{FILE-NAMESTRING}\VAR{ path})\\
1270 (\FU*{DIRECTORY-NAMESTRING}\VAR{ path})\\
1271 (\FU*{HOST-NAMESTRING}\VAR{ path})}{.}}
1273 Return string representing \retval{full pathname}; \retval{name,
1274 type, and version}; \retval{directory name}; or \retval{host
1275 name}, respectively, of \VAR{path}.
1278 \IT{(\FU*{TRANSLATE-PATHNAME} \VAR{path} \VAR{wildcard-path-a}
1279 \VAR{wildcard-path-b})}
1281 Translate \VAR{path} from \VAR{wildcard-path-a} into
1282 \VAR{wildcard-path-b}. Return \retval{new path}.
1285 \IT{(\FU*{PATHNAME} \VAR{path})}
1287 \retval{Pathname} of \VAR{path}.
1290 \IT{(\FU*{LOGICAL-PATHNAME} \VAR{logical-path})}
1292 \retval{Logical pathname} of \VAR{logical-path}.
1293 Logical pathnames are represented as all-uppercase
1294 \LIT{\#P"}%
1295 \Op{\VAR{host}\LIT{:}}\Op{\LIT{:}}%
1296 \Goos{\xorGOO{%
1297 \Goop{\VAR{dir}\XOR\LIT{*}}\\
1298 \LIT{**}}{\}}\LIT{;}}%
1299 \penalty-5
1300 \Goos{\VAR{name}\XOR\LIT{*}}%
1301 \OP{\LIT{.}%
1302 \xorGOO{%
1303 \Goop{\VAR{type}\XOR\LIT{*}}\\
1304 \LIT{LISP}}{\}}%
1305 \Op{\LIT{.}%
1306 \Goo{%
1307 \VAR{version}\XOR\LIT{*}\XOR\LIT{newest}\XOR\LIT{NEWEST}}}}%
1308 \LIT{"}.
1311 \IT{(\FU*{LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1313 \retval{List of (\VAR{from-wildcard to-wildcard}) translations} for \VAR{logical-host}. \kwd{setf}able.
1316 \IT{(\FU*{LOAD-LOGICAL-PATHNAME-TRANSLATIONS} \VAR{logical-host})}
1318 Load \VAR{logical-host}'s translations. Return \retval{\NIL} if already
1319 loaded; return \retval{\T} if successful.
1322 \IT{(\FU*{TRANSLATE-LOGICAL-PATHNAME} \VAR{pathname})}
1324 \retval{Physical pathname} corresponding to (possibly logical) \VAR{pathname}.
1327 \IT{\arrGOO{(\FU*{PROBE-FILE} \VAR{ file})\\
1328 (\FU*{TRUENAME} \VAR{ file})}{.}}
1330 \retval{Canonical name} of \VAR{file}. If \VAR{file} does not exist,
1331 return \retval{\NIL}/signal \kwd{file-error}, respectively.
1334 \IT{(\FU*{FILE-WRITE-DATE} \VAR{file})}
1336 \retval{Time} at which \VAR{file} was last written.
1339 \IT{(\FU*{FILE-AUTHOR} \VAR{file})\qquad\qquad}
1341 Return \retval{name of \VAR{file} owner}.
1344 \IT{(\FU*{FILE-LENGTH} \VAR{stream})}
1346 Return \retval{length of \VAR{stream}}.
1349 \IT{(\FU*{FILE-POSITION} \VAR{stream} \Op{\xorGOO{\kwd{:start}\\
1350 \kwd{:end}\\
1351 \VAR{position}}{\}}})}
1353 Return \retval{position within stream}, or set it to
1354 \retval{\VAR{position}} and return \retval{\T} on success.
1357 \IT{(\FU*{FILE-STRING-LENGTH} \VAR{stream} \VAR{foo})}
1359 \retval{Length} \VAR{foo} would have in \VAR{stream}.
1362 \IT{(\FU*{RENAME-FILE} \VAR{foo} \VAR{bar})}
1364 Rename file \VAR{foo} to \VAR{bar}. Unspecified components of path
1365 \VAR{bar} default to those of \VAR{foo}. Return \retval{new
1366 pathname}, \retvalii{old physical file name}, and \retvaliii{new
1367 physical file name}.
1370 \IT{(\FU*{DELETE-FILE} \VAR{file})}
1372 Delete \VAR{file}. Return \retval{\T}.
1375 \IT{(\FU*{DIRECTORY} \VAR{path})}
1377 \retval{List of pathnames} matching \VAR{path}.
1380 \IT{(\FU*{ENSURE-DIRECTORIES-EXIST} \VAR{path} \Op{\kwd{:verbose}
1381 \VAR{bool}})}
1383 Create parts of \retval{\VAR{path}} if necessary. Second return value is
1384 \retvalii{\T} if something has been created.
1387 \IT{(\MC*{WITH-OPEN-FILE} (\VAR{stream} \VAR{path}
1388 \OPn{\VAR{open-arg}}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
1389 \PROGN{\VAR{form}})}
1391 Use \FU{OPEN} with \VAR{open-arg}s (cf.\ page \pageref{open}) to temporarily
1392 create \VAR{stream} to \VAR{path}; return \retval{values of \VAR{form}s}.
1396 \end{LIST}
1400 % LocalWords: ies argumenth ar gu ment
1402 %%% Local Variables:
1403 %%% mode: latex
1404 %%% TeX-master: "clqr"
1405 %%% End: