Subject: | Documentation bug |
Regarding WeakRef-0.0.1
In the first example in the documentation for WeakRef a small bug has crept in. The example is:
use WeakRef;
for($i=0; $i<100000; $i++) {
my $x = {};
my $y = {};
$x->{Y} = $y;
$y->{X} = $y;
weaken($x->{Y});
} # no memory leak
The example should be of a circular reference from $x to $y to $x to $y etc. but instead it is from $x to $y to $y to $y etc. And therefore the 'weaken' has no real effect. I tested this on my perl 5.8.3 on Win32 but I believe it must be general. The fix is to change
$y->{X} = $y;
to
$y->{X} = $x;
or
weaken($x->{Y});
to
weaken($y->{X});
but then $x would be obsolete...
The module works fine and even though it is still only v. 0.0.1 I have no qualms about using it in production :-)
PS: perl -v gives me:
This is perl, v5.8.3 built for MSWin32-x86-multi-thread
(with 8 registered patches, see perl -V for more detail)
Copyright 1987-2003, Larry Wall
Binary build 809 provided by ActiveState Corp. http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Feb 3 2004 00:28:51
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.