Yves has some controversial ideas about what is and is not data structure
equivalence.  I'd like comments on it.


----- Forwarded message from demerphq <[EMAIL PROTECTED]> -----

From: demerphq <[EMAIL PROTECTED]>
Date: Thu, 30 Jun 2005 23:17:19 +0200
To: Michael G Schwern <[EMAIL PROTECTED]>
Subject: Re: fixing is_deeply
Reply-To: demerphq <[EMAIL PROTECTED]>

On 6/30/05, Michael G Schwern <[EMAIL PROTECTED]> wrote:
> On Thu, Jun 30, 2005 at 10:25:52AM +0200, demerphq wrote:
> > I can put together a patch to make is_deeply a fair bit smarter if you like.
> 
> Almost forget:  sure!

Ok, ive started work on this, however there is a minor problem: The
test in circular_refs regarding rt.cpan.org 11623. (I added names to
make it easier to work with.)

{
    # rt.cpan.org 11623
    # Make sure the circular ref checks don't get confused by a reference 
    # which is simply repeating.
    my $a = {};
    my $b = {};
    my $c = {};

    is_deeply( [$a, $a], [$b, $c], "rt.cpan.org 11623 - 1" );
    is_deeply( { foo => $a, bar => $a }, { foo => $b, bar => $c },
               "rt.cpan.org 11623 - 2" );
    is_deeply( [\$a, \$a], [\$b, \$c],"rt.cpan.org 11623 - 3" );
}

In order to make a real structural comparison these tests have to go. 
In order to determine structural equivelence you have to include a
methodology of adding or altering data. If by doing so the two
structures changes differently then you have different structures, if
the structures are still equivelent afterwards you have equivelent
structures. This example would clearly fail the test. Altering $a and
$b in the same way would make the difference stand out quite clearly.

Ie it makes no sense that

    my $a = {};
    my $b = {};
    my $c = {};
    my $ar1=[$a,$a];
    my $ar2=[$b,$c];

    is_deeply($ar1,$ar2); # ok?!
    $ar1->[0]{a}=1;
    $ar2->[0]{a}=1;
    is_deeply($ar1,$ar2); # not ok. (expected)

I dont know if you want me to post any of the comments i have or if i
should just deal with them directly with you. Id be happy to do
either, but perl-qa didnt seem to me to be the right place. Am I
wrong?

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"


----- End forwarded message -----

-- 
Michael G Schwern     [EMAIL PROTECTED]     http://www.pobox.com/~schwern
ROCKS FALL! EVERYONE DIES!
        http://www.somethingpositive.net/sp05032002.shtml

Reply via email to