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

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

Thread Previous | Thread Next
From:
Yuval Kogman
Date:
May 1, 2006 09:33
Subject:
Re: [perl #3306] DESTROY doesn't get called.
Message ID:
20060501163244.GU10759@woobling.org
On Mon, May 01, 2006 at 17:38:13 +0100, Dave Mitchell wrote:

> One possible fix would be a COW scheme: when bless tries to bless a code
> ref that happens to be an anon sub prototype, a new prototype is made and
> stuck in the pad for future use. But that doesn't completely solve the
> problem: any existing refs to the shared protoype will get to see the
> blessed version of the sub.

Why is there a distinction between prototype and non prototype?

sub foo { sub { } };
my $sub = foo();
my $copy = foo();

aren't $sub and $copy different ref addrs? and don't they have
'bless' handled by simply copying the sub to a "normal" copy?

traditionally the optimization is that if the copy count is 1 then
this allocation can be written in place - this is more like shared
constants.

-- 
  Yuval Kogman <nothingmuch@woobling.org>
http://nothingmuch.woobling.org  0xEBD27418


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