in reply to Re: Garbage-collecting with closures
in thread Garbage-collecting with closures

Does that complain under strict? I tried the following:
use strict; my $foo = 0; sub leaky { my $closure = sub { $foo++ }; return $closure; } my $x = leaky(); my $y = leaky(); print $y->(), $/ while $x->() < 10; ---- 1 3 5 7 9
The output seemed to be correct ...

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
Re: Re2: Garbage-collecting with closures
by perrin (Chancellor) on Feb 19, 2003 at 23:37 UTC
    The output is correct, but it eats up memory. If you keep looping on that sub, your machine will go into swap.