Debian Codegraph @

info/gcl/print_002dobject.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>print-object (ANSI and GNU Common Lisp Document)</title>
7
8 <meta name="description" content="print-object (ANSI and GNU Common Lisp Document)">
9 <meta name="keywords" content="print-object (ANSI and GNU Common Lisp Document)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="Printer-Dictionary.html" rel="up" title="Printer Dictionary">
15 <link href="print_002dunreadable_002dobject.html" rel="next" title="print-unreadable-object">
16 <link href="pprint_002dtab.html" rel="prev" title="pprint-tab">
17 <style type="text/css">
18 <!--
19 a.summary-letter {text-decoration: none}
20 blockquote.indentedblock {margin-right: 0em}
21 div.display {margin-left: 3.2em}
22 div.example {margin-left: 3.2em}
23 div.lisp {margin-left: 3.2em}
24 kbd {font-style: oblique}
25 pre.display {font-family: inherit}
26 pre.format {font-family: inherit}
27 pre.menu-comment {font-family: serif}
28 pre.menu-preformatted {font-family: serif}
29 span.nolinebreak {white-space: nowrap}
30 span.roman {font-family: initial; font-weight: normal}
31 span.sansserif {font-family: sans-serif; font-weight: normal}
32 ul.no-bullet {list-style: none}
33 -->
34 </style>
35
36
37 </head>
38
39 <body lang="en">
40 <span id="print_002dobject"></span><div class="header">
41 <p>
42 Next: <a href="print_002dunreadable_002dobject.html" accesskey="n" rel="next">print-unreadable-object</a>, Previous: <a href="pprint_002dtab.html" accesskey="p" rel="prev">pprint-tab</a>, Up: <a href="Printer-Dictionary.html" accesskey="u" rel="up">Printer Dictionary</a> &nbsp; </p>
43 </div>
44 <hr>
45 <span id="print_002dobject-_005bStandard-Generic-Function_005d"></span><h4 class="subsection">22.4.11 print-object [Standard Generic Function]</h4>
46
47 <span id="Syntax_003a_003a-39"></span><h4 class="subsubheading">Syntax::</h4>
48
49 <p><code>print-object</code> <i>object stream</i> &rArr; <i>object</i>
50 </p>
51 <span id="Method-Signatures_003a_003a-22"></span><h4 class="subsubheading">Method Signatures::</h4>
52
53 <p><code>print-object</code> <i><span class="roman">(</span><i>object</i> standard-object<span class="roman">)</span> <i>stream</i></i>
54 </p>
55 <p><code>print-object</code> <i><span class="roman">(</span><i>object</i> structure-object<span class="roman">)</span> <i>stream</i></i>
56 </p>
57 <span id="Arguments-and-Values_003a_003a-464"></span><h4 class="subsubheading">Arguments and Values::</h4>
58
59 <p><i>object</i>&mdash;an <i>object</i>.
60 </p>
61 <p><i>stream</i>&mdash;a <i>stream</i>.
62 </p>
63 <span id="Description_003a_003a-599"></span><h4 class="subsubheading">Description::</h4>
64
65 <p>The <i>generic function</i> <b>print-object</b> writes the printed representation of <i>object</i>
66 to <i>stream</i>.
67 The <i>function</i> <b>print-object</b> is called by the <i>Lisp printer</i>;
68 it should not be called by the user.
69 </p>
70 <p>Each implementation is required to provide a <i>method</i> on
71 the <i>class</i> <b>standard-object</b> and on the <i>class</i> <b>structure-object</b>.
72 In addition, each <i>implementation</i> must provide
73 <i>methods</i> on enough other <i>classes</i>
74 so as to ensure that there is always an applicable <i>method</i>.
75 Implementations are free to add <i>methods</i> for other <i>classes</i>.
76 Users may write <i>methods</i> for <b>print-object</b> for their own
77 <i>classes</i> if they do not wish to inherit an
78 <i>implementation-dependent</i> <i>method</i>.
79 </p>
80 <p>The <i>method</i> on the <i>class</i> <b>structure-object</b> prints the object in the
81 default <tt>#S</tt> notation; see <a href="Printing-Structures.html">Printing Structures</a>.
82 </p>
83 <p><i>Methods</i> on <b>print-object</b> are responsible for implementing
84 their part of the semantics of the <i>printer control variables</i>, as follows:
85 </p>
86 <dl compact="compact">
87 <dt><b>*print-readably*</b></dt>
88 <dd><p>All methods for <b>print-object</b> must obey <b>*print-readably*</b>.
89 This includes both user-defined methods and <i>implementation-defined</i> methods.
90 Readable printing of <i>structures</i> and <i>standard objects</i>
91 is controlled by their <b>print-object</b> method,
92 not by their <b>make-load-form</b> <i>method</i>.
93 <i>Similarity</i> for these <i>objects</i> is application dependent
94 and hence is defined to be whatever these <i>methods</i> do;
95 see <a href="Similarity-of-Literal-Objects.html">Similarity of Literal Objects</a>.
96 </p>
97 </dd>
98 <dt><b>*print-escape*</b></dt>
99 <dd><p>Each <i>method</i> must implement <b>*print-escape*</b>.
100 </p>
101 </dd>
102 <dt><b>*print-pretty*</b></dt>
103 <dd>
104 <p>The <i>method</i> may wish to perform specialized line breaking
105 or other output conditional on the <i>value</i> of <b>*print-pretty*</b>.
106 For further information,
107 see (for example) the <i>macro</i> <b>pprint-fill</b>.
108 See also <a href="Pretty-Print-Dispatch-Tables.html">Pretty Print Dispatch Tables</a> and <a href="Examples-of-using-the-Pretty-Printer.html">Examples of using the Pretty Printer</a>.
109 </p>
110 </dd>
111 <dt><b>*print-length*</b></dt>
112 <dd><p><i>Methods</i> that produce output of indefinite length must obey
113 <b>*print-length*</b>.
114 </p>
115 <p>For further information,
116 see (for example) the <i>macros</i> <b>pprint-logical-block</b>
117 and <b>pprint-pop</b>.
118 See also <a href="Pretty-Print-Dispatch-Tables.html">Pretty Print Dispatch Tables</a> and <a href="Examples-of-using-the-Pretty-Printer.html">Examples of using the Pretty Printer</a>.
119 </p>
120 </dd>
121 <dt><b>*print-level*</b></dt>
122 <dd><p>The printer takes care of <b>*print-level*</b> automatically,
123 provided that each <i>method</i> handles exactly one level of structure and
124 calls <b>write</b> (or an equivalent <i>function</i>) recursively if
125 there are more structural levels. The printer&rsquo;s decision of whether an
126 <i>object</i> has components (and therefore should not be printed when the
127 printing depth is not less than <b>*print-level*</b>) is
128 <i>implementation-dependent</i>. In some implementations its
129 <b>print-object</b> <i>method</i> is not called;
130 in others the <i>method</i> is called,
131 and the determination that the <i>object</i> has components is based on what
132 it tries to write to the <i>stream</i>.
133 </p>
134 </dd>
135 <dt><b>*print-circle*</b></dt>
136 <dd>
137 <p>When the <i>value</i> of <b>*print-circle*</b> is <i>true</i>,
138 a user-defined
139 </p>
140 <p><b>print-object</b> <i>method</i>
141 </p>
142 <p>can print <i>objects</i> to the supplied <i>stream</i>
143 using <b>write</b>,
144 <b>prin1</b>,
145 <b>princ</b>,
146 or <b>format</b>
147 and expect circularities to be detected
148 and printed using the <tt>#<i>n</i>#</tt> syntax.
149 If a user-defined
150 </p>
151 <p><b>print-object</b> <i>method</i>
152 </p>
153 <p>prints to a <i>stream</i> other than the one
154 that was supplied, then circularity detection starts over for that
155 <i>stream</i>. See <b>*print-circle*</b>.
156 </p>
157 </dd>
158 <dt><b>*print-base*</b>,</dt>
159 <dd><p><b>*print-radix*</b>,
160 <b>*print-case*</b>,
161 <b>*print-gensym*</b>,
162 and <b>*print-array*</b>
163 These <i>printer control variables</i> apply to specific types of <i>objects</i>
164 and are handled by the <i>methods</i> for those <i>objects</i>.
165 </p>
166 </dd>
167 </dl>
168
169 <p>If these rules are not obeyed, the results are undefined.
170 </p>
171 <p>In general, the printer and the <b>print-object</b> methods should not
172 rebind the print control variables as they operate recursively through the
173 structure, but this is <i>implementation-dependent</i>.
174 </p>
175 <p>In some implementations the <i>stream</i> argument passed to a
176 <b>print-object</b> <i>method</i> is not the original <i>stream</i>,
177 but is an intermediate <i>stream</i> that implements part of the printer.
178 <i>methods</i> should therefore not depend on the identity of this <i>stream</i>.
179 </p>
180 <span id="See-Also_003a_003a-487"></span><h4 class="subsubheading">See Also::</h4>
181
182 <p><a href="pprint_002dfill.html">pprint-fill</a>
183 ,
184 <a href="pprint_002dlogical_002dblock.html">pprint-logical-block</a>
185 ,
186 <a href="pprint_002dpop.html">pprint-pop</a>
187 ,
188 <a href="write.html">write</a>
189 ,
190 <b>*print-readably*</b>,
191 <b>*print-escape*</b>,
192 <b>*print-pretty*</b>,
193 <b>*print-length*</b>,
194 <a href="Default-Print_002dObject-Methods.html">Default Print-Object Methods</a>,
195 </p>
196 <p><a href="Printing-Structures.html">Printing Structures</a>,
197 </p>
198 <p><a href="Pretty-Print-Dispatch-Tables.html">Pretty Print Dispatch Tables</a>,
199 <a href="Examples-of-using-the-Pretty-Printer.html">Examples of using the Pretty Printer</a>
200 </p>
201 <hr>
202 <div class="header">
203 <p>
204 Next: <a href="print_002dunreadable_002dobject.html" accesskey="n" rel="next">print-unreadable-object</a>, Previous: <a href="pprint_002dtab.html" accesskey="p" rel="prev">pprint-tab</a>, Up: <a href="Printer-Dictionary.html" accesskey="u" rel="up">Printer Dictionary</a> &nbsp; </p>
205 </div>
206
207
208
209 </body>
210 </html>