Actually, you gave a direct hint. "I would not use inheritance...", which seems like it might be a hint that there is no easy way to do what I want using normal inheritance. Or is my interpretation incorrect? I'd love it if it was. ;-)
OTOH, maybe you can explain what you mean by the terms 'aggregation' and 'roles'. I may understand the concepts, but maybe not by those names, or such. For example, I'd think
of aggregation being something like combining multiple copies of the duplicate module into the modules that use them, which feels wrong on multiple levels, so I move to my fallback position of claiming ignorance of the how you define and use those terms.
Part of the problem probably comes from my manually "pushing" or "unshifting" the key
module where the 'open' is:
use Data::Vars [ qw(dry_run overrides todos) ],
{dry_run=>0, todos=>[], overrides=>{} };
use Switches;
BEGIN{unshift @ISA,"TorClient";}
our $mp = Data::Vars->new();
P "main::ISA=%s", \@ISA;
$mp->trm_open('trm', 'localhost:1024');
Which produces this output:
main::ISA=["TorClient", "Switches", "Data::Vars"]
Can't locate object method "trm_open" via package "Data::Vars" at ./to
+r_mgr line 360.
at ./tor_mgr line 360.
Of note, trm_open is in the 1st package listed in @main::ISA.
On the surface, it seems like the normal "search for subs in @ISA packages and descendants, w/that order based on the mro.
Oddly enough, method resolution **rarely** need look into the DV package at
any level, since it exports the "access routines" for the varnames specified in the first array ref. There are a few, little-used, util routines in that module to allow merging, handling 'new' to create an initialized copy of the vars in the passed and/or returned pointer. I could experiment with not including Data::Vars in the ISA list(s), but as the D::V module is used in a few over 700 places in various progs and modules in my bin dir, testing for side-effects would be a real pain.
Maybe your mentioned methods might provide alternate ideas... Either that, or first thing
I might attempt is clearing the mro cache before that 1st call.
A second idea (which is a big "unknown" for me), is creating an mro that works with
dynamic ISA alteration)....
|