This is related to the regex parser module. I'm trying to fix a problem encountered when trying to use multiple user-defined add-on modules.

The base class (for these purposes) for a "quant" object is Rx::quant. If you write an add-on, MyRxA, then a MyRxA::quant object's @ISA is (Rx::quant). If you write an add-on, MyRxB, then a MyRxB::quant object's @ISA is (Rx::quant).

MyRxA::quant::raw() changes the output of all quantifiers to '%' characters; this means a+b would render as a%b.

package MyRxA::quant; sub raw { my $self = shift; return "%"; }
MyRxB::quant::visual() makes the quantifier appear before the thing it quantifies; a+b would render as +ab.
package MyRxB::quant::visual; sub visual { my $self = shift; return $self->raw . $self->{data}->visual; }

Now we want to write MyRxC, which uses MyRxA and MyRxB as base classes. This means we want a+b to render as %ab. (Confusing? Sorry. Just bear with me.) The problem is that, because of the way @ISA is set up, an object of MyRxC::quant has the following inheritence tree:

This means any call to a method of a MyRxC::quant object would only be re-dispatched to the MyRxA::quant namespace, and no method in MyRxB::quant would ever be called.

I haven't considered the more difficult scenario of two classes overriding the same method.

I'm stuck. I'm not sure how to traverse the @ISA tree properly. I don't think NEXT has the right tools for the job. I kind of want an "OVER::", not a "NEXT::" or "SUPER::". It looks like I want a breadth-first @ISA scan, not a depth-first scan. What I really want is to avoid looking in Rx for the method until the VERY end. Maybe the solution, then, is not to put Rx in the @ISA tree, but rather to look in Rx after all others have failed, via AUTOLOAD?

_____________________________________________________
Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

In reply to Multiple Inheritence, Munging @ISA by japhy

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.