Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Being helpful to a fault?

by Steve_p (Priest)
on Dec 11, 2003 at 13:08 UTC ( #314024=note: print w/replies, xml ) Need Help??


in reply to Being helpful to a fault?

Regarding your first question, I don't think there is a situation where you would want to, by default, load in every module in a directory. Could you imagine seeing

use XML::*;

in someone's code? Not cool.

I can see the motivation of the original question and how it could occur and why someone might think that it is what they want, and I'm guessing that its related to Object Oriented Perl. Let's say you have a perl class Foo, with subclasses Foo::A, Foo::B, and Foo::C. Now, if you have a script that could have any of those classes returned from a function call you would need to include all those packages. Now, if the function called from your script is changed to also return Foo::D, your script will likely be broken.

On your second question, I typically point to the larger problem if I can see one, and provide some options to solving the larger problem. I won't, however, go into a typical question assuming there is a major flaw in their design. In the case with this question, I'm assuming the layout of their modules, while working fine for their initial design, development, and testing, are turning into a pain when modified. Now, a change in file A is forcing changes in file B. If that is truly the deeper problem, rather than trying to work around use, they should look to placing the classes in question into a single file.

Replies are listed 'Best First'.
Re: Re: Being helpful to a fault?
by hardburn (Abbot) on Dec 11, 2003 at 15:29 UTC

    I don't think there is a situation where you would want to, by default, load in every module in a directory.

    Frankly, just because you don't see a reason for it, someone else may have a perfectly valid reason. In fact, I there is at least one good reason to do this: testing that all modules in a directory will load.

    Also, as another poster pointed out, this is supported by default in other languages, like Java:

    import java.io.*;

    Which is a case of Java supporting more laziness than Perl (a case which is quite rare).

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2021-10-22 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (85 votes). Check out past polls.

    Notices?