Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: base.pm vs @ISA

by creamygoodness (Curate)
on Oct 08, 2007 at 05:07 UTC ( #643383=note: print w/replies, xml ) Need Help??


in reply to base.pm vs @ISA

base is fine until you encounter one of its screwy action-at-a-distance behaviors. Then, after you've finally hunted down what the #$@&! is going on, you will curse it.

Enjoy the fun while it lasts.

--
Marvin Humphrey
Rectangular Research ― http://www.rectangular.com

Replies are listed 'Best First'.
Re^2: base.pm vs @ISA
by Somni (Friar) on Oct 08, 2007 at 06:15 UTC

    Based on reading the thread you linked, and testing the code, this action-at-a-distance behavior can be avoided simply by using the module first.

    From what I understand there are three major arguments against base.pm:

    1. Hidden errors when a module cannot be found.
    2. Manipulation of fields (ala fields.pm) when it's not needed.
    3. Inability to pass a list to used modules.

    Given that there are simple counters:

    • Use the module prior to passing it to use base. This solves both 1 and 3.
    • The fields manipulation is conditional, based on whether or not fields have been manipulated prior. If you don't need fields, base.pm won't do anything to them.

    So, given all of that, what you're left with is a decision between:

    use Module; use base qw(Module);

    and:

    use Module; our @ISA = qw(Module);

    I can tell you I prefer use base from a readability standpoint alone. It also has the advantage of assigning to @ISA at compile-time, instead of run-time, which can resolve some problems if the modules being used attempt to call class methods immediately. Admittedly, this is extremely rare, however.

    If you are aware of any other outstanding problems with base.pm, by all means, share them. Otherwise what this boils down to is a simple style issue.

      You are also forgetting that it sets $VERSION for you if you haven't already done it. I found that incredibly confounding when working with some Inline::C code.

      $Your::Module::VERSION = '-1, set by base.pm.';

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

        Aha, so it does. How exactly did it confound you?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-01-25 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (66 votes). Check out past polls.

    Notices?