concept-pprint.tex 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. % -*- Mode: TeX -*-
  2. \issue{PRETTY-PRINT-INTERFACE}
  3. \beginsubSection{Pretty Printer Concepts}
  4. The facilities provided by the \newterm{pretty printer} permit
  5. \term{programs} to redefine the way in which \term{code} is displayed,
  6. and allow the full power of \term{pretty printing} to be applied
  7. to complex combinations of data structures.
  8. Whether any given style of output is in fact ``pretty'' is inherently a
  9. somewhat subjective issue. However, since the effect of the
  10. \term{pretty printer} can be customized by \term{conforming programs},
  11. the necessary flexibility is provided for individual \term{programs}
  12. to achieve an arbitrary degree of aesthetic control.
  13. By providing direct access to the mechanisms within the pretty printer
  14. that make dynamic decisions about layout, the macros and functions
  15. \macref{pprint-logical-block}, \funref{pprint-newline}, and
  16. \funref{pprint-indent} make it possible to specify pretty printing
  17. layout rules as a part of any function that produces output. They also
  18. make it very easy for the detection of circularity and sharing, and
  19. abbreviation based on length and nesting depth to be supported by the
  20. function.
  21. The \term{pretty printer} is driven entirely by dispatch based on
  22. \thevalueof{*print-pprint-dispatch*}.
  23. \Thefunction{set-pprint-dispatch} makes it possible
  24. for \term{conforming programs} to associate new pretty printing
  25. functions with a \term{type}.
  26. \beginsubsubsection{Dynamic Control of the Arrangement of Output}
  27. \DefineSection{DynamicControlofOutput}
  28. The actions of the \term{pretty printer} when a piece of output is too
  29. large to fit in the space available can be precisely controlled.
  30. Three concepts underlie
  31. the way these operations work---\newterm{logical blocks},
  32. \newterm{conditional newlines},
  33. and \newterm{sections}.
  34. Before proceeding further, it is important to define these terms.
  35. The first line of \thenextfigure\ shows a schematic piece of output. Each of
  36. the characters in the output is represented by ``\f{-}''. The positions of
  37. conditional newlines are indicated by digits. The beginnings and ends of
  38. logical blocks are indicated by ``\f{<}'' and ``\f{>}'' respectively.
  39. The output as a whole is a logical block and the outermost section. This
  40. section is indicated by the \f{0}'s on the second line of Figure 1. Logical
  41. blocks nested within the output are specified by the macro
  42. \macref{pprint-logical-block}. Conditional newline positions are specified
  43. by calls to \funref{pprint-newline}. Each conditional newline defines
  44. two sections (one before it and one after it) and is associated with a
  45. third (the section immediately containing it).
  46. The section after a conditional newline consists of: all the output up to,
  47. but not including, (a) the next conditional newline immediately contained
  48. in the same logical block; or if (a) is not applicable, (b) the next
  49. newline that is at a lesser level of nesting in logical blocks; or if (b)
  50. is not applicable, (c) the end of the output.
  51. The section before a conditional newline consists of: all the output back
  52. to, but not including, (a) the previous conditional newline that is
  53. immediately contained in the same logical block; or if (a) is not
  54. applicable, (b) the beginning of the immediately containing logical block.
  55. The last four lines in Figure 1 indicate the sections before and after the
  56. four conditional newlines.
  57. The section immediately containing a conditional newline is the shortest
  58. section that contains the conditional newline in question. In \thenextfigure,
  59. the first conditional newline is immediately contained in the section
  60. marked with \f{0}'s, the second and third conditional newlines are immediately
  61. contained in the section before the fourth conditional newline, and the
  62. fourth conditional newline is immediately contained in the section after
  63. the first conditional newline.
  64. \code
  65. <-1---<--<--2---3->--4-->->
  66. 000000000000000000000000000
  67. 11 111111111111111111111111
  68. 22 222
  69. 333 3333
  70. 44444444444444 44444
  71. \endcode
  72. \simplecaption{Example of Logical Blocks, Conditional Newlines, and Sections}
  73. Whenever possible, the pretty printer displays the entire contents of a
  74. section on a single line. However, if the section is too long to fit in
  75. the space available, line breaks are inserted at conditional newline
  76. positions within the section.
  77. \endsubsubsection%{Dynamic Control of the Arrangement of Output}
  78. \beginsubsubsection{Format Directive Interface}
  79. The primary interface to operations for dynamically determining the
  80. arrangement of output is provided through the functions and macros of the
  81. pretty printer. \Thenextfigure\ shows the defined names related to \term{pretty printing}.
  82. \displaythree{Defined names related to pretty printing.}{
  83. *print-lines*&pprint-dispatch&pprint-pop\cr
  84. *print-miser-width*&pprint-exit-if-list-exhausted&pprint-tab\cr
  85. *print-pprint-dispatch*&pprint-fill&pprint-tabular\cr
  86. *print-right-margin*&pprint-indent&set-pprint-dispatch\cr
  87. copy-pprint-dispatch&pprint-linear&write\cr
  88. format&pprint-logical-block&\cr
  89. formatter&pprint-newline&\cr
  90. }
  91. \Thenextfigure\ identifies a set of \term{format directives} which serve
  92. as an alternate interface to the same pretty printing operations in a
  93. more textually compact form.
  94. %%Only of interest historically. -kmp
  95. %In addition, it permits one would have to abandon the use of \funref{format}
  96. %when interacting with the pretty printer.
  97. \displaythree{Format directives related to Pretty Printing}{
  98. \formatOp{I}&\formatOp{W}&\formatOp{<...~:>}\cr
  99. \formatOp{:T}&\formatOp{/.../}&\formatOp{_}\cr
  100. }
  101. \endsubsubsection%{Format Directive Interface}
  102. \beginsubsubsection{Compiling Format Strings}
  103. \DefineSection{CompilingFormatStrings}
  104. \issue{FORMAT-STRING-ARGUMENTS:SPECIFY}
  105. A \term{format string} is essentially a program in a special-purpose language
  106. that performs printing, and that is interpreted by \thefunction{format}.
  107. \Themacro{formatter} provides the efficiency of using a \term{compiled function}
  108. to do that same printing but without losing the textual compactness of \term{format strings}.
  109. A \newterm{format control} is either a \term{format string} or a \term{function}
  110. that was returned by the \themacro{formatter}.
  111. \endissue{FORMAT-STRING-ARGUMENTS:SPECIFY}
  112. \endsubsubsection%{Compiling Format Strings}
  113. \beginsubsubsection{Pretty Print Dispatch Tables}
  114. \DefineSection{PPrintDispatchTables}
  115. \issue{GENERALIZE-PRETTY-PRINTER:UNIFY}
  116. %KAB: Are all type specifiers really valid?
  117. %Waters: Yes.
  118. %KMP: Actually, CONS was not originally valid, but has been added due to a cleanup.
  119. A \newterm{pprint dispatch table} is a mapping from keys to pairs of values.
  120. Each key is a \term{type specifier}.
  121. The values associated with a key are
  122. a ``function'' (specifically, a \term{function designator} or \nil)
  123. %% Per X3J13. -kmp 05-Oct-93
  124. % and a ``numerical priorities'' (specifically, a \term{real}).
  125. and a ``numerical priority'' (specifically, a \term{real}).
  126. Basic insertion and retrieval is done based on the keys with the equality
  127. of keys being tested by \funref{equal}.
  128. When \varref{*print-pretty*} is \term{true},
  129. the \newterm{current pprint dispatch table} (in \varref{*print-pprint-dispatch*})
  130. controls how \term{objects} are printed.
  131. The information in this table takes precedence over
  132. all other mechanisms for specifying how to print \term{objects}.
  133. In particular, it
  134. %overrides
  135. has priority over
  136. user-defined \funref{print-object} \term{methods}
  137. \issue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:X3J13-MAR-93}
  138. %and print functions for \term{structures}
  139. \endissue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:X3J13-MAR-93}
  140. because the \term{current pprint dispatch table} is consulted first.
  141. %%Just trying to simplify wording to fit context. -kmp 27-Aug-93
  142. %The function to use when \term{pretty printing} an \term{object} is chosen
  143. The function is chosen from the \term{current pprint dispatch table}
  144. by finding the highest priority function
  145. %% Again, this should follow from context.
  146. %from the \term{current pprint dispatch table}
  147. that is associated with a \term{type specifier} that matches the \term{object};
  148. %KAB: What if there are several matches with equal priority?
  149. %Waters: It's not well-defined.
  150. %KMP: I've added this text to clarify that point:
  151. if there is more than one such function,
  152. it is \term{implementation-dependent} which is used.
  153. However, if there is no
  154. %% better parallel construction. -kmp 27-Aug-93
  155. %specification
  156. information in the table
  157. about how to \term{pretty print} a particular kind of \term{object},
  158. % it is then printed using the standard mechanisms as if
  159. % \varref{*print-pretty*} were \term{false}.
  160. a \term{function} is invoked which uses \funref{print-object} to print the \term{object}.
  161. The value of \varref{*print-pretty*} is still \term{true}
  162. when this function is \term{called},
  163. and individual methods for \funref{print-object} might still elect to
  164. produce output in a special format conditional on \thevalueof{*print-pretty*}.
  165. \endissue{GENERALIZE-PRETTY-PRINTER:UNIFY}
  166. \endsubsubsection%{Pretty Print Dispatch Tables}
  167. \beginsubsubsection{Pretty Printer Margins}
  168. A primary goal of pretty printing is to keep the output between a pair of
  169. margins.
  170. %This used to say:
  171. % The left margin is set at the column where the output begins.
  172. %KMP asked:
  173. % Does this mean that
  174. % a. the cursor is moved
  175. % b. the position at the cursor is assumed to be zero
  176. % c. that the position at the cursor becomes the new left margin?
  177. %Waters replied (c), so the following new sentence was made:
  178. The column where the output begins is taken as the left margin.
  179. %This used to say:
  180. % If this cannot be determined, the left margin is set to zero.
  181. %KMP asked:
  182. % Does this mean ``assumed to be''
  183. %Waters replied yes, so the following new sentence was made:
  184. If the current column cannot be determined at the time output begins,
  185. the left margin is assumed to be zero.
  186. The right margin is controlled by \varref{*print-right-margin*}.
  187. \endsubsubsection%{Pretty Printer Margins}
  188. \endsubSection%{Pretty Printer Concepts}
  189. \beginsubSection{Examples of using the Pretty Printer}
  190. \DefineSection{PrettyPrinterExamples}
  191. As an example of the interaction of logical blocks, conditional newlines,
  192. and indentation, consider the function \f{simple-pprint-defun} below. This
  193. function prints out lists whose \term{cars} are \macref{defun} in the
  194. standard way assuming that the list has exactly length \f{4}.
  195. \code
  196. (defun simple-pprint-defun (*standard-output* list)
  197. (pprint-logical-block (*standard-output* list :prefix "(" :suffix ")")
  198. (write (first list))
  199. (write-char #\\Space)
  200. (pprint-newline :miser)
  201. (pprint-indent :current 0)
  202. (write (second list))
  203. (write-char #\\Space)
  204. (pprint-newline :fill)
  205. (write (third list))
  206. (pprint-indent :block 1)
  207. (write-char #\\Space)
  208. (pprint-newline :linear)
  209. (write (fourth list))))
  210. \endcode
  211. Suppose that one evaluates the following:
  212. \code
  213. (simple-pprint-defun *standard-output* '(defun prod (x y) (* x y)))
  214. \endcode
  215. If the line width available is greater than or equal to \f{26}, then all of the
  216. output appears on one line. If the line width available is reduced to \f{25},
  217. a line break is inserted at the
  218. linear-style conditional newline\idxtext{linear-style conditional newline}
  219. before the
  220. \term{expression} \f{(* x y)}, producing the output shown. The
  221. \f{(pprint-indent :block 1)} causes \f{(* x y)} to be printed at a relative
  222. indentation of \f{1} in the logical block.
  223. \code
  224. (DEFUN PROD (X Y)
  225. (* X Y))
  226. \endcode
  227. If the line width available is \f{15}, a line break is also inserted at the
  228. fill style conditional newline before the argument list. The call on
  229. \f{(pprint-indent :current 0)} causes the argument list to line up under the
  230. function name.
  231. \code
  232. (DEFUN PROD
  233. (X Y)
  234. (* X Y))
  235. \endcode
  236. If \varref{*print-miser-width*} were greater than or equal to 14, the example
  237. output above would have been as follows, because all indentation changes
  238. are ignored in miser mode and line breaks are inserted at
  239. miser-style conditional newlines.\idxtext{miser-style conditional newline}
  240. \code
  241. (DEFUN
  242. PROD
  243. (X Y)
  244. (* X Y))
  245. \endcode
  246. As an example of a per-line prefix, consider that evaluating the following
  247. produces the output shown with a line width of \f{20} and
  248. \varref{*print-miser-width*} of \nil.
  249. \code
  250. (pprint-logical-block (*standard-output* nil :per-line-prefix ";;; ")
  251. (simple-pprint-defun *standard-output* '(defun prod (x y) (* x y))))
  252. ;;; (DEFUN PROD
  253. ;;; (X Y)
  254. ;;; (* X Y))
  255. \endcode
  256. As a more complex (and realistic) example, consider the function \f{pprint-let}
  257. below. This specifies how to print a \specref{let} \term{form} in the traditional
  258. style. It is more complex than the example above, because it has to deal with
  259. nested structure. Also, unlike the example above it contains complete code to
  260. readably print any possible list that begins with the \term{symbol} \specref{let}.
  261. The outermost \macref{pprint-logical-block} \term{form} handles the printing of
  262. the input list as a whole and specifies that parentheses should be printed in the
  263. output. The second \macref{pprint-logical-block} \term{form} handles the list
  264. of binding pairs. Each pair in the list is itself printed by the innermost
  265. \macref{pprint-logical-block}. (A \macref{loop} \term{form} is used instead of
  266. merely decomposing the pair into two \term{objects} so that readable output will
  267. be produced no matter whether the list corresponding to the pair has one element,
  268. two elements, or (being malformed) has more than two elements.)
  269. A space and a
  270. fill-style conditional newline\idxtext{fill-style conditional newline}
  271. are placed after
  272. each pair except the last. The loop at the end of the topmost
  273. \macref{pprint-logical-block} \term{form} prints out the forms in the body
  274. of the \specref{let} \term{form} separated by spaces and
  275. linear-style conditional newlines.
  276. \code
  277. (defun pprint-let (*standard-output* list)
  278. (pprint-logical-block (nil list :prefix "(" :suffix ")")
  279. (write (pprint-pop))
  280. (pprint-exit-if-list-exhausted)
  281. (write-char #\\Space)
  282. (pprint-logical-block (nil (pprint-pop) :prefix "(" :suffix ")")
  283. (pprint-exit-if-list-exhausted)
  284. (loop (pprint-logical-block (nil (pprint-pop) :prefix "(" :suffix ")")
  285. (pprint-exit-if-list-exhausted)
  286. (loop (write (pprint-pop))
  287. (pprint-exit-if-list-exhausted)
  288. (write-char #\\Space)
  289. (pprint-newline :linear)))
  290. (pprint-exit-if-list-exhausted)
  291. (write-char #\\Space)
  292. (pprint-newline :fill)))
  293. (pprint-indent :block 1)
  294. (loop (pprint-exit-if-list-exhausted)
  295. (write-char #\\Space)
  296. (pprint-newline :linear)
  297. (write (pprint-pop)))))
  298. \endcode
  299. Suppose that one evaluates the following with \varref{*print-level*} being 4,
  300. and \varref{*print-circle*} being \term{true}.
  301. \code
  302. (pprint-let *standard-output*
  303. '#1=(let (x (*print-length* (f (g 3)))
  304. (z . 2) (k (car y)))
  305. (setq x (sqrt z)) #1#))
  306. \endcode
  307. If the line length is greater than or equal to \f{77}, the output produced
  308. appears on one line. However, if the line length is \f{76}, line breaks are
  309. inserted at the linear-style conditional newlines separating the forms in
  310. the body and the output below is produced. Note that, the degenerate
  311. binding pair \f{x} is printed readably even though it fails to be a list; a
  312. depth abbreviation marker is printed in place of \f{(g 3)}; the binding pair
  313. \f{(z . 2)} is printed readably even though it is not a proper list; and
  314. appropriate circularity markers are printed.
  315. \code
  316. #1=(LET (X (*PRINT-LENGTH* (F #)) (Z . 2) (K (CAR Y)))
  317. (SETQ X (SQRT Z))
  318. #1#)
  319. \endcode
  320. If the line length is reduced to \f{35}, a line break is inserted at one of the
  321. fill-style conditional newlines separating the binding pairs.
  322. \code
  323. #1=(LET (X (*PRINT-PRETTY* (F #))
  324. (Z . 2) (K (CAR Y)))
  325. (SETQ X (SQRT Z))
  326. #1#)
  327. \endcode
  328. Suppose that the line length is further reduced to \f{22} and \varref{*print-length*} is
  329. set to \f{3}. In this situation, line breaks are inserted after both the first
  330. and second binding pairs. In addition, the second binding pair is itself
  331. broken across two lines. Clause (b) of the description of fill-style
  332. conditional newlines (\seefun{pprint-newline})
  333. prevents the binding pair \f{(z . 2)} from being printed
  334. at the end of the third line. Note that the length abbreviation hides the
  335. circularity from view and therefore the printing of circularity markers
  336. disappears.
  337. \code
  338. (LET (X
  339. (*PRINT-LENGTH*
  340. (F #))
  341. (Z . 2) ...)
  342. (SETQ X (SQRT Z))
  343. ...)
  344. \endcode
  345. The next function prints a vector using ``\f{\#(...)}'' notation.
  346. \code
  347. (defun pprint-vector (*standard-output* v)
  348. (pprint-logical-block (nil nil :prefix "#(" :suffix ")")
  349. (let ((end (length v)) (i 0))
  350. (when (plusp end)
  351. (loop (pprint-pop)
  352. (write (aref v i))
  353. (if (= (incf i) end) (return nil))
  354. (write-char #\\Space)
  355. (pprint-newline :fill))))))
  356. \endcode
  357. Evaluating the following with a line length of 15 produces the output shown.
  358. \code
  359. (pprint-vector *standard-output* '#(12 34 567 8 9012 34 567 89 0 1 23))
  360. #(12 34 567 8
  361. 9012 34 567
  362. 89 0 1 23)
  363. \endcode
  364. As examples of the convenience of specifying pretty printing with
  365. \term{format strings}, consider that the functions \f{simple-pprint-defun}
  366. and \f{pprint-let} used as examples above can be compactly defined as follows.
  367. (The function \f{pprint-vector} cannot be defined using \funref{format}
  368. because the data structure it traverses is not a list.)
  369. \code
  370. (defun simple-pprint-defun (*standard-output* list)
  371. (format T "~:<~W ~@_~:I~W ~:_~W~1I ~_~W~:>" list))
  372. (defun pprint-let (*standard-output* list)
  373. (format T "~:<~W~{\hat}~:<~@\{~:<~@\{~W~{\hat}~_~\}~:>~{\hat}~:_~\}~:>~1I~@\{~{\hat}~_~W~\}~:>" list))
  374. \endcode
  375. In the following example, the first \term{form} restores
  376. \varref{*print-pprint-dispatch*} to the equivalent of its initial value.
  377. The next two forms then set up a special way to pretty print ratios.
  378. Note that the more specific \term{type specifier} has to be associated
  379. with a higher priority.
  380. \code
  381. (setq *print-pprint-dispatch* (copy-pprint-dispatch nil))
  382. (set-pprint-dispatch 'ratio
  383. #'(lambda (s obj)
  384. (format s "#.(/ ~W ~W)"
  385. (numerator obj) (denominator obj))))
  386. (set-pprint-dispatch '(and ratio (satisfies minusp))
  387. #'(lambda (s obj)
  388. (format s "#.(- (/ ~W ~W))"
  389. (- (numerator obj)) (denominator obj)))
  390. 5)
  391. (pprint '(1/3 -2/3))
  392. (#.(/ 1 3) \#.(- (/ 2 3)))
  393. \endcode
  394. The following two \term{forms} illustrate the definition of
  395. pretty printing functions for types of \term{code}. The first
  396. \term{form} illustrates how to specify the traditional method
  397. for printing quoted objects using \term{single-quote}. Note
  398. the care taken to ensure that data lists that happen to begin
  399. with \misc{quote} will be printed readably. The second form
  400. specifies that lists beginning with the symbol \f{my-let}
  401. should print the same way that lists beginning with \specref{let}
  402. print when the initial \term{pprint dispatch table} is in effect.
  403. \code
  404. (set-pprint-dispatch '(cons (member quote)) ()
  405. #'(lambda (s list)
  406. (if (and (consp (cdr list)) (null (cddr list)))
  407. (funcall (formatter "'~W") s (cadr list))
  408. (pprint-fill s list))))
  409. (set-pprint-dispatch '(cons (member my-let))
  410. (pprint-dispatch '(let) nil))
  411. \endcode
  412. The next example specifies a default method for printing lists that do not
  413. correspond to function calls. Note that the functions \funref{pprint-linear},
  414. \funref{pprint-fill}, and \funref{pprint-tabular} are all defined with
  415. optional \param{colon-p} and \param{at-sign-p} arguments so that they can
  416. be used as \funref{pprint dispatch functions} as well as \formatOp{/.../}
  417. functions.
  418. \code
  419. (set-pprint-dispatch '(cons (not (and symbol (satisfies fboundp))))
  420. #'pprint-fill -5)
  421. ;; Assume a line length of 9
  422. (pprint '(0 b c d e f g h i j k))
  423. (0 b c d
  424. e f g h
  425. i j k)
  426. \endcode
  427. This final example shows how to define a pretty printing function for a
  428. user defined data structure.
  429. \code
  430. (defstruct family mom kids)
  431. (set-pprint-dispatch 'family
  432. #'(lambda (s f)
  433. (funcall (formatter "~@<#<~;~W and ~2I~_~/pprint-fill/~;>~:>")
  434. s (family-mom f) (family-kids f))))
  435. \endcode
  436. The pretty printing function for the structure \f{family} specifies how to
  437. adjust the layout of the output so that it can fit aesthetically into
  438. a variety of line widths. In addition, it obeys
  439. the printer control variables \varref{*print-level*},
  440. \varref{*print-length*}, \varref{*print-lines*},
  441. \varref{*print-circle*}
  442. %% There's no such var. (Flanagan pointed this out in private mail.) -kmp 26-Jul-93
  443. %, \varref{*print-shared*}
  444. and \varref{*print-escape*},
  445. and can tolerate several different kinds of malformity in the data structure.
  446. The output below shows what is printed out with a right margin of \f{25},
  447. \varref{*print-pretty*} being \term{true}, \varref{*print-escape*} being \term{false},
  448. and a malformed \f{kids} list.
  449. \code
  450. (write (list 'principal-family
  451. (make-family :mom "Lucy"
  452. :kids '("Mark" "Bob" . "Dan")))
  453. :right-margin 25 :pretty T :escape nil :miser-width nil)
  454. (PRINCIPAL-FAMILY
  455. #<Lucy and
  456. Mark Bob . Dan>)
  457. \endcode
  458. \issue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:X3J13-MAR-93}
  459. Note that a pretty printing function for a structure is different from
  460. %the structure's print function.
  461. the structure's \funref{print-object} \term{method}.
  462. While
  463. %print functions
  464. \funref{print-object} \term{methods}
  465. are permanently associated with a structure,
  466. pretty printing functions are stored in
  467. \term{pprint dispatch tables} and can be rapidly changed to reflect
  468. different printing needs. If there is no pretty printing function for
  469. a structure in the current \term{pprint dispatch table},
  470. % the print function (if any)
  471. its \funref{print-object} \term{method}
  472. is used instead.
  473. \endissue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:X3J13-MAR-93}
  474. \endsubSection%{Examples of using the Pretty Printer}
  475. \beginsubsection{Notes about the Pretty Printer's Background}
  476. For a background reference to the abstract concepts detailed in this
  477. section, see \XPPaper. The details of that paper are not binding on
  478. this document, but may be helpful in establishing a conceptual basis for
  479. understanding this material.
  480. \endsubsection%{Notes about the Pretty Printer's Background}
  481. \endissue{PRETTY-PRINT-INTERFACE}