On Sat, Jul 02, 2005 at 07:34:47PM +0100, Fergal Daly wrote:
> On 7/2/05, Andrew Pimlott <[EMAIL PROTECTED]> wrote:
> > Citing "computer science" as the basis of your position is just too
> > much.  The "computer science" answer to the comparison of references is
> > that they are equal if and only if they are the same reference.
> 
> Actually what Yves wants is known a testing if 2 structures are
> bisimulable in computer science.

Can you give me a hint as to the difference in a language like Perl?

> > That this is just one example, and if you try to worm out by saying
> > "such-and-such operation is not allowed", I'll find you another.
> 
> I'm not sure you will. As long as this is_deeply looks inside the
> objects of tied and overloaded refsthen the only operations that needs
> to be banned are those which look at the address of a reference
> (except to compare it to the address of another reference). If you
> exclude those operations (which are fairly useless outside of
> debugging) then I don't think anything else goes wrong.

What about

    my $x = [];
    my $a = [$x, []];
    my $b = [[], $x]
    is_deeply($a, $b);  # passes
    $a->[0][0] = 1;
    $b->[0][0] = 1;
    is_deeply($a, $b);  # fails

> >  I also think that
> > any such comparison should allow objects to override the comparison.
> 
> You need to be very careful there. Allowing objects on the "expected"
> side to control the comparison is ok but If you allow the data that
> you are testing to control it then your test is effectively
> meaningless.

I was thinking that the comparison function would be a class method that
would be called after verifying that two references point to objects in
the same class.  I think that should be safe enough.

Andrew

Reply via email to