On Apr 23, 2012, at 9:24 AM, David Mertens wrote: > On Mon, Apr 23, 2012 at 10:00 AM, Doug Hunt <[email protected]> wrote: > Or, just put "use PDL::Lite" at the top of your module to avoid such hassles. > > PDL group: Is it normal to do all required 'uses' in the module, or should > the script calling the module be expected to do it? > > Defensive programming is always best. Your users may simply use your module > to obtain a piddle, then pass the object to other libraries that expect > piddles, so they don't need to say "use PDL" in their own namespace. > > I don't see that it would hurt to 'use PDL' in PDL/NetCDF.pm. > > To keep things light, I would add "use PDL::Lite". Otherwise you're going to > have Perl unnecessarily pull many symbols into PDL::NetCDF's package space, > which makes the load time longer than it ought to be. >
I agree vigorously with David. If you need something within your module, use it within the module. Perl's "use" is specifically designed to not cost much for reloading modules that are "use"d multiple times. Contrariwise, "use PDL" has grown out of all reasonable proportion since we expect it to pull in so much functionality, every time. So it is best to "use PDL::Lite" in your module if you just need basic support, "use PDL::Lite; use PDL::<foo>" if you need a little more, or "use PDL" if you can't be bothered to optimize. Cheers, Craig
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
