On Mon Feb 01 11:54:12 2010, DCANTRELL wrote:
Show quoted text> On Wed Dec 16 12:08:49 2009, SHARYANTO wrote:
> > $ perl -MData::Compare -E'$a={c=>1}; $a->{a}=$a; $b={c=>1}; $b->{a}=
$b;
Show quoted text> > say "equal" if Compare($a, $b)'
> > $
> >
> > but:
> >
> > $ perl -MStorable=freeze -E'$a={c=>1}; $a->{a}=$a; $b={c=>1}; $b->
{a}=
Show quoted text> > $b; say "equal" if freeze($a) eq freeze($b)'
> > equal
> > $
>
> This comes down to differing interpretations of what data are
> equivalent. In this case, while the *structures* are equivalent, the
> data are different, as is evident by stringifying $a->{a} and $b->{a}:
>
> $ perl -e '$a={c=>1}; $a->{a}=$a; $b={c=>1}; $b->{a}=$b; print
> $a->{a}."\n";print $b->{a}."\n"'
> HASH(0x812c1c8)
> HASH(0x812c0e4)
But this works (the two [1] refs don't stringify the same too because
they are two copies):
$ perl -MData::Compare -le'$a={a=>[1]}; $b={a=>[1]}; print $a->{a};
print $b->{a}; print Compare($a,$b)'
ARRAY(0x627df0)
ARRAY(0x627c40)
1
As long as the structures are the same and the data values are the
same, shouldn't they be considered the same? Isn't that what
Data::Compare is all about?
Make this analogy: the recursive structure is a circle (or Mobius
strip) of 5cm diameter. Shouldn't it also be "comparable" with another
circle (or Mobius strip) of 5cm diameter too, even if they are separate?