1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss078_w.htm
2024-04-01 10:24:07 +02:00

136 lines
10 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: Issue CONS-TYPE-SPECIFIER Writeup</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="../Issues/iss077_w.htm">
<LINK REL=UP HREF="../Issues/iss078.htm">
<LINK REL=NEXT HREF="../Issues/iss079_w.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="../Issues/iss077_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss078.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss079_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CONS-TYPE-SPECIFIER Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss078.htm">CONS-TYPE-SPECIFIER</A><P>
<B>Forum:</B> EDITORIAL<P>
<B>References:</B> Issue <A HREF="iss270.htm">PRETTY-PRINT-INTERFACE</A>,<P>
Issue ATOMIC-TYPE-SPECIFIER-LIST,<P>
Issue <A HREF="iss291.htm">RECURSIVE-DEFTYPE</A><P>
<B>Category:</B> ADDITION<P>
<B>Edit history:</B> 05-Feb-91, Version 1 by Pitman<P>
15-Mar-91, Version 2 by Pitman<P>
08-Apr-91, Version 3 by Pitman <P>
(integrate amendment to option ADD from Mar-91 meeting)<P>
<B>Status:</B> X3J13 passed option ADD on a vote of 12-1, March 1991.<P>
<P>
<B>Problem Description:<P>
</B><P>
The description of the pretty printer dispatching mechanism is complicated<P>
by the fact that dispatch cannot be described in terms of `type specifiers'.<P>
In fact, the pretty printer dispatches on either a type specifier -or- a<P>
list whose <A REL=DEFINITION HREF="../Body/f_car_c.htm#car"><B>car</B></A> is <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A>.<P>
<P>
<B>Proposal (CONS-TYPE-SPECIFIER:ADD):<P>
</B><P>
Permit the <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> type specifier to be a type specifier that specializes,<P>
with the syntax:<P>
<P>
(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> [type-specifier-1 [type-specifier-2]])<P>
<P>
Either type specifier may be *, which means the same as T.<P>
Either the second type specifier or both type specifiers may be omitted.<P>
Omitted type specifiers default to T.<P>
<P>
Extend the <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> pretty printer dispatcher to treat (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A>) the same as <A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A>.<P>
<P>
<B>Test Case:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A>) =&gt; T ; Already true<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> T)) =&gt; T ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A>)) =&gt; T ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_intege.htm#integer"><B>INTEGER</B></A>)) =&gt; <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> T T)) =&gt; T ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A>)) =&gt; <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A>))))<P>
=&gt; T ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>))))<P>
=&gt; <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> ; New with this proposal<P>
(<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A> <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> <A REL=DEFINITION HREF="../Body/a_null.htm#null"><B>NULL</B></A>))))<P>
=&gt; T ; New with this proposal<P>
<P>
<B>Rationale:<P>
</B><P>
This will make the description of the pretty printer simpler with no <P>
substantial overhead for other parts of the system.<P>
<P>
This same approach was taken for <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> type specifiers in CLOS, so that<P>
all <A REL=DEFINITION HREF="../Body/t_method.htm#method"><B>method</B></A> specializers could have corresponding type specifiers.<P>
<P>
<B>Current Practice:<P>
</B><P>
Probably no one implements this.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Very small.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
Extra conceptual overhead in the specification. A new term will have to be<P>
devised for <A REL=DEFINITION HREF="../Body/f_wr_pr.htm#pprint"><B>pprint</B></A> `type specifiers' in order to avoid telling lies all over<P>
the place about some things being type specifiers that really aren't (or to <P>
avoid being overly verbose all over the place if we decide to tell the full<P>
truth every time the issue comes up.)<P>
<P>
<B>Benefits:<P>
</B><P>
This new type specifier might be turn out to be useful in its own right in<P>
some applications.<P>
<P>
<B>Aesthetics:<P>
</B><P>
I think this improves the aesthetics.<P>
<P>
<B>Discussion:<P>
</B><P>
This was discussed previously and discarded. But having looked at the <P>
complexity it introduces in to the specification, I think it needs to be<P>
reopened.<P>
<P>
The question of what (<A REL=DEFINITION HREF="../Body/f_typep.htm#typep"><B>TYPEP</B></A> '(A B C) '(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>CONS</B></A>)) returns was spun off as<P>
a separate issue named ATOMIC-TYPE-SPECIFIER-LIST.<P>
<P>
Barmar got briefly excited about the idea of <P>
(<A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>deftype</B></A> proper-list (<A REL=DEFINITION HREF="../Body/03_da.htm#AMoptional"><B>&amp;optional</B></A> (element-type t))<P>
`(<A REL=DEFINITION HREF="../Body/a_or.htm#or"><B>or</B></A> <A REL=DEFINITION HREF="../Body/a_null.htm#null"><B>null</B></A> (<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>cons</B></A> ,element-type proper-list)))<P>
but others didn't like it. A separate issue <A HREF="iss291.htm">RECURSIVE-DEFTYPE</A> addresses<P>
this.<P>
<P>
Allan Wechsler (Symbolics) notes that <P>
(<A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>deftype</B></A> list-of-length (<A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>length</B></A>)<P>
(<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> (= 0 <A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>length</B></A>)<P>
'<A REL=DEFINITION HREF="../Body/a_null.htm#null"><B>null</B></A><P>
`(<A REL=DEFINITION HREF="../Body/a_cons.htm#cons"><B>cons</B></A> t (list-of-length ,(- <A REL=DEFINITION HREF="../Body/f_length.htm#length"><B>length</B></A> 1)))))<P>
would in principle be reasonable under this proposal.<P>
</PRE>
<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>