I realise that I'm missing the precise context of why you want to find out you have a real OP object rather than something derived from OP (directly or indirectly), but part of the purpose of deriving from some base class is to pretend to be an object of that type, while changing the behaviour. So I'm trying to think why you (normally) would want to check that something is an OP, but only an OP.

I put "normally" there just because I realise you're probably doing some deep dark magicks (based solely on the fact you're inside B), and thus probably have a good reason to do this. But since Test::MockObject probably fakes things by changing its own ISA to go through inheritance, you're probably looking for a fairly significant overhaul of some of the object infrastructure of perl to allow T::MO to fake something without anyone else faking it.

That said, it makes perfect sense to me that a binary operator ISA operator. Because it is. However, a binary operator IS NOT a unary operator. They may share some code in common, but they aren't really the same thing. It's sorta like some of the OO examples that have Rectangle as a subclass of Square - which is wrong, because a Square ISA Rectangle, but a Rectangle is not (always) a Square. From an implementation perspective, you end up with smaller objects for Square if you put them in the object hierarchy backwards, which may be why you have BINOP as a subclass of UNOP.


In reply to Re: ISA but no farther? by Tanktalus
in thread ISA but no farther? by diotalevi

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.