Assuming Number::MixedFraction, and Number::Fraction::Tk are both happy to inherit the 'add' method from Number::Fraction (and get a Number::Fraction as the result) then wouldn't it make sense for Number::Fraction::add to be general enough to work in that scenerio?

I'd say so (although I agree with ihb and would use __PACKAGE__ rather than hardcoding the class name).

Ideally subclasses should do at least as much as their parent class, and possibly more (or, in design by contract speak - they must meet all their parents class invarients and post-conditions, and its own or its parents pre-conditions). I'd worry about the code if this wasn't true.


In reply to Re: if (UNIVERSAL::isa($r, ref $l)) by adrianh
in thread if (UNIVERSAL::isa($r, ref $l)) by hossman

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.