[XML-SIG] DOM Nodes: Identity test
Thu, 25 Mar 1999 15:46:14 -0600
"Andrew M. Kuchling" wrote:
Note that the discussion last year started out on a different basis:
> Briefly, what should 'node1 == node2' do? In Python, object
> identity is tested using the 'is' operator, so 'node1 is node2'
> returns true iff node1 and node2 are actually the same object.
But that doesn't work, right? So this doesn't follow:
> 'node1 == node2' should therefore test for equal values of the node.
So you started down the path of trying to figure out value equality. And
as you've pointed out there is no decent definition for it except maybe
"nodes in the same place, in the same tree, with the same attributes and
the same children" -- i.e. identical to identity.
> the time, we concluded that no reasonable meaning for == could be
> chosen, and if a future DOM Level N draft specifies some different
> behaviour, we're in trouble, so it would be best to have a completely
> different method for such comparisons.
I don't see how the DOM could specify something for such a
language-specific concept. The "==" syntax has a different behaviour in
C++, Java and Python. It doesn't even exist in Scheme. Therefore we should
expect to choose our own behaviour based on Python semantics.
Actually, isSameNode seems like something that they are more likely to
specify. After all, method calls are language independent but operators
are not.. So the danger of conflict there is higher, not lower.
> So, how about isSameNode()? node1.isSameNode(node2) returns
> true iff node1 and node2 refer to the same underlying node in the
I could live with isSameNode but I prefer "==".
Paul Prescod - ISOGEN Consulting Engineer speaking for only himself
"Perpetually obsolescing and thus losing all data and programs every 10
years (the current pattern) is no way to run an information economy or
a civilization." - Stewart Brand, founder of the Whole Earth Catalog