On Wed, Feb 23, 2005 at 09:49:40AM +0100, demerphq wrote: > DD needs to catalog scalars so it can handle cyclic references and > self referential data structures. Consider: > > my @array=(1..10); > my %hash=(a=>\$array[2]); > > print Dumper([EMAIL PROTECTED],\%hash); > > Id be really surprised if DD passed self test with this change applied.
Currently DD contradicts it's documentation: $Data::Dumper::Deepcopy or $OBJ->Deepcopy([NEWVAL]) Can be set to a boolean value to enable deep copies of structures. Cross-referencing will then only be done when absolutely essential (i.e., to break reference cycles). Default is 0. but in the example you gave, cross referencing would have been performed even though there was no cycle. By definition you only need to catalog references to catch cyclic references. DD only catalogs scalars to find cases like yours above but a deep copy would have broken that cross reference. You're right about the tests though, I got the meaning of Deepcopy backwards, I should have turned off cataloging when Deepcopy is on, not off. Correct patch attached and the tests pass. > Also, im confused about this patch. Why arent you using the XS code? > With the code youve posted I would expect DD to use the XS code, and > the patch youve posted wouldnt change its behaviour. Not that the XS > is any better in this regard, im just confused why you think this > patch should work. Simple reason, it's easier to debug and fix the Perl code. I'll do the XS stuff later if the Perl fix is accepted, F
