Re: Equality of foreign objects



On Oct 15, 8:24 pm, D Herring <dherr...@xxxxxxxxxxxxxxxxxxx> wrote:
Scott Burson wrote:
On Oct 14, 3:25 pm, Pascal Costanza <p...@xxxxxxxxx> wrote:
There is no generic equivalence predicate (in the CLOS sense) in Common
Lisp that can be extended for user-defined types, and there are good
reasons for that. Other languages that pretend to provide such generic
equivalence predicates get them wrong most of the time. The issues are
very subtle and very hard to solve.

No, they're really not. The correct rule is very simple: for
(mutable) object types, equality is identity; for (immutable) value
types, equality is by type-and-content (e.g. two sequence values are
equal iff they are of the same size and their elements are pairwise
equal). The little-known language Refine, which I used for years,
does things this way and it works great.

On the other hand, equality is not an intrinsic property; it requires
a well-defined metric. The number 1 is not equal to the number 5,
except modulo 2 or 4, or ...

Your rule is a good one, but it is just one rule more equal than others.

I think it's more than that. Equality is supposed to be the finest
possible equivalence relation. The fact that there exist coarser
equivalence relations that might be of use to someone is irrelevant.

This is why it really is wrong to compare (mutable) objects by type-
and-content, despite that lots of languages do it, and even FSet is
forced to go along in some common cases. It is always possible to
tell two mutable objects apart, if they really are distinct, by
modifying one and seeing that the other isn't affected. So type-and-
content comparison can never provide the finest possible equivalence
relation.

-- Scott
.



Relevant Pages

  • Re: Equality of foreign objects
    ... Other languages that pretend to provide such generic ... equivalence predicates get them wrong most of the time. ... possible equivalence relation. ... If two mutable objects are "equal" at a certain time, ...
    (comp.lang.lisp)
  • Re: equality vs. identity in Conways "On Numbers and Games"
    ... he should call this "equality" an equivalence ... >equivalence relation between sequences. ... David C. Ullrich ...
    (sci.math)
  • Re: So whats null then if its not nothing?
    ... tautology would be nice, but unrealistic even in the 2L because in the ... >> equivalence. ... The equality operation ... > at present unknown' and for the unknown truth value. ...
    (comp.databases.theory)
  • Re: So whats null then if its not nothing?
    ... to store truth values in the database, ... think it is very likely that he means equivalence in all cases. ... I don't think Codd ... A redefinition of equivalence, not equality. ...
    (comp.databases.theory)
  • Re: So whats null then if its not nothing?
    ... *logical equivalence* rather than a biconditional. ... accoding to its truth table. ... An example of such use by COdd would be ... When I said that Cddd had redefined equality, ...
    (comp.databases.theory)