W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

Re: Equality tests on DOM nodes

From: Ray Whitmer <ray@imall.com>
Date: Wed, 16 Dec 1998 09:45:18 -0700
Message-ID: <3677E39E.8BAECF6E@imall.com>
To: David Brownell <db@Eng.Sun.COM>
CC: www-dom@w3.org, xml-sig@python.org
David Brownell wrote:

> Though there's one thing to consider:  The behavior of Object.equals()
> and Object.hashCode() is specified to make objects work as hashtable
> keys in the natural manner.  For example, strings can be used as keys
> since they're immutable and equals() is overridden ... were they mutable,
> or did they not override equals(), that'd not be so.

That is a sad but true that Hashtable influenced the implementation of
Object.  Equals is problematic in Object's API because of its ambiguity, but
about every other language seems to do something similarly ambiguous.  You
raise a connection between equals and immutability that I generally tend to
overlook as nonessential.  There are plenty of other examples in the jdk that
also overlook it that I cited before (like Point or Rectangle), again
demonstrating the ambiguity of the interpretation of equals, which I think we
are mostly agreed upon.  Users of Hashtable must rely on discipline, because
there is not enough typing to otherwise guarantee that the interpretation of
equals will not change.

In any case, equals should not be usable for Node until a clear portable
definition is established, whether that be the identity interpretation or some
deeper interpretation.

Received on Wednesday, 16 December 1998 11:46:17 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:05 UTC