in reply to coderefs keep references to themselves
sub Foo::DESTROY { print "foo::DESTROY called\n"; } { my $x = do {my $var; bless sub {$var}, 'Foo'; }; } __END__ foo::DESTROY called
The fact that a simple sub { "test" } isn't garbage collected is an optimization that's poorly hidden from the user. It basically means that perl doesn't have to recompile a sub. Since eval can't be cached anyway it doesn't make sense to perform that optimization there.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: coderefs keep references to themselves
by jettero (Monsignor) on Jul 15, 2008 at 12:04 UTC |