Perhaps you call it "stupid" because you don't understand what it's for.

When you override a method in a subclass, you frequently need to modify or reuse the superclass behavior. So you need a construct that says "if I wasn't here, what would have been called".

But let's say you were already an inherited method. To do the lookup, you can't start in the object's superclass... you have to start in the method's superclass, otherwise you'll get into an infinite loop, calling yourself over and over.

Hence, the current behavior is precisely right, albeit a bit awkward if you don't get the purpose of the behavior. Also, the closest thing we have to "class of the method" is "package in which the method was compiled", which is not necessarily the same as "the package in which the subroutine is located", as I've illustrated in the past here. That's both a blessing and a curse, but I'll save the longer discussion for another node.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.


In reply to SUPER does the right thing - don't disrespect it! by merlyn
in thread inheritance weirdness by dash2

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.