1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/v_pr_rda.htm
2024-04-01 10:24:07 +02:00

97 lines
8.9 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Variable *PRINT-READABLY*</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="v_pr_pre.htm">
<LINK REL=UP HREF="c_printe.htm">
<LINK REL=NEXT HREF="v_pr_rig.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="v_pr_pre.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_printe.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="v_pr_rig.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="STprint-readablyST"><I>Variable</I> <B>*PRINT-READABLY*</B></A> <P>
<P><B>Value Type:</B><P>
<P>
a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
<P><B>Initial Value:</B><P>
<P>
<A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
<P><B>Description:</B><P>
<P>
If <A REL=DEFINITION HREF="#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, some special rules for printing <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>objects</I></A> go into effect. Specifically, printing any <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> O1 produces a printed representation that, when seen by the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_reader"><I>Lisp reader</I></A> while the <A REL=DEFINITION HREF="26_glo_s.htm#standard_readtable"><I>standard readtable</I></A> is in effect, will produce an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> O2 that is <A REL=DEFINITION HREF="26_glo_s.htm#similar"><I>similar</I></A> to O1. The printed representation produced might or might not be the same as the printed representation produced when <A REL=DEFINITION HREF="#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. If printing an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> <A REL=DEFINITION HREF="26_glo_r.htm#readably"><I>readably</I></A> is not possible, an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_pr_not.htm#print-not-readable"><B>print-not-readable</B></A> is signaled rather than using a syntax (e.g., the ``<TT>#&lt;</TT>'' syntax) that would not be readable by the same <A REL=DEFINITION HREF="26_glo_i.htm#implementation"><I>implementation</I></A>. If the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of some other <A REL=DEFINITION HREF="26_glo_p.htm#printer_control_variable"><I>printer control variable</I></A> is such that these requirements would be violated, the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of that other <A REL=DEFINITION HREF="26_glo_v.htm#variable"><I>variable</I></A> is ignored. <P>
Specifically, if <A REL=DEFINITION HREF="#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, printing proceeds as if <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A>, <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A>, and <A REL=DEFINITION HREF="v_pr_gen.htm#STprint-gensymST"><B>*print-gensym*</B></A> were also <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, and as if <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST"><B>*print-length*</B></A>, <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-levelST"><B>*print-level*</B></A>, and <A REL=DEFINITION HREF="v_pr_lin.htm#STprint-linesST"><B>*print-lines*</B></A> were <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. <P>
If <A REL=DEFINITION HREF="#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, the normal rules for printing and the normal interpretations of other <A REL=DEFINITION HREF="26_glo_p.htm#printer_control_variable"><I>printer control variables</I></A> are in effect. <P>
Individual <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A> for <A REL=DEFINITION HREF="f_pr_obj.htm#print-object"><B>print-object</B></A>, including user-defined <A REL=DEFINITION HREF="26_glo_m.htm#method"><I>methods</I></A>, are responsible for implementing these requirements. <P>
If <A REL=DEFINITION HREF="v_rd_eva.htm#STread-evalST"><B>*read-eval*</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> and <A REL=DEFINITION HREF="#STprint-readablyST"><B>*print-readably*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, any such method that would output a reference to the ``<TT>#.</TT>'' <A REL=DEFINITION HREF="26_glo_r.htm#reader_macro"><I>reader macro</I></A> will either output something else or will signal an error (as described above). <P>
<P><B>Examples:</B><P>
<P>
<PRE>
(let ((x (list &quot;a&quot; '\a (gensym) '((a (b (c))) d e f g)))
(*print-escape* nil)
(*print-gensym* nil)
(*print-level* 3)
(*print-length* 3))
(write x)
(let ((*print-readably* t))
(terpri)
(write x)
:done))
&gt;&gt; (a a G4581 ((A #) D E ...))
&gt;&gt; (&quot;a&quot; |a| #:G4581 ((A (B (C))) D E F G))
=&gt; :DONE
;; This is setup code is shared between the examples
;; of three hypothetical implementations which follow.
(setq table (make-hash-table)) =&gt; #&lt;HASH-TABLE EQL 0/120 32005763&gt;
(setf (gethash table 1) 'one) =&gt; ONE
(setf (gethash table 2) 'two) =&gt; TWO
;; Implementation A
(let ((*print-readably* t)) (print table))
Error: Can't print #&lt;HASH-TABLE EQL 0/120 32005763&gt; readably.
;; Implementation B
;; No standardized #S notation for hash tables is defined,
;; but there might be an implementation-defined notation.
(let ((*print-readably* t)) (print table))
&gt;&gt; #S(HASH-TABLE :TEST EQL :SIZE 120 :CONTENTS (1 ONE 2 TWO))
=&gt; #&lt;HASH-TABLE EQL 0/120 32005763&gt;
;; Implementation C
;; Note that #. notation can only be used if *READ-EVAL* is true.
;; If *READ-EVAL* were false, this same implementation might have to
;; signal an error unless it had yet another printing strategy to fall
;; back on.
(let ((*print-readably* t)) (print table))
&gt;&gt; #.(LET ((HASH-TABLE (MAKE-HASH-TABLE)))
&gt;&gt; (SETF (GETHASH 1 HASH-TABLE) ONE)
&gt;&gt; (SETF (GETHASH 2 HASH-TABLE) TWO)
&gt;&gt; HASH-TABLE)
=&gt; #&lt;HASH-TABLE EQL 0/120 32005763&gt;
</PRE>
</TT> <P>
<P><B>Affected By:</B> None.
<P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_wr_pr.htm#write"><B>write</B></A>, <A REL=DEFINITION HREF="m_pr_unr.htm#print-unreadable-object"><B>print-unreadable-object</B></A> <P>
<P><B>Notes:</B><P>
<P>
The rules for ``<A REL=DEFINITION HREF="26_glo_s.htm#similarity"><I>similarity</I></A>'' imply that <TT>#A</TT> or <TT>#(</TT> syntax cannot be used for <A REL=DEFINITION HREF="26_glo_a.htm#array"><I>arrays</I></A> of <A REL=DEFINITION HREF="26_glo_e.htm#element_type"><I>element type</I></A> other than <A REL=DEFINITION HREF="t_t.htm#t"><B>t</B></A>. An implementation will have to use another syntax or signal an error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_pr_not.htm#print-not-readable"><B>print-not-readable</B></A>. <P>
<P>
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss276.htm">PRINT-READABLY-BEHAVIOR:CLARIFY</A><LI> <A REL=CHILD HREF="../Issues/iss089.htm">DATA-IO:ADD-SUPPORT</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>