On Tue, 15 Jan 2002, brian moseley wrote:
> On Mon, 14 Jan 2002, Michael A Nachbaur wrote:
>
> > Correct me if I'm wrong someone, but it seems that this
> > would only evaluate if the hashrefs are equal (which
> > wouldn't happen unless you did $obj->equals($obj)).
>
> or if you did
>
> $b = $a;
> $b->equals($a);
>
> bcm@void:~ > perl -e '$a = {}; $b = $a; print "a: $a\nb: $b\n"'
> a: HASH(0x814374c)
> b: HASH(0x814374c)
>
> i guess it depends on your definition of object identity:
>
> 1) are two data structures with equivalent values defined as
> equal?
>
> $a = {foo => 1};
> $b = {foo => 1};
>
> 2) (i don't know if i'm using the correct vocabulary) are
> two variables referring to the same reference defined as
> equal?
>
> $a = {};
> $b = $a;
I think the canonical way of doing this is if the objects are the same
object. If a subclass wants to redefine equality it is free to do so.
Oh, and we should also use overload to make == and "" work for equals and
to_string.
--
<!-- Matt -->
<:->Get a smart net</:->