Skip Menu |

This queue is for tickets about the Clone-Fast CPAN distribution.

Report information
The Basics
Id: 36015
Status: open
Priority: 0/
Queue: Clone-Fast

People
Owner: Nobody in particular
Requestors: silencer [...] mailcraft.ru
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Reference which equal undef is cloned incorrectly
code with Clone::Fast === use Data::Dumper; use Clone::Fast; $a->{b} = []; # $a->{b} is link to array $a->{b} = undef; # $a->{b} is still link to array, but undefined $b = Clone::Fast::clone($a); $a->{b} = 123; # and now $a->{b} != $b->{b}, wrong print Dumper($a); print Dumper($b); === code with Clone; === use Data::Dumper; use Clone; $a->{b} = []; # $a->{b} is link to array $a->{b} = undef; # $a->{b} is still link to array, but undefined $b = Clone::clone($a); $a->{b} = 123; # and now $a->{b} != $b->{b}, correct print Dumper($a); print Dumper($b); ===
You have made two errors. One is a mistake on your part and the other is just Perl 5 implementation. The first is when you assign undef to $a->{b}. You stated that it is an "undefined link to an array." There is no such thing. The value is now just undefined. The array was reaped and garbage collected when you assigned undef over it. The second error is not your fault but is insurmountable. There is only one undef value in any Perl interpreter and it is impossible to clone undef the way you are requesting. I am closing the bug because it is impossible to fulfill.
From: jjore [...] cpan.org
On Mon May 19 15:59:21 2008, Silencer2K wrote: Show quoted text
> code with Clone::Fast > === > use Data::Dumper; > use Clone::Fast; > $a->{b} = []; > # $a->{b} is link to array > $a->{b} = undef; > # $a->{b} is still link to array, but undefined > $b = Clone::Fast::clone($a); > $a->{b} = 123; > # and now $a->{b} != $b->{b}, wrong > print Dumper($a); > print Dumper($b); > === > > code with Clone; > === > use Data::Dumper; > use Clone; > $a->{b} = []; > # $a->{b} is link to array > $a->{b} = undef; > # $a->{b} is still link to array, but undefined > $b = Clone::clone($a); > $a->{b} = 123; > # and now $a->{b} != $b->{b}, correct > print Dumper($a); > print Dumper($b); > === >
BTW, further, I wish it were possible to do useful things like you're requesting with undef but alas, no. It is only with regret that I reject it. It will likely never become possible to solve this in Perl 5. Perhaps 5.12.