Here's a way of looking at it that doesn't require you to consider
what happens if you alter the structures.
Let's say you have a Person class with a Name an Age and a House class
with Owner and Resident.
Now imagine there are 2 people who have the same name and age but are
different people.
my $p1 = Person->new(Name => "Fergal Daly", Age => 31);
my $p2 = Person->new(Name => "Fergal Daly", Age => 31);
They live in 2 houses but one of the owns both houses.
my $h1 = House->new(Owner => $p1, Resident => $p1);
my $h2 = House->new(Owner => $p1, Resident => $p2);
The houses look identical if you only consider values however Yves
wants to also consider identities. $h1 is owner-occupied $h2 is
presumably being rented.
Here's what CalculateRent could look like:
sub CalculateRent
{
my $house = shift;
if ($house->Owner eq $house->Resident)
{
return 0;
}
else
{
return ValueHouse($house) / 360;
}
}
so curently
is_deeply($h1, $h2)
passes but
CalculateRent($h1) == CalculateRent($h2)
fails so there it definitely something unequal about $h1 and $h2.
There is a stronger form of equality that could be tested which would
guarantee that if
is_really_deep($h1, $h2)
passes then
AnyFunction($h1) == AnyFunction($h2)
would also pass (assuming there are no conflicting side effects and
assuming nothing looks directly at reference addresses - apart from
debugging, there's no reason to ever do this anyway),
F
On 7/2/05, Michael Peters <[EMAIL PROTECTED]> wrote:
> demerphq wrote:
>
> > I wasn't suggesting that this should fail and wouldnt suggest it should
> > either.
> >
> > I was suggesting that
> >
> > my $a=[];
> > is_deeply([$a,$a],[[],[]])
>
> So doesn't that just come down to
> is_deeply([], [])
> failing?
>
> Can we really say that
> x=y; but x,x != y,y?
>
> If that is the case, the it is completely non-intuitive.
>
>
> --
> Michael Peters
> Developer
> Plus Three, LP
>
>