develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl.git] branch doy/runtime_isa_manipulation_bug, created. v5.17.1-337-gbd8c24f

Thread Previous
From:
Father Chrysostomos
Date:
July 9, 2012 23:37
Subject:
Re: [perl.git] branch doy/runtime_isa_manipulation_bug, created. v5.17.1-337-gbd8c24f
Message ID:
20120710063744.19360.qmail@lists-nntp.develooper.com
Jesse Luehrs wrote:
> On Tue, Jul 10, 2012 at 05:05:45AM -0000, Father Chrysostomos wrote:
> > Anything else is madness.
> 
> I'm fine with this. My question is - how do you do this from perl space,
> if you don't know the name of the stash (as in, you just have the
> hashref)? I had been using Symbol::gensym in my code to generate new
> stash entries, but that's clearly wrong, because they have the wrong
> name. So... how do they get the right name? (If this isn't currently
> possible, should Symbol be rewritten with some XS to allow for doing
> the right thing?)

Temporary aliasing works:

sub vivify_isa {
    my $stashref = shift;
    local *__CLASS__:: = $stashref;
    *{"__CLASS__::ISA"};
    return;
}

use Devel::Peek;

Dump $foo::{ISA}; # a PVLV, because it does not exist
vivify_isa \%foo::;
Dump $foo::{ISA}; # GvSTASH points to foo
Dump \@{$foo::{ISA}};


Thread Previous


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