What if we could drop archives into @INC?
What if I didn't have to install distributions, but instead just dropped the entire archive into a directory, much like a Java JAR file? I don't have a complete idea for this, but I have enough that I want to have public notes on it.
This is something that I think about when I can't do anything else. I'm on a bus or train in Chicago where any sign of Apple technology will get you jacked (the CTA even has signs telling people to be careful with their iPhones. Not Blackberrys or Samsung, or whatever, just iPhones). There's that time between finishing the in-flight magazine and reaching 10,000 feet, or waiting in line for passport control after I wonder if the guys with the guns would really shoot me if I took out my cell phone.
My idea is the confluence of several problems:
- I'd like a way to have multiple versions installed without a huge
- Perl stops looking when it finds the first matching namespace
- Many people want to install tests so they can test later too, mostly to check the tests against newer versions of dependencies
- Perl 6 wants to load by name, version list, and author list.
- People hate installing things.
The problems are legion and formidable:
- Perl maps namespaces to filenames, unfortunately
- You have to extract dependencies and fetch those distress
- Pure-perl Archive::Tar is really slow.
- You can't compartmentalize a namespace so you can have divergent versions of it
- You have to infer from the archive name what might be inside and what version it might be
Let's ignore the first two for a moment. Those are just work, even if that work is annoying. The last one is something I've wanted for a long time. I thought I wrote about this before, but I didn't find it (I can't remember any non-stopwords I would have used).
Instead of loading modules, I'd like to load groups of modules into a variable. This wouldn't really load the distribution. It merely loads a description of the distribution which I can then play with as some sort of loader object:
my $lwp4 = load( 'libwww-perl', '< 5.0', 'GAAS' ); # distro name stub
my $lwp5 = load( 'libwww-perl', '>= 5.0', 'GAAS' ); # co-exists nicely
my %namespaces = $lwp4->list_namespaces; # names and versions
my %dependencies = $lwp4->list_dependencies;
my $file = $lwp4->extract_file( $file );
my $test_result = $lwp4->run_tests;
# and many other accessors
my $ua = $lwp4->use( 'LWP::UserAgent', @import_list );
That requires a lot of extra bookkeeping to put things in different, but user-hidden namespaces.
But, let's say someone figures out that part. It might be really easy to do something like that if everything (and absolutely everything) was a Moose class so Moose can move all the class names around.
The next bits are the mechanics. You want to extract the files from the distribution as you need them. That's not terribly hard, although tar is probably not a good way to do it because you'll want random access and you want to know where all the files are without having to scan the entire archive. Sure, you can kludge some pre-indexing, but let's pretend that we could convert all of CPAN to a different archive format.
So, all of that is solved. Now you get to deal with all of the crappy code in CPAN. These modules use package variables because, probably rightly so, a module gets to do what it likes with its package. But, package variables don't work anymore because packages don't exist in the same way.
And then...well, that's as far as I've thought about this.