develooper Front page | perl.perl5.porters | Postings from June 2009

Re: DESTROY: is there any predictability about when it's called?

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 13, 2009 14:43
Subject:
Re: DESTROY: is there any predictability about when it's called?
Message ID:
f86994700906131442u264a84cfrd5a7bad791ba4aea@mail.gmail.com
On Sat, Jun 13, 2009 at 12:45 PM, Andy Armstrong <andy@hexten.net> wrote:

> What I'm seeing is that with this code ( without the my (undef)... bodge ):
>
>  sub leakguard(&@) {
>    my $block = shift;
>    my $state = My::Mem::State->new( @_ );
>    my $rc    = $block->();
>    #my ( undef ) = ( $state );
>    return $rc;
>  }
>
>  leakguard { my $foo = Foo->new };
>
> it seems that $state is DESTROYed /before/ $foo - which surprises me a
> little.



Do you get the same problem with

    leakguard { my $foo = Foo->new; 1 };


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