develooper Front page | perl.perl5.porters | Postings from May 2006

[perl #3306] DESTROY doesn't get called.

Thread Next
From:
Steve Peters via RT
Date:
May 1, 2006 06:57
Subject:
[perl #3306] DESTROY doesn't get called.
Message ID:
rt-3.0.11-3306-132943.10.644312074439@perl.org
> [abigail@arenanetworks.com - Tue May 30 09:25:02 2000]:
> 
> This is a bug report for perl from abigail@arena-i.com,
> generated with the help of perlbug 1.28 running under perl v5.6.0.
> 
> 
> -----------------------------------------------------------------
> [Please enter your report here]
> 
> This might be related to my previous report.
> 
> Consider the following program:
> 
>     #!/opt/perl/bin/perl -w
> 
>     use strict;
> 
>     sub new {
>         my ($class, $code) = @_;
>         bless $code => $class;
>     }
> 
>     DESTROY {
>         print "In DESTROY...\n";
>     }
> 
>     my $i    = "Hello";
>     my $exit = main -> new (sub {});   # 1)
> 
>     __END__
> 
> This will not print anything at all, indicating that the DESTROY
> method
> isn't called when $exit goes out of scope - not even on program
> termination.
> 
> If we change 1) such that new() is called with a closure, for instance
> by changing it to:
> 
>     my $exit = main -> new (sub {$i});   # 1)
> 
> DESTROY is called as soon as $exit goes out of scope.
> 
> 

This problem still exists in bleadperl.

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