develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl #109270] leak on accessing anon sub inside another one

Thread Previous | Thread Next
From:
Alexandr Gomoliako
Date:
January 29, 2012 12:47
Subject:
Re: [perl #109270] leak on accessing anon sub inside another one
Message ID:
CAKb9G9i1ayJL05PcEq+6-LSW3L2PXOaRoB1CAQ7RQaJFftBqqw@mail.gmail.com
On Sun, Jan 29, 2012 at 10:35 PM, Father Chrysostomos via RT
<perlbug-followup@perl.org> wrote:

>    $foo = $foo_life_raft = sub {  &$bar   };
>    weaken($foo);

> I usually like to call the variable $life_raft or similar in my own
> code, because it keeps the referent ‘afloat’ till the end of the
> enclosing scope.

> That example will work if $foo is the closure that will be returned or
> assigned to something.  If $bar is to be returned, then $bar has to be
> weakened (with a $bar_life_raft to keep it alive till the end of sub leak).

Thanks, nice approach.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About