I recently suggested that Perl 5 extend the ‘package’ keyword to also set the package $VERSION:
package Foo 1.00;
package Foo :ver(1.00);
I disagree. A major problem with the multitude of ways to set $VERSION is that it doesn’t necessarily correspond to how the ‘use’ keyword parses a module version restriction.
My strong belief is that any extension of ‘package’ should mirror ‘use’ in both semantics and style, like this:
# In a module package Foo 1.00; # Elsewhere use Foo 1.00;
Having Perl parse both the same way guarantees congruence in the interpretation of the version numbers.
Extending ‘package’ in this way would require changes to toolchain modules, but since extending ‘package’ would only happen in a new version of Perl, it would be relatively simple to ensure that the toolchain modules in that version are changed as well.
The one big thing outside Perl itself that would need to change is the way in which ‘alpha’ distributions are designated on PAUSE/CPAN. Rather than designating them through underscores in the distribution version (Foo-1.00_01), the release status designation would need to move into distribution metadata.
I think this would be a good evolution for CPAN as well as Perl. The current method of handling alphas is kludgy. It’s hard (perhaps impossible) to specify alpha versions robustly in a ‘use’ statement or in distribution dependency data. Version numbers should just be version numbers. Release status should be managed separately.
While extending ‘package’ won’t eliminate the historical problems with $VERSION on the thousands of modules on CPAN, it would at least put things on the right path going forward and I hope it becomes part of Perl 5.12 in the future.