develooper Front page | perl.perl5.porters | Postings from August 2003

Re: [perl #10030] DESTROY not called on code reference objects

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
August 18, 2003 15:13
Subject:
Re: [perl #10030] DESTROY not called on code reference objects
Message ID:
20030818231329.K558@plum.flirble.org
On Mon, Aug 18, 2003 at 05:50:16PM -0400, Chip Salzenberg wrote:
> According to Simon Cozens:
> > Yitzchak Scott-Thoennes:
> > > > >     my $y;
> > > > >     { my $x = bless sub { $y }, 'X'; }
> > > > >     sub X::DESTROY { print "DESTROYED\n" }
> > 
> > My initial reaction is that calling a destructor on a sub that happens
> > to be a closure and not on one that doesn't is not just an unexpected
> > special case, but it's surely a bug. Why (and I ask this honestly, not
> > rhetorically) is it supposed to be so hard to fix?
> 
> Because every value of
> 
>   $a = sub { print "hi" }
> 
> is the same CV.  Printing $a will confirm this.  The original owner of


Oh yes. Mmm. Arguably action at a distance:

$ perl -le 'sub foo { return sub {}}; $a = foo; $b = foo; print ref $b; bless $a; print ref $b'
CODE
main

Nicholas Clark

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