1
0
Fork 0
cl-sites/novaspec.org/cl/v_print-pretty.html
2025-02-05 18:52:26 +01:00

302 lines
No EOL
6.3 KiB
HTML

<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>*print-pretty* | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="v_print-pretty.html"
><LINK REL="next" HREF="v_print-readably.html" TYPE="text/html" TITLE="*print-readably*"
><LINK REL="prev" HREF="v_print-pprint-dispatch.html" TYPE="text/html" TITLE="*print-pprint-dispatch*"
><LINK REL="up" HREF="22_4_Printer_Dictionary.html" TYPE="text/html" TITLE="22.4 Printer Dictionary"
><LINK REL="start" HREF="index.html" TYPE="text/html" TITLE="Common Lisp Nova Spec"
><META NAME="VIEWPORT" CONTENT="width=device-width, initial-scale=1.0"
><LINK REL="STYLESHEET" HREF="dpans.css%3F3909942064.css"
><SCRIPT SRC="dpans.js%3F3909942064"
></SCRIPT
><SCRIPT SRC="apropos.js%3F3909942064"
></SCRIPT
></HEAD
><BODY
><DIV
><DIV CLASS="topnav"
><DIV CLASS="breadcrumb"
><SPAN CLASS="breadcrumb-item"
><A HREF="index.html"
>Common Lisp Nova Spec</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="22_Printer.html"
>22. Printer</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="22_4_Printer_Dictionary.html"
>22.4 Printer Dictionary</A
></SPAN
> <SPAN CLASS="breadcrumb-item"
>&#8594; <A HREF="v_print-pretty.html"
>*print-pretty*</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="v_print-pprint-dispatch.html" CLASS="prev"
>&#8592;</A
><SPAN ID="apropos-label"
>Apropos </SPAN
><INPUT ID="apropos" AUTOFOCUS="AUTOFOCUS" PLACEHOLDER="Type here to search" ONINPUT="aproposInput(this);" ONKEYUP="aproposKeyup(event);" ONCHANGE="aproposChange(this);" ONFOCUS="aproposFocus(this);" ONFOCUSOUT="aproposFocusout(this);"
><A HREF="v_print-readably.html" CLASS="next"
>&#8594;</A
></DIV
><DIV ID="apropos-res"
></DIV
></DIV
></DIV
><DIV CLASS="matter"
><DIV CLASS="com"
><DIV CLASS="begincom"
><HR
><TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="0"
><TR
><TD ALIGN="LEFT" VALIGN="BASELINE" WIDTH="100%" CLASS="name"
><SPAN CLASS="idx" DATA-KIND="idxref" DATA-TERM="*print-pretty*"
></SPAN
><SPAN CLASS="cmsy"
>*</SPAN
><B
>print-pretty</B
><SPAN CLASS="cmsy"
>*</SPAN
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Variable</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Value Type</B
></DT
><DD
><P CLASS="j"
>a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>.</P
></DD
><DT
><B
>Initial Value</B
></DT
><DD
><P CLASS="j"
><A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>Controls whether the <A HREF="26_1_Glossary.html#Lisp_printer"
><EM CLASS="term"
>Lisp printer</EM
></A
> calls the <A HREF="26_1_Glossary.html#pretty_printer"
><EM CLASS="term"
>pretty printer</EM
></A
>. </P
><P CLASS="j"
>If it is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>, the <A HREF="26_1_Glossary.html#pretty_printer"
><EM CLASS="term"
>pretty printer</EM
></A
> is not used and a minimum of <A HREF="26_1_Glossary.html#whitespace"
><EM CLASS="term"
>whitespace</EM
></A
><SPAN CLASS="meaning"
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>1</SPAN
></SUB
></SPAN
> is output when printing an expression. </P
><P CLASS="j"
>If it is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, the <A HREF="26_1_Glossary.html#pretty_printer"
><EM CLASS="term"
>pretty printer</EM
></A
> is used, and the <A HREF="26_1_Glossary.html#Lisp_printer"
><EM CLASS="term"
>Lisp printer</EM
></A
> will endeavor to insert extra <A HREF="26_1_Glossary.html#whitespace"
><EM CLASS="term"
>whitespace</EM
></A
><SPAN CLASS="meaning"
><SUB CLASS="sub"
><SPAN CLASS="cmr"
>1</SPAN
></SUB
></SPAN
> where appropriate to make <A HREF="26_1_Glossary.html#expression"
><EM CLASS="term"
>expressions</EM
></A
> more readable. </P
><P CLASS="j"
><A HREF="v_print-pretty.html" CLASS="varref"
><B
>*print-pretty*</B
></A
> has an effect even when the <A HREF="26_1_Glossary.html#value"
><EM CLASS="term"
>value</EM
></A
> of <A HREF="v_print-escape.html" CLASS="misc"
><B
>*print-escape*</B
></A
> is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><PRE CLASS="screen"
> (setq *print-pretty* 'nil) <SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL
(progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil)
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LET ((A 1) (B 2) (C 3)) (+ A B C))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL
(let ((*print-pretty* t))
(progn (write '(let ((a 1) (b 2) (c 3)) (+ a b c))) nil))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LET ((A 1)
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (B 2)
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (C 3))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (+ A B C))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL
;; Note that the first two expressions printed by this next form
;; differ from the second two only in whether escape characters are printed.
;; In all four cases, extra whitespace is inserted by the pretty printer.
(flet ((test (x)
(let ((*print-pretty* t))
(print x)
(format t "~%~S " x)
(terpri) (princ x) (princ " ")
(format t "~%~A " x))))
(test '#'(lambda () (list "a" #<B CLASS="b"
></B
> 'c #'d))))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> #'(LAMBDA ()
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LIST "a" #<B CLASS="b"
></B
> 'C #'D))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> #'(LAMBDA ()
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LIST "a" #<B CLASS="b"
></B
> 'C #'D))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> #'(LAMBDA ()
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LIST a b 'C #'D))
<SPAN CLASS="cmr"
>&#8883;</SPAN
> #'(LAMBDA ()
<SPAN CLASS="cmr"
>&#8883;</SPAN
> (LIST a b 'C #'D))
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> NIL</PRE
></DD
><DT
><B
>See Also</B
></DT
><DD
><P CLASS="j"
><A HREF="f_write.html" CLASS="funref"
><B
>write</B
></A
></P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="v_print-pprint-dispatch.html" CLASS="prev"
>&#8592;</A
><A HREF="v_print-readably.html" CLASS="next"
>&#8594;</A
></DIV
><DIV CLASS="trail"
>Conversion to HTML copyright 2023 by Gilbert Baumann</DIV
></DIV
></DIV
><SCRIPT
>domReady();</SCRIPT
></BODY
></HTML
>