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

119 lines
5.8 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 DEFSTRUCT-CONSTRUCTOR-OPTIONS 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/iss109_w.htm">
<LINK REL=UP HREF="../Issues/iss110.htm">
<LINK REL=NEXT HREF="../Issues/iss111_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/iss109_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss110.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss111_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue DEFSTRUCT-CONSTRUCTOR-OPTIONS Writeup</H2>
<PRE><B>Forum:</B> Cleanup<P>
<B>Issue:</B> <A HREF="iss110.htm">DEFSTRUCT-CONSTRUCTOR-OPTIONS</A><P>
<B>References:</B> DEFSTRUCT; CLtL p. 309, 311, 315-316<P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit History:</B> V1, 11 Oct 1989, Sandra Loosemore<P>
<P>
<P>
<B>Problem Description:<P>
</B><P>
It is permitted to specify multiple :constructor options to <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A>,<P>
but the interactions between them are unclear.<P>
<P>
Is it legitimate to specify multiple (:constructor &lt;name&gt;) options to<P>
<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> to get multiple copies of the default keyword constructor<P>
function?<P>
<P>
Does specifying an explicit :constructor option inhibit <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> from<P>
creating the default keyword constructor or does one have to<P>
explicitly say (:constructor nil)?<P>
<P>
<P>
<B>Proposal (DEFSTRUCT-CONSTRUCTOR-OPTIONS:EXPLICIT):<P>
</B><P>
Clarify that <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> creates the default keyword constructor only if<P>
no explicit :constructor options are specified, or if the :constructor<P>
option is specified without an argument.<P>
<P>
(:constructor nil) is meaningful only when there are no other<P>
:constructor options specified. It prevents <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> from generating<P>
any constructors at all.<P>
<P>
Otherwise, <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> builds a constructor function corresponding to<P>
each supplied :constructor option. It is permissible to specify both<P>
multiple BOA constructors and multiple keyword constructors.<P>
<P>
<P>
<B>Rationale:<P>
</B><P>
This proposal treats all of the :constructor options uniformly as a<P>
group. Instead of viewing each individual option as something that<P>
adds to or modifies the behavior, the entire set of specified<P>
:constructor options taken as a whole tell <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> to do something<P>
*instead of* its default behavior. Treating all :constructor options<P>
uniformly in this respect should make the behavior easier to<P>
understand.<P>
<P>
<P>
<B>Current Practice:<P>
</B><P>
Varies widely.<P>
<P>
Lucid Common Lisp and Kyoto Common Lisp appear to implement this<P>
proposal.<P>
<P>
Utah Common Lisp currently allows only one keyword constructor. If a<P>
(:constructor name) option appears more than once, it ignores all but<P>
one. It always makes a keyword constructor unless (:constructor nil)<P>
is explicitly specified, even if BOA constructors are explicitly<P>
requested. CMU Common Lisp appears to behave in the same way.<P>
<P>
HPCL-I signals an error if multiple (:constructor name) options appear.<P>
It also always makes a keyword constructor unless (:constructor nil) is<P>
explicitly specified.<P>
<P>
<P>
<B>Cost to implementors:<P>
</B><P>
Probably wouldn't take more than a few hours to fix.<P>
<P>
<P>
<B>Cost to users:<P>
</B><P>
Code (that is currently nonportable anyway) that assumes the default<P>
keyword constructor will be created unless it is explictly disabled<P>
with (:constructor nil) would have to be changed.<P>
<P>
<P>
<B>Benefits:<P>
</B><P>
Increased portability of application code using <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A>.<P>
<P>
<P>
<B>Discussion:<P>
</B><P>
Loosemore supports this proposal even though she would have to fix UCL<P>
to conform to it.<P>
-------<P>
<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>