92 lines
8.7 KiB
HTML
92 lines
8.7 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 PPRINT-FILL, PPRINT-LINEAR...</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="m_ppr_ex.htm">
|
|
<LINK REL=UP HREF="c_printe.htm">
|
|
<LINK REL=NEXT HREF="f_ppr_in.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="m_ppr_ex.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_ppr_in.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="pprint-fill"><A NAME="pprint-linear"><A NAME="pprint-tabular"><I>Function</I> <B>PPRINT-FILL, PPRINT-LINEAR, PPRINT-TABULAR</B></A></A></A> <P>
|
|
<P>
|
|
<P><B>Syntax:</B><P>
|
|
<P>
|
|
|
|
<B>pprint-fill</B> <I>stream object <TT>&optional</TT> colon-p at-sign-p</I> => <I><A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A></I><P>
|
|
|
|
<B>pprint-linear</B> <I>stream object <TT>&optional</TT> colon-p at-sign-p</I> => <I><A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A></I><P>
|
|
|
|
<B>pprint-tabular</B> <I>stream object <TT>&optional</TT> colon-p at-sign-p tabsize</I> => <I><A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A></I><P>
|
|
<P>
|
|
<P><B>Arguments and Values:</B><P>
|
|
<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>. <P>
|
|
<I>object</I>---an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A>. <P>
|
|
<I>colon-p</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. The default is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. <P>
|
|
<I>at-sign-p</I>---a <A REL=DEFINITION HREF="26_glo_g.htm#generalized_boolean"><I>generalized boolean</I></A>. The default is <A REL=DEFINITION HREF="26_glo_i.htm#implementation-dependent"><I>implementation-dependent</I></A>. <P>
|
|
<I>tabsize</I>---a non-negative <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A>. The default is <TT>16</TT>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
The functions <A REL=DEFINITION HREF="#pprint-fill"><B>pprint-fill</B></A>, <A REL=DEFINITION HREF="#pprint-linear"><B>pprint-linear</B></A>, and <A REL=DEFINITION HREF="#pprint-tabular"><B>pprint-tabular</B></A> specify particular ways of <I>pretty printing</I> a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> to <I>stream</I>. Each function prints parentheses around the output if and only if <I>colon-p</I> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>. Each function ignores its <I>at-sign-p</I> argument. (Both arguments are included even though only one is needed so that these functions can be used via <TT>~/.../</TT> and as <A REL=DEFINITION HREF="f_set_pp.htm#set-pprint-dispatch"><B>set-pprint-dispatch</B></A> functions, as well as directly.) Each function handles abbreviation and the detection of circularity and sharing correctly, and uses <A REL=DEFINITION HREF="f_wr_pr.htm#write"><B>write</B></A> to print <I>object</I> when it is a <A REL=DEFINITION HREF="26_glo_n.htm#non-list"><I>non-list</I></A>. <P>
|
|
If <I>object</I> is a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> and if the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A> is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, each of these functions prints <I>object</I> using a minimum of <A REL=DEFINITION HREF="26_glo_w.htm#whitespace"><I>whitespace</I></A>, as described in <A REL=CHILD HREF="22_ace.htm">Section 22.1.3.5 (Printing Lists and Conses)</A>. Otherwise (if <I>object</I> is a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> and if the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>): <P>
|
|
<P><UL><P>
|
|
<LI> The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="#pprint-linear"><B>pprint-linear</B></A> prints a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> either all on one line, or with each <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>element</I></A> on a separate line. <P>
|
|
<LI> The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="#pprint-fill"><B>pprint-fill</B></A> prints a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> with as many <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> as possible on each line. <P>
|
|
<LI> The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="#pprint-tabular"><B>pprint-tabular</B></A> is the same as <A REL=DEFINITION HREF="#pprint-fill"><B>pprint-fill</B></A> except that it prints the <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> so that they line up in columns. The <I>tabsize</I> specifies the column spacing in <A REL=DEFINITION HREF="26_glo_e.htm#em"><I>ems</I></A>, which is the total spacing from the leading edge of one column to the leading edge of the next. <P></UL><P>
|
|
<P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
Evaluating the following with a line length of <TT>25</TT> produces the output shown. <P>
|
|
<PRE>
|
|
(progn (princ "Roads ")
|
|
(pprint-tabular *standard-output* '(elm main maple center) nil nil 8))
|
|
Roads ELM MAIN
|
|
MAPLE CENTER
|
|
</PRE>
|
|
</TT> <P>
|
|
<P><B>Side Effects:</B><P>
|
|
<P>
|
|
Performs output to the indicated <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>. <P>
|
|
<P><B>Affected By:</B><P>
|
|
<P>
|
|
The cursor position on the indicated <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>, if it can be determined. <P>
|
|
<P><B>Exceptional Situations:</B> None.
|
|
<P>
|
|
<P><B>See Also:</B> None.
|
|
<P>
|
|
<P><B>Notes:</B><P>
|
|
<P>
|
|
The <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A> <A REL=DEFINITION HREF="#pprint-tabular"><B>pprint-tabular</B></A> could be defined as follows: <P>
|
|
<PRE>
|
|
(defun pprint-tabular (s list &optional (colon-p t) at-sign-p (tabsize nil))
|
|
(declare (ignore at-sign-p))
|
|
(when (null tabsize) (setq tabsize 16))
|
|
(pprint-logical-block (s list :prefix (if colon-p "(" "")
|
|
:suffix (if colon-p ")" ""))
|
|
(pprint-exit-if-list-exhausted)
|
|
(loop (write (pprint-pop) :stream s)
|
|
(pprint-exit-if-list-exhausted)
|
|
(write-char #\Space s)
|
|
(pprint-tab :section-relative 0 tabsize s)
|
|
(pprint-newline :fill s))))
|
|
</PRE>
|
|
</TT> <P>
|
|
Note that it would have been inconvenient to specify this function using <A REL=DEFINITION HREF="f_format.htm#format"><B>format</B></A>, because of the need to pass its <I>tabsize</I> argument through to a <TT>~:T</TT> format directive nested within an iteration over a list. <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/iss180.htm">GENERALIZE-PRETTY-PRINTER:UNIFY</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>
|