Actually I do have an empty DESTROY but I did not bother copying it. In my case if there is no DESTROY then the program tries to do stuff on a non-existent CGI::Application reference.
The inheritence question is more interesting. Yes I can see my approach makes no special effort to handle inheritence. But actually I think it would work. Let me put my approach in words.
- Avoid AUTOLOAD except where it gives a big gain in loose coupling.
- Don't rely on someone else's module. The area is too complicated.
- This means you have to craft your own solution, but it is fairly simple.
- Define a DESTROY method as bad stuff happens otherwise.
- Define a semantically correct "can" function that either returns undef or a CODE ref.
- Define the AUTOLOAD function in the fairly standard way based upon the "can" function.
- If I were to write a derived class I would either inherit both "can" and "AUTOLOAD" and override less impactful functions; or I would override "can" in the same way and make use of SUPER::can where appropriate.
- I avoid multiple inheritence so I would make autoloading in a multiple inheritence scenario an absolute no.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.