emacs.d/clones/lisp/HyperSpec-7-0/HyperSpec/Body/f_set_pp.htm

67 lines
6.8 KiB
HTML
Raw Normal View History

2023-01-18 20:30:47 +01:00
<!-- 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 SET-PPRINT-DISPATCH</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_pr_unr.htm">
<LINK REL=UP HREF="c_printe.htm">
<LINK REL=NEXT HREF="f_wr_pr.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_pr_unr.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_pr.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="set-pprint-dispatch"><I>Function</I> <B>SET-PPRINT-DISPATCH</B></A> <P>
<P>
<P><B>Syntax:</B><P>
<P>
<B>set-pprint-dispatch</B> <I>type-specifier function <TT>&amp;optional</TT> priority table</I> =&gt; <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>type-specifier</I>---a <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A>. <P>
<I>function</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#function"><I>function</I></A>, a <A REL=DEFINITION HREF="26_glo_f.htm#function_name"><I>function name</I></A>, or <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. <P>
<I>priority</I>---a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A>. The default is <TT>0</TT>. <P>
<I>table</I>---a <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch table</I></A>. The default is the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_pr_ppr.htm#STprint-pprint-dispatchST"><B>*print-pprint-dispatch*</B></A>. <P>
<P><B>Description:</B><P>
<P>
Installs an entry into the <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch table</I></A> which is <I>table</I>. <P>
<I>Type-specifier</I> is the <A REL=DEFINITION HREF="26_glo_k.htm#key"><I>key</I></A> of the entry. The first action of <A REL=DEFINITION HREF="#set-pprint-dispatch"><B>set-pprint-dispatch</B></A> is to remove any pre-existing entry associated with <I>type-specifier</I>. This guarantees that there will never be two entries associated with the same <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A> in a given <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch table</I></A>. Equality of <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifiers</I></A> is tested by <A REL=DEFINITION HREF="f_equal.htm#equal"><B>equal</B></A>. <P>
Two values are associated with each <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A> in a <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch table</I></A>: a <I>function</I> and a <I>priority</I>. The <I>function</I> must accept two arguments: the <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A> to which output is sent and the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> to be printed. The <I>function</I> should <A REL=DEFINITION HREF="26_glo_p.htm#pretty_print"><I>pretty print</I></A> the <A REL=DEFINITION HREF="26_glo_o.htm#object"><I>object</I></A> to the <I>stream</I>. The <I>function</I> can assume that object satisfies the <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> given by <I>type-specifier</I>. The <I>function</I> must obey <A REL=DEFINITION HREF="v_pr_rda.htm#STprint-readablyST"><B>*print-readably*</B></A>. Any values returned by the <I>function</I> are ignored. <P>
<I>Priority</I> is a priority to resolve conflicts when an object matches more than one entry. <P>
It is permissible for <I>function</I> to be <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. In this situation, there will be no <I>type-specifier</I> entry in <I>table</I> after <A REL=DEFINITION HREF="#set-pprint-dispatch"><B>set-pprint-dispatch</B></A> returns. <P>
<P><B>Examples:</B> None.
<P>
<P><B>Side Effects:</B> None.
<P>
<P><B>Affected By:</B> None.
<P>
<P><B>Exceptional Situations:</B><P>
<P>
An error is signaled if <I>priority</I> is not a <A REL=DEFINITION HREF="t_real.htm#real"><I>real</I></A>. <P>
<P><B>See Also:</B> None.
<P>
<P><B>Notes:</B><P>
<P>
Since <A REL=DEFINITION HREF="26_glo_p.htm#pprint_dispatch_table"><I>pprint dispatch tables</I></A> are often used to control the pretty printing of Lisp code, it is common for the <I>type-specifier</I> to be an <A REL=DEFINITION HREF="26_glo_e.htm#expression"><I>expression</I></A> of the form <P>
<PRE>
(cons car-type cdr-type)
</PRE>
</TT> <P>
This signifies that the corresponding object must be a cons cell whose <A REL=DEFINITION HREF="26_glo_c.htm#car"><I>car</I></A> matches the <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A> <I>car-type</I> and whose <A REL=DEFINITION HREF="26_glo_c.htm#cdr"><I>cdr</I></A> matches the <A REL=DEFINITION HREF="26_glo_t.htm#type_specifier"><I>type specifier</I></A> <I>cdr-type</I>. The <I>cdr-type</I> can be omitted in which case it defaults to <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>. <P>
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issue</A>, <I>not part of the specification</I>, applies to this section:<P><UL><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>