develooper Front page | perl.perl5.porters | Postings from July 2009

A Modest Proposal

Thread Next
From:
John Peacock
Date:
July 22, 2009 16:31
Subject:
A Modest Proposal
Message ID:
4A67A14E.9010907@havurah-software.org
So I left Damian's API design tutorial at OSCON with my head buzzing.  
In the haze afterwords, it occurred to me that this _should_ be sufficient

     use version; our $VERSION = 1.2.3;

to define a package $VERSION.  No version->new() or qv() required.  If 
you are running Perl 5.10.x you don't even need to include "use version"!

Is that a good thing?  Should I work towards that minimalist goal?

The reason this is sufficient is that version.pm includes a 
version-object-aware UNIVERSAL::VERSION, which will upgrade the $VERSION 
scalar to a version object if needed to do a comparison (e.g. 'use 
package 1.0').  That deals with the runtime usage.

However, there are three packages (that I'm aware of) that don't depend 
on runtime behavior, but rather grovel through the source file and use 
hairy regexes to extract that evaluate the $VERSION assignment:

1) Module::Build
2) ExtUtils::MakeMaker
3) the PAUSE indexer

Since M::B now uses version.pm internally (going so far as to provide a 
stub package if version.pm isn't already installed), it already DTRT.  I 
don't know about PAUSE, but I believe it would also be OK, or could be 
quickly patched.

That just leaves EU::MM.  Schwern has sworn up and down that EU::MM is 
DOOMED (the essay of which is unfortunately offline right now).  
However, I've forked his git repo and am working on a patch to make 
EU::MM behave like M::B when it comes to versions.  It hasn't taken that 
long to get something that passes almost all tests; of course the devil 
is in the details...

Opinions?  Brickbats?  What color should we paint this shed?

John


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About