NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
import vs explicit importing (Score:1)
use LWP::Simple 'get'What happened to the mantra from Exporter.pod?
"Do not export anything else by default without a good reason!
Re:import vs explicit importing (Score:2)
Oh, its intentions are good. Its there to make authors think and to avoid modules like POSIX which export nearly everything. So often people only hear the "do not export anything by default" and miss the "without a good reason" part.
If your module doesn't do anything useful but provide functions, go ahead and export some useful defaults. The user's going to have to import stuff anyway, give them a leg up. Why? Choice. Specifically the user's.
Any module which exports by default can be turned into a module which does not. Observe:
use LWP::Simple (). It can also be turned into one which explicitly exports:use LWP::Simple qw(get). However, you can't take a module which does not export by default and turn it into one that does. I prefer to let the user decide if they want my convenient defaults or not.The worst offenders are those who don't allow exporting at all, I'm looking at you mro::compat [cpan.org] and Class::ISA [cpan.org].
Reply to This
Parent
Re: (Score:1)
Personally, I have mixed feelings about it. Some default exports can be handy and look clean. However, I like to grep my code for a function name and be able to figure out where it came from.
OO code tends to be traceable to the object construction. But with with procedural code, if there's no explicit export, it is more difficult to track down where a function comes from, and that can slow me down. (Yes, I know there are modules and techniqu
Re: (Score:2)
The wonderful thing is as a user of the module you always have that option no matter what the module author chooses to do.