1
0
Fork 0
cl-sites/novaspec.org/cl/f_print-unreadable-object.html

289 lines
6.4 KiB
HTML
Raw Normal View History

2025-02-05 18:52:26 +01:00
<!DOCTYPE HTML>
<HTML LANG="en-us"
><HEAD
><TITLE
>print-unreadable-object | Common Lisp Nova Spec</TITLE
><META CHARSET="US-ASCII"
><LINK REL="canonical" HREF="f_print-unreadable-object.html"
><LINK REL="next" HREF="f_set-pprint-dispatch.html" TYPE="text/html" TITLE="set-pprint-dispatch"
><LINK REL="prev" HREF="f_print-object.html" TYPE="text/html" TITLE="print-object"
><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="f_print-unreadable-object.html"
>print-unreadable-object</A
></SPAN
></DIV
><DIV CLASS="apropos"
><DIV CLASS="apropos-io"
><A HREF="f_print-object.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="f_set-pprint-dispatch.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-unreadable-object"
></SPAN
><B
>print-unreadable-object</B
></TD
><TD ALIGN="RIGHT" VALIGN="BASELINE" WIDTH="0" NOWRAP="NOWRAP" CLASS="ftype"
><I
>Macro</I
></TD
></TR
></TABLE
><HR
></DIV
><UL CLASS="subtoc"
></UL
><DL
><DT
><B
>Syntax</B
></DT
><DD
><P CLASS="j"
><B
>print-unreadable-object</B
> (<SPAN CLASS="cmssi"
>object</SPAN
> <SPAN CLASS="cmssi"
>stream</SPAN
> <SPAN CLASS="cmtt"
>&amp;key</SPAN
> <SPAN CLASS="cmssi"
>type</SPAN
> <SPAN CLASS="cmssi"
>identity</SPAN
>) {<VAR CLASS="param"
>form</VAR
>}* <SPAN CLASS="arrow"
>&#8594;</SPAN
> <SPAN CLASS="misc"
><B
>nil</B
></SPAN
></P
></DD
><DT
><B
>Arguments and Values</B
></DT
><DD
><P CLASS="j"
><VAR CLASS="param"
>object</VAR
> &#8212; an <A HREF="26_1_Glossary.html#object"
><EM CLASS="term"
>object</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>stream</VAR
> &#8212; a <A HREF="26_1_Glossary.html#stream_designator"
><EM CLASS="term"
>stream designator</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>type</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>identity</VAR
> &#8212; a <A HREF="26_1_Glossary.html#generalized_boolean"
><EM CLASS="term"
>generalized boolean</EM
></A
>; evaluated. </P
><P CLASS="j"
><VAR CLASS="param"
>forms</VAR
> &#8212; an <A HREF="26_1_Glossary.html#implicit_progn"
><EM CLASS="term"
>implicit progn</EM
></A
>.</P
></DD
><DT
><B
>Description</B
></DT
><DD
><P CLASS="j"
>Outputs a printed representation of <VAR CLASS="param"
>object</VAR
> on <VAR CLASS="param"
>stream</VAR
>, beginning with &#8220;<CODE CLASS="f"
>#&lt;</CODE
>&#8221; and ending with &#8220;<CODE CLASS="f"
>&gt;</CODE
>&#8221;. Everything output to <VAR CLASS="param"
>stream</VAR
> by the body <VAR CLASS="param"
>forms</VAR
> is enclosed in the the angle brackets. If <VAR CLASS="param"
>type</VAR
> is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, the output from <VAR CLASS="param"
>forms</VAR
> is preceded by a brief description of the <VAR CLASS="param"
>object</VAR
>&#8217;s <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> and a space character. If <VAR CLASS="param"
>identity</VAR
> is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, the output from <VAR CLASS="param"
>forms</VAR
> is followed by a space character and a representation of the <VAR CLASS="param"
>object</VAR
>&#8217;s identity, typically a storage address. </P
><P CLASS="j"
>If either <VAR CLASS="param"
>type</VAR
> or <VAR CLASS="param"
>identity</VAR
> is not supplied, its value is <A HREF="26_1_Glossary.html#false"
><EM CLASS="term"
>false</EM
></A
>. It is valid to omit the body <VAR CLASS="param"
>forms</VAR
>. If <VAR CLASS="param"
>type</VAR
> and <VAR CLASS="param"
>identity</VAR
> are both true and there are no body <VAR CLASS="param"
>forms</VAR
>, only one space character separates the type and the identity.</P
></DD
><DT
><B
>Examples</B
></DT
><DD
><P CLASS="j"
>;; Note that in this example, the precise form of the output ;; is <A HREF="26_1_Glossary.html#implementation-dependent"
><EM CLASS="term"
>implementation-dependent</EM
></A
>.</P
><PRE CLASS="screen"
> (defmethod print-object ((obj airplane) stream)
(print-unreadable-object (obj stream :type t :identity t)
(princ (tail-number obj) stream)))
(prin1-to-string my-airplane)
<SPAN CLASS="cmsy"
><SPAN CLASS="arrow"
>&#8594;</SPAN
></SPAN
> "#&lt;Airplane NW0773 36000123135&gt;"
<SPAN CLASS="sp"
><SPAN CLASS="arrow withabove"
><SPAN CLASS="above"
>or </SPAN
>&#8594;</SPAN
></SPAN
> "#&lt;FAA:AIRPLANE NW0773 17&gt;"</PRE
></DD
><DT
><B
>Exceptional Situations</B
></DT
><DD
><P CLASS="j"
>If <A HREF="v_print-readably.html" CLASS="varref"
><B
>*print-readably*</B
></A
> is <A HREF="26_1_Glossary.html#true"
><EM CLASS="term"
>true</EM
></A
>, <A HREF="f_print-unreadable-object.html" CLASS="macref"
><B
>print-unreadable-object</B
></A
> signals an error of <A HREF="26_1_Glossary.html#type"
><EM CLASS="term"
>type</EM
></A
> <A HREF="t_print-not-readable.html" CLASS="typeref"
><B
>print-not-readable</B
></A
> without printing anything.</P
></DD
></DL
></DIV
></DIV
><DIV CLASS="footer"
><DIV CLASS="btmnav"
><A HREF="f_print-object.html" CLASS="prev"
>&#8592;</A
><A HREF="f_set-pprint-dispatch.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
>