96 lines
7 KiB
HTML
96 lines
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: Variable *PRINT-LEVEL*, *PRINT-LENGTH*</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_gen.htm">
|
|
<LINK REL=UP HREF="c_printe.htm">
|
|
<LINK REL=NEXT HREF="v_pr_lin.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_gen.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_lin.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
<A NAME="STprint-levelST"><A NAME="STprint-lengthST"><I>Variable</I> <B>*PRINT-LEVEL*, *PRINT-LENGTH*</B></A></A> <P>
|
|
<P><B>Value Type:</B><P>
|
|
<P>
|
|
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>
|
|
<P><B>Initial Value:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
|
|
<P><B>Description:</B><P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="#STprint-levelST"><B>*print-level*</B></A> controls how many levels deep a nested <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> will print. If it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, then no control is exercised. Otherwise, it is an <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A> indicating the maximum level to be printed. An <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> to be printed is at level <TT>0</TT>; its components (as of a <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> or <A REL=DEFINITION HREF="26_glo_v.htm#vector"><I>vector</I></A>) are at level <TT>1</TT>; and so on. If an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> to be recursively printed has components and is at a level equal to or greater than the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="#STprint-levelST"><B>*print-level*</B></A>, then the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> is printed as ``<TT>#</TT>''. <P>
|
|
<A REL=DEFINITION HREF="#STprint-lengthST"><B>*print-length*</B></A> controls how many elements at a given level are printed. If it is <A REL=DEFINITION HREF="26_glo_f.htm#false"><I>false</I></A>, there is no limit to the number of components printed. Otherwise, it is an <A REL=DEFINITION HREF="26_glo_i.htm#integer"><I>integer</I></A> indicating the maximum number of <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> of an <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> to be printed. If exceeded, the printer will print ``<TT>...</TT>'' in place of the other <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A>. In the case of a <A REL=DEFINITION HREF="26_glo_d.htm#dotted_list"><I>dotted list</I></A>, if the <A REL=DEFINITION HREF="26_glo_l.htm#list"><I>list</I></A> contains exactly as many <A REL=DEFINITION HREF="26_glo_e.htm#element"><I>elements</I></A> as the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="#STprint-lengthST"><B>*print-length*</B></A>, the terminating <A REL=DEFINITION HREF="26_glo_a.htm#atom"><I>atom</I></A> is printed rather than printing ``<TT>...</TT>'' <P>
|
|
<A REL=DEFINITION HREF="#STprint-levelST"><B>*print-level*</B></A> and <A REL=DEFINITION HREF="#STprint-lengthST"><B>*print-length*</B></A> affect the printing of an any <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> printed with a list-like syntax. They do not affect the printing of <A REL=DEFINITION HREF="26_glo_s.htm#symbol"><I>symbols</I></A>, <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>strings</I></A>, and <A REL=DEFINITION HREF="26_glo_b.htm#bit_vector"><I>bit vectors</I></A>. <P>
|
|
<P><B>Examples:</B><P>
|
|
<P>
|
|
<PRE>
|
|
(setq a '(1 (2 (3 (4 (5 (6))))))) => (1 (2 (3 (4 (5 (6))))))
|
|
(dotimes (i 8)
|
|
(let ((*print-level* i))
|
|
(format t "~&~D -- ~S~%" i a)))
|
|
>> 0 -- #
|
|
>> 1 -- (1 #)
|
|
>> 2 -- (1 (2 #))
|
|
>> 3 -- (1 (2 (3 #)))
|
|
>> 4 -- (1 (2 (3 (4 #))))
|
|
>> 5 -- (1 (2 (3 (4 (5 #)))))
|
|
>> 6 -- (1 (2 (3 (4 (5 (6))))))
|
|
>> 7 -- (1 (2 (3 (4 (5 (6))))))
|
|
=> NIL
|
|
|
|
(setq a '(1 2 3 4 5 6)) => (1 2 3 4 5 6)
|
|
(dotimes (i 7)
|
|
(let ((*print-length* i))
|
|
(format t "~&~D -- ~S~%" i a)))
|
|
>> 0 -- (...)
|
|
>> 1 -- (1 ...)
|
|
>> 2 -- (1 2 ...)
|
|
>> 3 -- (1 2 3 ...)
|
|
>> 4 -- (1 2 3 4 ...)
|
|
>> 5 -- (1 2 3 4 5 6)
|
|
>> 6 -- (1 2 3 4 5 6)
|
|
=> NIL
|
|
|
|
(dolist (level-length '((0 1) (1 1) (1 2) (1 3) (1 4)
|
|
(2 1) (2 2) (2 3) (3 2) (3 3) (3 4)))
|
|
(let ((*print-level* (first level-length))
|
|
(*print-length* (second level-length)))
|
|
(format t "~&~D ~D -- ~S~%"
|
|
*print-level* *print-length*
|
|
'(if (member x y) (+ (car x) 3) '(foo . #(a b c d "Baz"))))))
|
|
>> 0 1 -- #
|
|
>> 1 1 -- (IF ...)
|
|
>> 1 2 -- (IF # ...)
|
|
>> 1 3 -- (IF # # ...)
|
|
>> 1 4 -- (IF # # #)
|
|
>> 2 1 -- (IF ...)
|
|
>> 2 2 -- (IF (MEMBER X ...) ...)
|
|
>> 2 3 -- (IF (MEMBER X Y) (+ # 3) ...)
|
|
>> 3 2 -- (IF (MEMBER X ...) ...)
|
|
>> 3 3 -- (IF (MEMBER X Y) (+ (CAR X) 3) ...)
|
|
>> 3 4 -- (IF (MEMBER X Y) (+ (CAR X) 3) '(FOO . #(A B C D ...)))
|
|
=> NIL
|
|
</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> <P>
|
|
<P><B>Notes:</B> None.
|
|
<P>
|
|
<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>
|