Trey Harris wrote:
In a message dated Mon, 7 Jan 2008, Richard Hainsworth writes:
May I suggest the following extension to the 'use ' pragma, viz.
use <module name written in unicode and case sensitive> in <filename
as constrained by local system>
Oh please, no.
The entire point of the wording currently in the synopsis is so that
we can have platform-independent location of libraries. The "name
mangling capability" hypothesized lets the same C<use> get the
requested resource, regardless of the file (or database location!)
where the resource is actually located on the platform running Perl.
The reasoning for the arcane language becomes clear. My thanks.
Definitely a good idea for the implementation / implementors to decide
how to get a resource magically.
But ...
I have run into situations where I wanted to have more control over
where specific resources were located, at least temporarily. And I could
not find a simple way to do it in perl5.
Or is there some other magic I have not understood (and there is a lot I
dont understand) that would allow for this as perl6 is already specified?
Your proposal would force us to have platform-dependent locations, and
hence platform-dependent programs. Do you really want to see dozens
of switches like
given $?OS {
when m:i:/win/ { use Foo in WinFoo.pm }
when m:i:/nix/ { use Foo in UnixLikeFoo.pm }
}
at the top of programs?
No. That would not be nice.
Yet, does my proposal *force* this? Is it not possible for the magical
resource locator to coexist with a mechanism to allow local control?
And why would WinFoo.pm differ from UnixLikeFoo.pm? They are both text
files. To the extent they interact with the operating system, perl
already manages manfully (no fork in Windows).
But what about
#use GetUserResponse in 'smpl_ui.pm'; # when debugging
use GetUserResponse in 'our_gui.pm';
The broken operating system, or rather family of systems (and I
converted away from them about three years ago), still is used by 90%
of users. In practice, it does matter what happens in that environment.
Yes--but better for implementators to make that decision than for each
and every Perl programmer (most of whom will have no experience with
most OS's Perl runs on, so will be making such decisions blind!) to
make them separately (and differently).
True. Yet this implies all Perl programmers write for platform
independence. My experience has been that when I was using perl under
windows, I had to use ppm made available by ActiveState. Whereas for
Linux, I could use CPAN directly. This indicates a conversion procedure
and rules of best practice for software whose authors want it to be used
cross-platform.
<snip>