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)....


In reply to Re^2: mro's which to use for flexibility? by perl-diddler
in thread mro's which to use for flexibility? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.