in reply to OOP introspection

I suppose one way to do it would be to go "up the chain"; utlizing SUPER (i.e., $self->SUPER::new + ref on the ancestor to get __PACKAGE__, it's reasonable to assume you could explore the turtles all the way up). Start with your initial blessed reference; recreate parent using my $father = $son->SUPER::new; use $father to recreated grandfather, so on and so forth. This example relies on each having new; but seems to reason it would work in Moo, Moose, and their elk.

Replies are listed 'Best First'.
Re^2: OOP introspection
by dsheroh (Monsignor) on Apr 03, 2021 at 11:37 UTC
    Aside from the reliance on a predictably-named constructor (->new), this also implicitly assumes single inheritance. I'm not sure that there's any practical way to get all the ancestors in a multiple-inheritance scenario other than iterating the @ISAs.
      I didn't consider multiple inheritenace. I suppose I need to play with SUPER to see what it does in that case.
Re^2: OOP introspection
by roboticus (Chancellor) on Apr 03, 2021 at 12:22 UTC

    perlfan:

    If the system allowed additional upvodes, I'd give an extra one just for that last word. ;^)

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.