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:
Dave Mitchell
Date:
August 19, 2003 19:44
Subject:
Re: [perl #10030] DESTROY not called on code reference objects
Message ID:
20030819201909.GA6164@fdgroup.com
On Tue, Aug 19, 2003 at 05:29:09PM +0100, Arthur Bergman wrote:
> 
> On Monday, August 18, 2003, at 07:12  pm, Dave Mitchell wrote:
> 
> >
> >Assuming that we wish to keep the optimisation of sharing non-closure 
> >anon
> >CVs, then the problem is that by the time you try to bless the coderef,
> >its already pointing to the shared CV, and you're buggered. By then, 
> >you
> >don't really have the option of unsharing it. At least I can't think of
> >a clean way.
> >
> >
> 
> COW?

AFAIKT, any COW scheme would break the following:

    my $sub = sub { print "hello" };
    my $sub2 = $sub;	# $sub and $sub1 point to the same CV
    bless $sub, 'Foo';	# $sub now points to a copy via COW
    print "not ok\n" unless $sub == $sub2;

-- 
The optimist believes that he lives in the best of all possible worlds.
As does the pessimist.

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