http://www.perlmonks.org?node_id=221093


in reply to Re^4: Class::InsideOut - yet another riff on inside out objects.
in thread Class::InsideOut - yet another riff on inside out objects.

Oh ok. I was expressing more of a generalized ability so I might combine that with a search of all the contexts I could find on the symbol table as well. Very slow, not the right approach but still doable. So that'd just have to go all around and collect the pads from every visible code reference and I'm thinking that eventually you hit the right one...


Fun Fun Fun in the Fluffy Chair

Replies are listed 'Best First'.
Re^6: Class::InsideOut - yet another riff on inside out objects.
by adrianh (Chancellor) on Dec 19, 2002 at 13:07 UTC

    Darn. I hoped there was something obvious I was missing :-)

    While scanning all coderefs & symbol table entries might work for a lot of cases, I don't think it is completely general. For example, consider:

    { package Foo; use base qw(Class::InsideOut); sub new { return bless [], shift }; { my %foo : Field }; };

    There are no subroutines that have %foo in their scope so, without generating code with a source filter, I can see no way of getting access to the pad with "%foo" in it.

        No. Foo::new is not in %foo's scope.

        It also doesn't reference %foo - which probably means it would be optimised out of the pad even if it was in scope (not 100% on the details of this sort of optimisation so I could be wrong about that).