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

126 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: Issue DEFSTRUCT-SLOTS-CONSTRAINTS-NAME 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/iss118_w.htm">
<LINK REL=UP HREF="../Issues/iss119.htm">
<LINK REL=NEXT HREF="../Issues/iss120_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/iss118_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss119.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss120_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue DEFSTRUCT-SLOTS-CONSTRAINTS-NAME Writeup</H2>
<PRE><B>Issue:</B> <A HREF="iss119.htm">DEFSTRUCT-SLOTS-CONSTRAINTS-NAME</A><P>
<B>References:</B> CLtL p.308 &amp; 86-003 p.4<P>
<B>Category:</B> CLARIFICATION<P>
<P>
<B>Edit history:</B> Version 1 by Skona Brittain 05/13/88<P>
Version 2, Masinter, 14-Sep-88<P>
Version 3, Masinter, 23-Sep-88<P>
Version 4, Masinter, 31-Oct-88<P>
Version 5, Masinter, 12-Jan-89<P>
<P>
<B>Problem Description:<P>
</B><P>
The case of two slots of a <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A> having the same name is not <P>
discussed in CLtL. Is it allowed? The problem is that the<P>
name of slot accessors and the keyword arguments of the <P>
constructor function is determined only by the <A REL=DEFINITION HREF="../Body/f_symb_2.htm#symbol-name"><B>SYMBOL-NAME</B></A><P>
of the slot designator; the meaning of slot accessors and<P>
the constructor function is unspecified.<P>
<P>
<B>Proposal (DEFSTRUCT-SLOTS-CONSTRAINTS-NAME:DUPLICATES-ERROR):<P>
</B><P>
It is an error for two slots in a <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A> type to have the same symbol-name;<P>
that is, the <A REL=DEFINITION HREF="../Body/f_symb_2.htm#symbol-name"><B>SYMBOL-NAME</B></A> of the slot names should not be <A REL=DEFINITION HREF="../Body/f_stgeq_.htm#stringEQ"><B>STRING=</B></A>.<P>
This holds when they were both named directly by the same call to <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A><P>
or when one is present by virtue of being in an included <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>.<P>
<P>
The situation of expanding a <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> macro with a duplicate name &quot;should<P>
signal an error.&quot; (While not yet formally defined, the intent is that <P>
the error signalling may occur when compiling a file that contains<P>
duplicate names or when evaluating a <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> form with duplicate names<P>
in an interpreter.)<P>
<P>
This proposal only affects the operation of the <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A><P>
macro, and not the <A REL=DEFINITION HREF="../Body/t_stu_cl.htm#structure-class"><B>STRUCTURE-CLASS</B></A> or structures defined<P>
with DEFCLASS&gt;<P>
<P>
<B>Examples:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A> struc slot slot) would be an error. So would<P>
(<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A> (struc2 (:include struc1)) slot) if preceded by<P>
(<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A> struc1 slot).<P>
<P>
(<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A> struct package-1:slot package-2:slot) is also an<P>
error. Slot accessors are interned in the current <A REL=DEFINITION HREF="../Body/v_pkg.htm#STpackageST"><B>*PACKAGE*</B></A><P>
at the time of the evalution of the <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A>. <P>
<P>
<B>Rationale:<P>
</B><P>
Since it would be difficult to prescribe reasonable behavior for<P>
<A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A>, it should be considered an error.<P>
<P>
<B>Current Practice:<P>
</B><P>
In KCL, if two slots have the same name, no warning message is <P>
given but mysterious behavior ensues. (Their default values are <P>
both whatever is given for the second one, neither can be given a<P>
different value via a call to the constructor function, only the <P>
second one's value can be changed by <A REL=DEFINITION HREF="../Body/a_setf.htm#setf"><B>setf</B></A>...)<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
None.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
Possible confusion.<P>
<P>
<B>Benefits:<P>
</B><P>
Clarity.<P>
<P>
<B>Aethetics:<P>
</B><P>
Something that is not well-defined and leads to erratic behavior <P>
should be explicitly considered an error.<P>
<P>
<B>Discussion: <P>
</B><P>
Although this issue was mentioned in Guy's original issues file, it has<P>
not been officially discussed since. <P>
<P>
This issue was first circulated to X3J13 June 1988.<P>
<P>
This proposal does not address the issue of whether <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> is a legitimate<P>
slot name. There seems to be no current reason why it might be prohibitied.<P>
<P>
The compiler committee is proposing to address generally the issue <P>
of how macro-expansion errors during <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>compile-file</B></A> might be caught and<P>
turned into compiler warnings.<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>