in reply to Re: OO Identity Crisis
in thread OO Identity Crisis

The 'equals' method also requires to compare the given object with each existing objects. Isn't it the case?
--Artist

Replies are listed 'Best First'.
Re^3: OO Identity Crisis
by kaif (Friar) on Jun 21, 2005 at 06:44 UTC

    Sort of. If we're using tlm's approach of a hashtable anyway (see return $self->{ N }{ $id } ||= $node;), then --- as far as I know --- Java's Hashtable combines the Object class's overridable methods equals and hashCode to do what we want. Basically, it avoids comparing the given object with each existing object by comparing it only to those with the same hashcode; but if you have a poor hashcode function (like return 0;), it will compare with everything.