develooper Front page | perl.perl5.porters | Postings from September 2019

[perl #134424] Anonymous subroutines which are not closures are NOTdeterministically destroyed.

From:
Tony Cook via RT
Date:
September 9, 2019 23:24
Subject:
[perl #134424] Anonymous subroutines which are not closures are NOTdeterministically destroyed.
Message ID:
rt-4.0.24-10240-1568071481-1564.134424-15-0@perl.org
On Sun, 08 Sep 2019 22:44:58 -0700, demerphq wrote:
> The following two one liners should output the same thing, in
> particular they should both output the same thing as the second piece
> of code.
> 
> This potentially could screw up code that is trying to do "ScopeExit"
> type behavior. I find it particularly confusing and wrong that the
> first example does not print out two "destroying lines".
> 
> $ perl -le'sub DestroyNow::DESTROY { print "destroying $_[0] in
> ${^GLOBAL_PHASE}" } sub foo { my $x= bless sub {}, "DestroyNow"; undef
> $x; return undef;}  foo(); foo(); print "All done\n" '
> All done
> 
> destroying DestroyNow=CODE(0x8bc6f8) in DESTRUCT
> 
> $ perl -le'sub DestroyNow::DESTROY { print "destroying $_[0] in
> ${^GLOBAL_PHASE}" } sub foo { my $y= shift; my $x= bless sub {$y},
> "DestroyNow"; undef $x; return undef;}  foo(); foo(); print "All
> done\n" '
> destroying DestroyNow=CODE(0xf83218) in RUN
> destroying DestroyNow=CODE(0xf83218) in RUN
> All done

Didn't you already report this in https://rt.perl.org/Ticket/Display.html?id=134313 ?

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=134424



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