198 lines
13 KiB
HTML
198 lines
13 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 EQUAL-STRUCTURE 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/iss142_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss143.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss144_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/iss142_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss143.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss144_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue EQUAL-STRUCTURE Writeup</H2>
|
|
|
|
<PRE><B>Status:</B> Passed as amended, Jun 89 X3J13<P>
|
|
<B>Issue:</B> <A HREF="iss143.htm">EQUAL-STRUCTURE</A><P>
|
|
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> (p80), <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> (p81)<P>
|
|
<B>Category:</B> CLARIFICATION/CHANGE<P>
|
|
<B>Edit history:</B> 18-Mar-88, Version 1 by Pitman<P>
|
|
08-Jun-88, Version 2 by Masinter (add Benson's proposal)<P>
|
|
23-Sep-88, Version 3 by Masinter (remove all but STATUS-QUO)<P>
|
|
01-Oct-88, Version 4 by Masinter (fix description)<P>
|
|
01-Oct-88, Version 5 by Pitman (correct wording, add discussion)<P>
|
|
11-Jan-89, Version 6 by Pitman (attempt <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> correction)<P>
|
|
15-Mar-89, Version 7 by Masinter (amended as per vote at Jan 89 X3J13)<P>
|
|
3-Jul-89, Version 8, by Masinter (amended as per Jun89 X3J13)<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
The behavior of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> on structures is a subject of controversy.<P>
|
|
At issue are whether these functions should descend the slots of structures<P>
|
|
or use simply the <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>'s primitive identity (i.e., <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A>) to test for<P>
|
|
equivalence.<P>
|
|
<P>
|
|
<B>Proposal (EQUAL-STRUCTURE:MAYBE-STATUS-QUO):<P>
|
|
</B><P>
|
|
Clarify that <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> do not descend any structures or data types<P>
|
|
other than the ones explicitly specified here:<P>
|
|
<P>
|
|
Type <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> Behavior <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> Behavior<P>
|
|
<P>
|
|
Number uses <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> uses =<P>
|
|
Character uses <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> uses <A REL=DEFINITION HREF="../Body/f_chareq.htm#char-equal"><B>CHAR-EQUAL</B></A><P>
|
|
Cons descends descends<P>
|
|
Bit-Vector descends descends<P>
|
|
String descends descends<P>
|
|
Pathname magic per CLtL same as <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A><P>
|
|
Structure uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> (see below)<P>
|
|
other Array uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> descends<P>
|
|
Hash-Table uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> (see below)<P>
|
|
Instance (Standard-Object) uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A><P>
|
|
Other uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> uses <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A><P>
|
|
<P>
|
|
Note that the order of this table is in some cases important, with upper<P>
|
|
entries taking priority over lower ones.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> descends hash tables by first comparing the count of entries<P>
|
|
and the :TEST function; if those are the same, it compares the<P>
|
|
keys of the tables using the :TEST function and then the values<P>
|
|
of the matching keys using <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> recursively.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> on two <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> objects 's1' and 's2', where one is a<P>
|
|
non-:TYPEed <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> and the other is typed, is false.<P>
|
|
<P>
|
|
<A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> on two <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>DEFSTRUCT</B></A> objects 's1' and 's2', where both are<P>
|
|
non-:TYPEed DEFSTRUCTS is true iff:<P>
|
|
<P>
|
|
(1) The type of 's1' is the same as the type of 's2' (this is<P>
|
|
the same as saying that the <A REL=DEFINITION HREF="../Body/m_defstr.htm#defstruct"><B>defstruct</B></A> name for 's1' is the same<P>
|
|
as that for 's2').<P>
|
|
<P>
|
|
(2) The value of each slot of 's1' is <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> to the value of the<P>
|
|
same slot of 's2' (where "same" means same name) (this is not the<P>
|
|
same as 'slots' for standard-objects in CLOS).<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
There seem to be as many different equality primitives as there<P>
|
|
are applications for them. None of the possible ways of changing<P>
|
|
<A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> or <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> are flawless. Given the inability to "fix" them,<P>
|
|
it is better to leave them alone.<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
We are unaware of any extensions to CLtL's set of operations,<P>
|
|
although frequently users request them.<P>
|
|
<P>
|
|
<B>Cost to Implementors:<P>
|
|
</B><P>
|
|
Since this seems to be compatible with the status quo, none.<P>
|
|
<P>
|
|
<B>Cost to Users:<P>
|
|
</B><P>
|
|
Same<P>
|
|
<P>
|
|
<B>Cost of Non-Adoption:<P>
|
|
</B><P>
|
|
Ongoing controversy about whether <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> "do the right thing".<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
A feeling that <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> exist and/or do what they do because serious<P>
|
|
consideration was given and we consciously decided on a particular resolution<P>
|
|
to the numerous questions that have come up about them.<P>
|
|
<P>
|
|
<B>Aesthetics:<P>
|
|
</B><P>
|
|
There seems to be wide debate about what the proper aesthetics for<P>
|
|
how equality should work in Common Lisp. While the status quo is not<P>
|
|
aesthetically more pleasing than the various alternatives, aesthetic<P>
|
|
considerations vary widely. Different people model structures<P>
|
|
differently. Sometimes the same person models structures differently in<P>
|
|
different situations. The question of which should be descended and which<P>
|
|
should not is a very personal one, and the aesthetic attractiveness of any<P>
|
|
of these options will vary from person to person or application to<P>
|
|
application.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
An earlier version of this issue with various alternatives was distributed<P>
|
|
at the June 1988 X3J13 meeting. Since<P>
|
|
this is a frequently raised issue, we thought we should submit it<P>
|
|
as a clarification although there is no change to CLtL.<P>
|
|
<P>
|
|
Options for which we considered proposals were:<P>
|
|
- removing <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> from the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>.<P>
|
|
- changing <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> to descend structures.<P>
|
|
- changing <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> to be case sensitive.<P>
|
|
- adding a :TEST keyword to <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>.<P>
|
|
- making <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> a generic function<P>
|
|
All of these had some serious problems.<P>
|
|
<P>
|
|
The cleanup committee supports option STATUS-QUO.<P>
|
|
<P>
|
|
It would be useful if descriptions of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> contained some sort<P>
|
|
of additional commentary alluding to the complex issues discussed here.<P>
|
|
The following is offered to the Editorial staff as a starting point:<P>
|
|
<P>
|
|
Object equality is not a concept for which there is a uniquely<P>
|
|
determined correct algorithm. The appropriateness of an equality<P>
|
|
predicate can be judged only in the context of the needs of some<P>
|
|
particular program. Although these functions take any type of<P>
|
|
argument and their names sound very generic, <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> and <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> are<P>
|
|
not appropriate for every application. Any decision to use or not<P>
|
|
use them should be determined by what they are documented to do<P>
|
|
rather than any abstract characterization of their function. If<P>
|
|
neither <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> nor <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> is found to be appropriate in a particular<P>
|
|
situation, programmers are encouraged to create another operator<P>
|
|
that is appropriate rather than blame <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> or <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A> for ``doing<P>
|
|
the wrong thing.''<P>
|
|
<P>
|
|
<P>
|
|
Additional Comments to Version 6:<P>
|
|
<P>
|
|
Version 6 attempts to fix some of the problems noted in Version 5.<P>
|
|
There are still some open questions. Only the "Proposal"<P>
|
|
part has been changed since Version 5; some of the costs,<P>
|
|
benefits & other discussion is now incorrect.<P>
|
|
<P>
|
|
Kent says:<P>
|
|
<P>
|
|
Please read this very carefully before voting in favor of it.<P>
|
|
There were a lot of Yes votes for the last version, which I think<P>
|
|
had some serious bugs in it. This would be a very bad issue for<P>
|
|
us to screw up.<P>
|
|
<P>
|
|
Things that might need special attention:<P>
|
|
<P>
|
|
- Moon contends that <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> practice in Symbolics Lisp is<P>
|
|
for instances to be compared using <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> under <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A>, not by<P>
|
|
descending. There may be performance issues involved here.<P>
|
|
Some agreement needs to be reached.<P>
|
|
<P>
|
|
- Neither the previous version of the proposal nor CLtL was<P>
|
|
clear on what happens to pathnames under <A REL=DEFINITION HREF="../Body/f_equalp.htm#equalp"><B>EQUALP</B></A>. This showed<P>
|
|
up when I converted the presentation below. That issue should<P>
|
|
be addressed as well.<P>
|
|
<P>
|
|
Hopefully if this version of the proposal isn't something you want to<P>
|
|
vote yes for, at least it's in a suitable form for easy line-item<P>
|
|
changes interactively in the meeting.<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>
|