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

130 lines
8.1 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 DEFTYPE-KEY 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/iss121_w.htm">
<LINK REL=UP HREF="../Issues/iss122.htm">
<LINK REL=NEXT HREF="../Issues/iss123_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/iss121_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss122.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss123_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue DEFTYPE-KEY Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss122.htm">DEFTYPE-KEY</A><P>
<P>
<B>References:</B> CLtL p.50<P>
<P>
Related issues: <A HREF="iss109.htm">DEFSTRUCT-CONSTRUCTOR-KEY-MIXTURE</A><P>
<P>
<B>Category:</B> CLARIFICATION/ADDITION<P>
<P>
<B>Edit history:</B> 29-Apr-90, Version 1 by Moon<P>
30-Apr-90, Version 2 by Moon (update current practice)<P>
4-May-90, Version 3 by Moon (update from comment received)<P>
9-May-90, Version 4 by Moon (revise according to comments<P>
received. Specifically, remove references to<P>
<A REL=DEFINITION HREF="../Body/03_dd.htm#AMenvironment"><B>&amp;ENVIRONMENT</B></A>, take no stand on destructuring, and<P>
correct the current practice.)<P>
<P>
<B>Problem description:<P>
</B><P>
CLtL p.50 only mentions <A REL=DEFINITION HREF="../Body/03_da.htm#AMoptional"><B>&amp;OPTIONAL</B></A> and <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A> as allowed lambda-list<P>
keywords in <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A>. It doesn't say whether <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> is allowed too.<P>
<P>
This is Symbolics issue #18.<P>
<P>
<B>Proposal (DEFTYPE-KEY:ALLOW):<P>
</B><P>
Allow <A REL=DEFINITION HREF="../Body/03_da.htm#AMoptional"><B>&amp;OPTIONAL</B></A>, <A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A>, <A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A>, <A REL=DEFINITION HREF="../Body/03_da.htm#AMallow-other-keys"><B>&amp;ALLOW-OTHER-KEYS</B></A>, and <A REL=DEFINITION HREF="../Body/03_da.htm#AMaux"><B>&amp;AUX</B></A> in the<P>
lambda-list of <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A>.<P>
<P>
Clarify that unsupplied keyword arguments default to *, not <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>, the same<P>
as unsupplied optional arguments, if no initform is specified in the<P>
lambda-list. <A REL=DEFINITION HREF="../Body/03_da.htm#AMaux"><B>&amp;AUX</B></A> parameters are initialized to <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if no initform is<P>
specified.<P>
<P>
<B>Examples:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>deftype</B></A> xarray (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;key</B></A> dimensions (rank '* rank-p) element-type)<P>
(<A REL=DEFINITION HREF="../Body/m_check_.htm#check-type"><B>check-type</B></A> rank (<A REL=DEFINITION HREF="../Body/a_or.htm#or"><B>or</B></A> (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>member</B></A> *) (<A REL=DEFINITION HREF="../Body/t_intege.htm#integer"><B>integer</B></A> 0 *)))<P>
(<A REL=DEFINITION HREF="../Body/m_check_.htm#check-type"><B>check-type</B></A> dimensions (<A REL=DEFINITION HREF="../Body/a_or.htm#or"><B>or</B></A> (<A REL=DEFINITION HREF="../Body/a_member.htm#member"><B>member</B></A> *) <A REL=DEFINITION HREF="../Body/a_list.htm#list"><B>list</B></A>))<P>
`(<A REL=DEFINITION HREF="../Body/t_array.htm#array"><B>array</B></A> ,element-type<P>
,(<A REL=DEFINITION HREF="../Body/s_if.htm#if"><B>if</B></A> rank-p rank dimensions)))<P>
<P>
(<A REL=DEFINITION HREF="../Body/m_check_.htm#check-type"><B>check-type</B></A> z (xarray :rank 2 :element-type <A REL=DEFINITION HREF="../Body/t_short_.htm#double-float"><B>double-float</B></A>))<P>
<P>
(define-presentation-type command (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;key</B></A> (command-table *command-table*))<P>
....)<P>
<P>
define-presentation-type is similar to <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>deftype</B></A> but defines some<P>
additional information about use of the type in user interfaces.<P>
<P>
<B>Rationale:<P>
</B><P>
Type specifiers with keyword arguments are used extensively in CLIM<P>
and CLIM-based applications.<P>
<P>
<A REL=DEFINITION HREF="../Body/03_da.htm#AMaux"><B>&amp;AUX</B></A> is allowed just for completeness.<P>
<P>
<B>Current practice:<P>
</B><P>
Symbolics Genera 8.0 supports the proposal.<P>
Lucid 3.0.1 signals an error (<A REL=DEFINITION HREF="../Body/03_da.htm#AMkey"><B>&amp;KEY</B></A> not allowed) for this example.<P>
Franz Allegro CL 3.1.beta.22 supports the proposal.<P>
Other implementations were not surveyed.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
Should be small since this simply makes <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A> support the same<P>
lambda-list keywords as <A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> and <A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (which suggests an<P>
implementation technique of inserting '* where an initform is not<P>
specified for an &amp;optional or &amp;keyword argument and then making a<P>
function that is applied to the <A REL=DEFINITION HREF="../Body/f_car_c.htm#cdr"><B>cdr</B></A> of the type specifier).<P>
<P>
<B>Cost to Users:<P>
</B><P>
None.<P>
<P>
<B>Cost of non-adoption:<P>
</B><P>
CLIM will not fit into Common Lisp as well. <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A> will be less<P>
consistent with the rest of the language.<P>
<P>
<B>Performance impact:<P>
</B><P>
None.<P>
<P>
<B>Benefits:<P>
</B><P>
Cost of non-adoption will not be incurred.<P>
<P>
<B>Esthetics:<P>
</B><P>
<A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A> will be consistent with <A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A>, eliminating an arbitrary<P>
restriction.<P>
<P>
<B>Discussion:<P>
</B><P>
There has been some discussion about whether <A REL=DEFINITION HREF="../Body/m_deftp.htm#deftype"><B>DEFTYPE</B></A> supports<P>
destructuring. It seems that CLtL pages 50 and 146 may contradict<P>
each other on this point. This issue explicitly does not address<P>
the question of destructuring.<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>