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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Not to detract from your excellent point, parent allows for (and documents) this case:

package MyHash; use Tie::Hash; use parent -norequire, 'Tie::StdHash';

I understand that use parent -norequire, 'Some::Class'; can be helpful, but it requires even more typing than our @ISA=('Some::Class');. I've considered for a few seconds if parent could fix what Tie::Hash broke, without forcing me to write more code.

Adding a few special cases for core modules like Tie::StdHash that exist in files where they should not be. A simple hash mapping broken classes to their containing files ({ 'Tie::StdHash' => 'Tie::Hash', 'Tie::ExtraHash' => 'Tie::Hash', ... }), plus a few lines of code to use that hash. Perhaps only if require failed to load the base class.

It would have solved the problem that use parent 'Tie::StdHash'; does not work out of the box. But the same would have to be added to base, and to every other module that manipulates @ISA for other modules. And it would require updating the workaround hash from time to time, whenever someone blindly copies the Tie::Hash anti-pattern.

Another way could have been adding a way to load a class and inherit from a different class to parent, eleminating the need to manually load the file containing the base class. Something like use parent 'Tie::StdHash', -from => 'Tie::Hash'; or use parent { 'Tie::StdHash' => 'Tie::Hash' };.

But again, why should parent fix what is wrong in other modules?

After all, parent's history is quite clear:

This module was forked from base to remove the cruft that had accumulated in it.

So, after about three seconds, I discarded that idea and did not write about it in the meditation.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re^2: Breaking Tie::Hash into three modules by afoken
in thread Breaking Tie::Hash into three modules by afoken

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 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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found