Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Yes, this error message sucks. It should list the two possible explanations with the most likely ("no such method") stressed more than the other ("*.al file missing because module not properly installed").

Note that this error message is a result of over-use of inheritance. In particular, this line from DBI.pm:

@ISA = qw(Exporter DynaLoader);

means that DBI "is a" Export and "is a" DynaLoader. Which means that if either Exporter or DynaLoad "is a" SomethingElse, then DBI also "is a" SomethingElse.

So some implementation detail of Exporter or DynaLoader becomes the baggage of DBI because it declares itself to be a descendant of them. In this case, the detail is that one (or both) of them "is a" AutoLoader (or similar). So DBI suddenly acts like an AutoLoader even though it had no desire to do so.

It would be better if Exporter and DynaLoader didn't use inheritance to get the AutoLoader functionality. And it would be better if DBI didn't use inheritance to get Exporter nor DynaLoader functionality.

Note that this realization has lead to Exporter now supporting better ways for it to be used, such as:

use Exporter qw( import );

And note that some module authors have realized this problem with DynaLoader and worked around it similarly:

require DynaLoader; # ... DynaLoader::bootstrap( __PACKAGE__ );

It is rather sad that the OO mindset so often jumps to inheritance as the answer for nearly every problem. Here we have two important core modules that mostly just need to provide one subroutine to the modules that use them, yet they encourage inheritance to be used to accomplish this.

It would be nice if DBI would fix this. Since DBI tries to be quite portable, it probably can't assume a modern version of Exporter, so it should instead use something like this:

BEGIN { require Exporter; *import= \&Exporter::import; }

Thus DBI would no longer produce this particularly misleading error message.

- tye        


In reply to Re^2: What is the /auto/ directory used for? (inheritance--) by tye
in thread What is the /auto/ directory used for? by nmerriweather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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> <u> <ul>
  • 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 intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-08-03 14:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (39 votes). Check out past polls.

    Notices?