124 lines
15 KiB
HTML
124 lines
15 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: Function WRITE, PRIN1, PRINT, PPRINT...</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="f_set_pp.htm">
|
|
<LINK REL=UP HREF="c_printe.htm">
|
|
<LINK REL=NEXT HREF="f_wr_to_.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="f_set_pp.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="f_wr_to_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="write"><A NAME="prin1"><A NAME="print"><A NAME="pprint"><A NAME="princ"><I>Function</I> <B>WRITE, PRIN1, PRINT, PPRINT, PRINC</B></A></A></A></A></A> <P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>write</B> <I><I>object</I> <TT>&key</TT> array base case circle escape gensym length level lines miser-width pprint-dispatch pretty radix readably right-margin stream</I><P> => <I>object</I><P>
|
|
<P>
|
|
|
|
<B>prin1</B> <I>object <TT>&optional</TT> output-stream</I> => <I>object</I><P>
|
|
|
|
<B>princ</B> <I>object <TT>&optional</TT> output-stream</I> => <I>object</I><P>
|
|
|
|
<B>print</B> <I>object <TT>&optional</TT> output-stream</I> => <I>object</I><P>
|
|
|
|
<B>pprint</B> <I>object <TT>&optional</TT> output-stream</I> => <I><I><no values></I></I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<P>
|
|
<I>object</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<I>output-stream</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#output"><I>output</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#stream_designator"><I>stream designator</I></A>. The default is <A REL=DEFINITION HREF="26_glo_s.htm#standard_output"><I>standard output</I></A>. <P>
|
|
<I>array</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>base</I>---a <A REL=DEFINITION HREF="26_glo_r.htm#radix"><I>radix</I></A>. <P>
|
|
<I>case</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbol</I></A> of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <TT>(member :upcase :downcase :capitalize)</TT>. <P>
|
|
<I>circle</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>escape</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>gensym</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>length</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>level</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>lines</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>miser-width</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>pprint-dispatch</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch table</I></A>. <P>
|
|
<I>pretty</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>radix</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>readably</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. <P>
|
|
<I>right-margin</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<I>stream</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#output"><I>output</I></A> <A REL=DEFINITION HREF="26_glo_s.htm#stream_designator"><I>stream designator</I></A>. The default is <A REL=DEFINITION HREF="26_glo_s.htm#standard_output"><I>standard output</I></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#write"><B>write</B></A>, <A REL=DEFINITION HREF="#prin1"><B>prin1</B></A>, <A REL=DEFINITION HREF="#princ"><B>princ</B></A>, <A REL=DEFINITION HREF="#print"><B>print</B></A>, and <A REL=DEFINITION HREF="#pprint"><B>pprint</B></A> write the printed representation of <I>object</I> to <I>output-stream</I>. <P>
|
|
<A REL=DEFINITION HREF="#write"><B>write</B></A> is the general entry point to the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_printer"><I>Lisp printer</I></A>. For each explicitly supplied <A REL=DEFINITION HREF="26_glo_k.htm#keyword_parameter"><I>keyword parameter</I></A> named in the next figure, the corresponding <A REL=DEFINITION HREF="26_glo_p.htm#printer_control_variable"><I>printer control variable</I></A> is dynamically bound to its <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> while printing goes on; for each <A REL=DEFINITION HREF="26_glo_k.htm#keyword_parameter"><I>keyword parameter</I></A> in the next figure that is not explicitly supplied, the value of the corresponding <A REL=DEFINITION HREF="26_glo_p.htm#printer_control_variable"><I>printer control variable</I></A> is the same as it was at the time <A REL=DEFINITION HREF="#write"><B>write</B></A> was invoked. Once the appropriate <A REL=DEFINITION HREF="26_glo_b.htm#binding"><I>bindings</I></A> are <I>established</I>, the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is output by the <A REL=DEFINITION HREF="26_glo_l.htm#lisp_printer"><I>Lisp printer</I></A>. <P>
|
|
<PRE>
|
|
Parameter Corresponding Dynamic Variable
|
|
array <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST">*print-array*</A>
|
|
base <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-baseST">*print-base*</A>
|
|
case <A REL=DEFINITION HREF="v_pr_cas.htm#STprint-caseST">*print-case*</A>
|
|
circle <A REL=DEFINITION HREF="v_pr_cir.htm#STprint-circleST">*print-circle*</A>
|
|
escape <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST">*print-escape*</A>
|
|
gensym <A REL=DEFINITION HREF="v_pr_gen.htm#STprint-gensymST">*print-gensym*</A>
|
|
length <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST">*print-length*</A>
|
|
level <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-levelST">*print-level*</A>
|
|
lines <A REL=DEFINITION HREF="v_pr_lin.htm#STprint-linesST">*print-lines*</A>
|
|
miser-width <A REL=DEFINITION HREF="v_pr_mis.htm#STprint-miser-widthST">*print-miser-width*</A>
|
|
pprint-dispatch <A REL=DEFINITION HREF="v_pr_ppr.htm#STprint-pprint-dispatchST">*print-pprint-dispatch*</A>
|
|
pretty <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST">*print-pretty*</A>
|
|
radix <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-radixST">*print-radix*</A>
|
|
readably <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST">*print-readably*</A>
|
|
right-margin <A REL=DEFINITION HREF="v_pr_rig.htm#STprint-right-marginST">*print-right-margin*</A>
|
|
</PRE>
|
|
<P><B>Figure 22-7. Argument correspondences for the WRITE function.</B> <P>
|
|
<A REL=DEFINITION HREF="#prin1"><B>prin1</B></A>, <A REL=DEFINITION HREF="#princ"><B>princ</B></A>, <A REL=DEFINITION HREF="#print"><B>print</B></A>, and <A REL=DEFINITION HREF="#pprint"><B>pprint</B></A> implicitly <A REL=DEFINITION HREF="26_glo_b.htm#bind"><I>bind</I></A> certain print parameters to particular values. The remaining parameter values are taken from <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-baseST"><B>*print-base*</B></A>, <A REL=DEFINITION HREF="v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A>, <A REL=DEFINITION HREF="v_pr_cir.htm#STprint-circleST"><B>*print-circle*</B></A>, <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A>, <A REL=DEFINITION HREF="v_pr_gen.htm#STprint-gensymST"><B>*print-gensym*</B></A>, <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>, <A REL=DEFINITION HREF="v_pr_lin.htm#STprint-linesST"><B>*print-lines*</B></A>, <A REL=DEFINITION HREF="v_pr_mis.htm#STprint-miser-widthST"><B>*print-miser-width*</B></A>, <A REL=DEFINITION HREF="v_pr_ppr.htm#STprint-pprint-dispatchST"><B>*print-pprint-dispatch*</B></A>, <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-radixST"><B>*print-radix*</B></A>, and <A REL=DEFINITION HREF="v_pr_rig.htm#STprint-right-marginST"><B>*print-right-margin*</B></A>. <P>
|
|
<A REL=DEFINITION HREF="#prin1"><B>prin1</B></A> produces output suitable for input to <A REL=DEFINITION HREF="f_rd_rd.htm#read"><B>read</B></A>. It binds <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A> to <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<A REL=DEFINITION HREF="#princ"><B>princ</B></A> is just like <A REL=DEFINITION HREF="#prin1"><B>prin1</B></A> except that the output has no <A REL=DEFINITION HREF="26_glo_e.htm#escape"><I>escape</I></A> <A REL=DEFINITION HREF="26_glo_c.htm#character"><I>characters</I></A>. It binds <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A> to <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A> and <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A> to <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>. The general rule is that output from <A REL=DEFINITION HREF="#princ"><B>princ</B></A> is intended to look good to people, while output from <A REL=DEFINITION HREF="#prin1"><B>prin1</B></A> is intended to be acceptable to <A REL=DEFINITION HREF="f_rd_rd.htm#read"><B>read</B></A>. <P>
|
|
<A REL=DEFINITION HREF="#print"><B>print</B></A> is just like <A REL=DEFINITION HREF="#prin1"><B>prin1</B></A> except that the printed representation of <I>object</I> is preceded by a newline and followed by a space. <P>
|
|
<A REL=DEFINITION HREF="#pprint"><B>pprint</B></A> is just like <A REL=DEFINITION HREF="#print"><B>print</B></A> except that the trailing space is omitted and <I>object</I> is printed with the <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A> flag <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A> to produce pretty output. <P>
|
|
<I>Output-stream</I> specifies the <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> to which output is to be sent. <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="v_debug_.htm#STstandard-outputST"><B>*standard-output*</B></A>, <A REL=DEFINITION HREF="v_termin.htm#STterminal-ioST"><B>*terminal-io*</B></A>, <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-radixST"><B>*print-radix*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-baseST"><B>*print-base*</B></A>, <A REL=DEFINITION HREF="v_pr_cir.htm#STprint-circleST"><B>*print-circle*</B></A>, <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A>, <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-levelST"><B>*print-level*</B></A>, <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST"><B>*print-length*</B></A>, <A REL=DEFINITION HREF="v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A>, <A REL=DEFINITION HREF="v_pr_gen.htm#STprint-gensymST"><B>*print-gensym*</B></A>, <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A>, <A REL=DEFINITION HREF="v_rd_def.htm#STread-default-float-formatST"><B>*read-default-float-format*</B></A>. <P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="f_rdtabl.htm#readtable-case"><B>readtable-case</B></A>, <A REL=CHILD HREF="22_cd.htm">Section 22.3.4 (FORMAT Printer Operations)</A> <P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>functions</I></A> <A REL=DEFINITION HREF="#prin1"><B>prin1</B></A> and <A REL=DEFINITION HREF="#print"><B>print</B></A> do not bind <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A>. <P>
|
|
<PRE>
|
|
(prin1 object output-stream)
|
|
== (write object :stream output-stream :escape t)
|
|
</PRE>
|
|
</TT> <P>
|
|
|
|
<PRE>
|
|
(princ object output-stream)
|
|
== (write object stream output-stream :escape nil :readably nil)
|
|
</PRE>
|
|
</TT> <P>
|
|
<PRE>
|
|
(print object output-stream)
|
|
== (progn (terpri output-stream)
|
|
(write object :stream output-stream
|
|
:escape t)
|
|
(write-char #\space output-stream))
|
|
</PRE>
|
|
</TT> <P>
|
|
<PRE>
|
|
(pprint object output-stream)
|
|
== (write object :stream output-stream :escape t :pretty t)
|
|
</PRE>
|
|
</TT> <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/iss271.htm">PRINC-READABLY:X3J13-DEC-91</A><LI> <A REL=CHILD HREF="../Issues/iss270.htm">PRETTY-PRINT-INTERFACE</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>
|