Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Breaking Tie::Hash into three modules

by afoken (Canon)
on Sep 09, 2018 at 10:16 UTC ( #1221971=note: print w/replies, xml ) Need Help??

in reply to Breaking Tie::Hash into three modules


For the last 16 years, it seems that nobody complained about Tie::StdHash no longer inheriting the useless new() from Tie::Hash. So I am very sure that we can also move that class safely out of Tie/

Having a fresh look at the code of both Tie::StdHash and Tie::Hash explains why nobody complained:

  • Tie::Hash::TIEHASH() is designed to call new() in an inheriting class, or to be reimplemented by the inheriting class. If the inheriting class implements neither new() nor TIEHASH(), Tie::Hash::TIEHASH() croak()s.
  • (If the inheriting class implements new(), but not TIEHASH(), Tie::Hash::TIEHASH() warns that it calls new() because TIEHASH() is missing. So why even bother to implement new()?)
  • Tie::Hash::new(), which is never called by tie, just calls TIEHASH() of the inheriting class. Implementing new() in an inheriting class does not make any sense at all, because you need a class name, not an object, for tie.
  • Tie::StdHash implements its own TIEHASH(), as expected by Tie::Hash and tie. This prevents new() from being called indirectly from tie().

So, no class inheriting from Tie::StdHash needs a new() implementation.


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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1221971]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2022-01-28 08:17 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (73 votes). Check out past polls.