Debian Codegraph @

info/gcl/Examples-of-Printer-Behavior.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>Examples of Printer Behavior (ANSI and GNU Common Lisp Document)</title>
7
8 <meta name="description" content="Examples of Printer Behavior (ANSI and GNU Common Lisp Document)">
9 <meta name="keywords" content="Examples of Printer Behavior (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="The-Lisp-Printer.html" rel="up" title="The Lisp Printer">
15 <link href="The-Lisp-Pretty-Printer.html" rel="next" title="The Lisp Pretty Printer">
16 <link href="Printing-Other-Objects.html" rel="prev" title="Printing Other Objects">
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="Examples-of-Printer-Behavior"></span><div class="header">
41 <p>
42 Previous: <a href="Default-Print_002dObject-Methods.html" accesskey="p" rel="prev">Default Print-Object Methods</a>, Up: <a href="The-Lisp-Printer.html" accesskey="u" rel="up">The Lisp Printer</a> &nbsp; </p>
43 </div>
44 <hr>
45 <span id="Examples-of-Printer-Behavior-1"></span><h4 class="subsection">22.1.4 Examples of Printer Behavior</h4>
46
47 <div class="example">
48 <pre class="example"> (let ((*print-escape* t)) (fresh-line) (write #\a))
49 <tt> |&gt; </tt> #\a
50 &rArr; #\a
51 (let ((*print-escape* nil) (*print-readably* nil))
52 (fresh-line)
53 (write #\a))
54 <tt> |&gt; </tt> a
55 &rArr; #\a
56 (progn (fresh-line) (prin1 #\a))
57 <tt> |&gt; </tt> #\a
58 &rArr; #\a
59 (progn (fresh-line) (print #\a))
60 <tt> |&gt; </tt>
61 <tt> |&gt; </tt> #\a
62 &rArr; #\a
63 (progn (fresh-line) (princ #\a))
64 <tt> |&gt; </tt> a
65 &rArr; #\a
66
67 (dolist (val '(t nil))
68 (let ((*print-escape* val) (*print-readably* val))
69 (print '#\a)
70 (prin1 #\a) (write-char #\Space)
71 (princ #\a) (write-char #\Space)
72 (write #\a)))
73 <tt> |&gt; </tt> #\a #\a a #\a
74 <tt> |&gt; </tt> #\a #\a a a
75 &rArr; NIL
76
77 (progn (fresh-line) (write '(let ((a 1) (b 2)) (+ a b))))
78 <tt> |&gt; </tt> (LET ((A 1) (B 2)) (+ A B))
79 &rArr; (LET ((A 1) (B 2)) (+ A B))
80
81 (progn (fresh-line) (pprint '(let ((a 1) (b 2)) (+ a b))))
82 <tt> |&gt; </tt> (LET ((A 1)
83 <tt> |&gt; </tt> (B 2))
84 <tt> |&gt; </tt> (+ A B))
85 &rArr; (LET ((A 1) (B 2)) (+ A B))
86
87 (progn (fresh-line)
88 (write '(let ((a 1) (b 2)) (+ a b)) :pretty t))
89 <tt> |&gt; </tt> (LET ((A 1)
90 <tt> |&gt; </tt> (B 2))
91 <tt> |&gt; </tt> (+ A B))
92 &rArr; (LET ((A 1) (B 2)) (+ A B))
93
94 (with-output-to-string (s)
95 (write 'write :stream s)
96 (prin1 'prin1 s))
97 &rArr; &quot;WRITEPRIN1&quot;
98 </pre></div>
99
100
101
102
103
104 </body>
105 </html>