On Apr 7, 2004, at 9:35 AM, John Peacock wrote:
The "version" module attempts to perform all conceivable version comparisons in a consistent and predictible fashion, by converting everything used as a version into a version object. $VERSION is a special scalar, on par with any of the magic punctuation scalars, even though it looks like an ordinary user-space scalar. It is, I believe, the only Perl-level scalar referred directly by the C-level Perl code by name (again other than the punctuation scalars).

Consequently, $VERSION handling is always going to be somewhat different from all other scalars. And, given that both M::B and EU::MM are attempting to load a module without really loading it, just for the purposes of judging that module's $VERSION, I don't see any way around the current level of magic/hacks.

Really, there are two kinds of hackitude going on. There's all the hoops that EU::MM and M::B jump through to *find* the $VERSION, and then the hoops that version.pm jumps through to *parse* the $VERSION. The main thing that annoys us, of course, is the former. I don't think the M::B people have ever even really thought about the latter much. ;-)


If I was writing M::B and EU::MM (which I am not, thanks!), I would do the following psuedo-code:

        'use version' in M::B EU::MM directly
        find the first line containing an assignment to the scalar $VERSION
        eval the right side
        if the result is not a version object, make it one
        keep the $VERSION as an object for comparison purposes
        stringify $VERSION only when required (say for the dist filename)

That might be the right way to do it - if so, then we should do the same with versions in 'requires' and 'recommends' and so on.


One thing that came up in the recent P5P discussion of versions and stringification was the idea that version.pm could offer a custom function which could be used to extract $VERSION from a random module, something like

$mod_version = version->from_module("modulename");

which would return a version object for later use. This would relieve both M::B and EU::MM from maintaining their own code for that purpose (and I think there was a third module that had it's own routines to do this). I am willing to work (with others) on developing a common function to do this. Would that help?


Yeah, it might. It would at least make it your problem instead of mine. ;-)


-Ken



Reply via email to