in reply to Re: Garbage-collecting with closures
in thread Garbage-collecting with closures
This would be a closure being passed to a Tk function:
sub make_counter { my $count = shift; sub { ++$count } } $mw->Button(-text => "count", -command => &make_counter(0)});
That in and of itself shouldn't produce leaks -- the closure will be deconstructed along with the Button deconstruction. I would imagine you need be wary of reference cycles, however, like this (functionally meaningless):
sub make_ref_reporter { my $thing = shift; sub { ref $thing } } $mw->Button(-text => "refthing", -command => &make_ref_reporter($mw) +);
Matt
|
|---|