Thanks for your replies. I summarize here.
I see the problem was that I thought the SUPER::defaults() method
applied to the object it was called on.
As noted by "Anonymous Monk", pike, and demerphq (who referenced
`perldoc perlobj`), SUPER:: is relative to the package containing
the SUPER:: construct and not the package of the object that called it.
It seems, then, that one would basically rewrite the functionality of
can(), which tye said is probably not worth it. In fact, I like tye's
solution, the goal being to simplify the coding of subclasses
(why else use OO? :).
Finally, the (welcome) criticisms.
-
demerphq asked that I mention the parent classes
before the subclasses. I apparently think upside-down. 8)
(I just noticed the "d/l code" link, which pulls out the
<CODE> sections; I assume that is part of the motivation.)
-
demerphq also mentioned checking that the subroutine
arguments are allowed. I'll re-read those points in the
"Object-Oriented Perl" book and try to figure it out.
-
I agree with tye's point that using `my` instead of `return`
is stupid. Probably I'll end up creating a `my` variable and
returning it, though.
Again, thanks for everyone's help.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.