[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are isomorphic structures EQUAL?



	
    From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>
    Subject: Are isomorphic structures EQUAL?
    
        ....
	There will be no way to do a component-wise test (using EQUAL on each
	component) on two structures unless one writes a structure-specific
	equality predicate.
    
	Therefore, I propose that two structures of the same type that are
	created by DEFSTRUCT (regardless of the :TYPE option) be tested for
	equality component-wise and that the CLtL make this clear.
    
	Until then, she can get by with EQUALP (since her structures don't
	conatin strings, floats, etc.).
    
    I don't understand this.  I can't find anything in the manual that says
    that EQUALP behaves differently than EQUAL for structures.  Actually I
    can't find anything in the manual that says anything at all about the
    behavior of either EQUAL or EQUALP on structures.
    
    It may be that by coincidence the two implementations you mentioned in
    your message both compare components of structures (with the default
    defstruct options, especially no :TYPE) in EQUALP, and do not compare
    components of structures in EQUAL, but I don't think the Common Lisp
    manual says that all implementations have to do that.
		
The definition of EQUAL on pg. 80 says, "Certain objects that have
components are EQUAL if they are of the of the same type and
corresponding components are EQUAL."  Following this line is an
enumeration of these "certain objects".

The definition of EQUALP on the next page has an identical line
(substituting EQUALP for EQUAL) EXCEPT it omits the word "certain".  I
(and apparently the two implementations that I mentioned) interpret
this to mean that EQUALP does behave differently from EQUAL, in that
EQUALP performs a component-wise equality check on ALL objects that
are defined to have componentsin CLtL.  It just so happens that
objects defined by defstruct are the only objects not enumerated in
the definition of EQUAL that would be covered by EQUALP.

I agree that CLtL isn't explicit about the behavior of EQUAL and
EQAULP on structures, but I think the behavior of EQUAL and EQUALP in
the two implementations is due their interpreting the relevant
definitions as I did above, not to coincidence.  I am curious how
other implementations defined EQUAL and EQUALP's behavior on
structures.  I just tried it on KCL and they behave identically: both
do a component-wise test (this is the behavior I personally prefer).
I'd say that this is a fairly major ambiguity in CLtL and should be
clarified as soon as possible (even if just informally).

	-- Nick