This is correct, and in this case the base class uses -somefeature to activate a pragma, scoped using %^H. People have been wondering how multiple users of the same base class within the same application would be able to keep track of whether -somefeature is in effect. They probably haven't read (or don't recall reading) perlpragma. ...or possibly wish they never had read it. This is obviously not trivial magic.

So this is a case where a base class is designed to be inherited from, and to optionally provide some additional behavior, tracked as a pragma. The extends mechanism on its own doesn't accommodate this particular need. It's looking like the simplest approach is a use followed by an extends. That's fine, but consider this:

[non-Moose base class implementing -somefeature pragma] <- [Moose-style base class adapter passing through -somefeature pr +agma] <- [broad range of subclasses that inherit from Moose-style ba +se class, and that may or may not want to invoke -somefeature]

We've been able to manage the pass-through just fine, but extends alone isn't sufficient for making it work without use.

package NonMooseBase; sub import { # I'll spare you the treachery. } ... 1; package MooseBase; use Moose; use NonMooseBase; extends 'NonMooseBase'; ... 1; package MySubclass; extends 'MooseBase'; use MooseBase -somepragma; ... 1;

This probably will work. As long as inheritance is in place, the presence of the import list in use MooseBase -somepragma will cause ->import() to be called, and it gets inherited from NonMooseBase. We're already handling inheritance depth correctly and twiddling %^H appropriately. The one fly in the ointment was providing a Moosey intermediate class to allow new work to benefit from Moose without losing the useful tools built into the old-school base class.


Dave


In reply to Re^4: Passing an import list to Moose extends by davido
in thread Passing an import list to Moose extends by davido

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.