Mon, 21 Dec 2009
Alpha Modules and Perl's use Statement
I'm contemplating breaking a very well-established standard: Version arguments to Perl's "use" statement. The module writer is free to change the semantics of these, but despite the endless eccentricities you find on CPAN in other things, they rarely (never?) do.
So I'm having guilt feelings. Insecurities are coming out. I'm getting second thoughts. In this post I will handle these things the way many people do. Preach.
Consider a default module use like
The standard (and almost universal) semantics is to load whatever version is out there. This works if you can assume that the modules you're using are well-behaved and upwardly compatible.
Or if you have strict controls on the libraries in the environment in which
you are running.
But what if you are dealing with software
which is avowedly alpha?
Certainly allowing the user
to say "Just give me anything" is
very much in the Perl spirit.
And it's necessary in some cases.
Programs in a test suite should not be fussy about the version
of the software that gets thrown at them.
Crashing and burning because of new versions of software is their
role in life.
But with alpha modules, it's a poor default.
So I'm thinking of having my alpha modules accept
only two forms of the use
statement, both with two arguments.
use Marpa 0.001_037;
The numeric version of the two argument form means gives me version
Upgrades result in an error message.
use Marpa 'alpha';
The two argument form with the alpha argument means give me anything alpha or later --
in other words, anything at all.
That's the equivalent of the "wide open city"
But here the user has asked for it explicitly.
What do I do with the one argument form?
The one argument form gets you a multi-line error message
which summarizes what
I've just said.
This might make people think before including
a dependency on my new, alpha, module.
But is that a bad thing?
Shouldn't alpha code turn off unsafe defaults?
Perhaps other writers of alpha code should consider non-standard semantics
for the use statement. It will help me with my guilt feelings.
posted at: 22:36 |
direct link to this entry