in reply to Re: Re: use Very::Long::Module::Name as Foo;
in thread use Very::Long::Module::Name as Foo;
Your opinions on what is and is not obvious clearly differ from mine. And breaking out the 50 pound sledgehammer of source filters, along with all of TheDamian's heuristics about how to interpret what is valid Perl (which you are quickly obsoleting), along with the potential bugs when TheDamian gets it wrong, doesn't strike me as a conceptually lightweight approach. Even when the piece that you added is simple.
Now if you want parametrized uses, consider the following (untested):
This can now be used (assuming no bugs...) as follows:package load; use Carp; use strict; sub as { my $pkg = shift; # Set the alias. $_[0] = $pkg; # load the module eval "require $pkg"; die $@ if $@; # import it? shift; if (@_) { unshift @_, $pkg; my $import = $pkg->can("import") or croak("No import available to use"); goto &$import; } } 1;
If you prefer a constant approach, that isn't hard to do either.use load; Very::Long::Module->load::as my $short => qw(foo bar baz);
In any case the difference in ease of usage between these solutions and a source filter is pretty minor. The difference in potential problems is pretty large. (Note that I am steering towards solutions where you can create any aliases for yourself without trampling on any potential global namespace. That is both deliberate and, I feel, important.)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: use Very::Long::Module::Name as Foo;
by liz (Monsignor) on Oct 14, 2003 at 18:06 UTC | |
by tilly (Archbishop) on Oct 15, 2003 at 03:04 UTC | |
Re4: use Very::Long::Module::Name as Foo;
by dragonchild (Archbishop) on Oct 14, 2003 at 17:48 UTC | |
by liz (Monsignor) on Oct 14, 2003 at 18:18 UTC | |
by tilly (Archbishop) on Oct 15, 2003 at 02:48 UTC |
In Section
Meditations