develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [rt.cpan.org #70622] Versions Disappear

Thread Previous | Thread Next
From:
David Golden
Date:
September 8, 2011 10:51
Subject:
Re: [rt.cpan.org #70622] Versions Disappear
Message ID:
CAOeq1c_td43VG0Rtw+J+MrNMHiSiHZGyqtw6pO_0+2mD0FtzqA@mail.gmail.com
On Thu, Sep 8, 2011 at 12:23 PM, David E. Wheeler <david@kineticode.com> wrote:
> On Sep 8, 2011, at 9:03 AM, David E. Wheeler wrote:
>
>>> $ perl -E'package Foo 1.23; say ref($VERSION)'
>>> version
>>
>> +1
>>
>> Okay then!
>
> Er, although:
>
>    > perl -E'package Foo 1.23; say ref(Foo->VERSION)'
>
>    > perl -E'package Foo v1.23.0; say ref(Foo->VERSION)'
>
> Wha?

I think that goes back to my point that Foo->VERSION should return
whatever is in $Foo::VERSION without modification.

As I consider UNIVERSAL::VERSION, the only reason I can think for it
to exist at all is to allow version checks equivalent to a "use NAME
VERSION" call.  E.g.

    use Foo 1.23;

    use Foo;
    Foo->VERSION(1.23);

We would like to have the argument to VERSION treated as close as
possible to the semantics of a version check as part of use() -- which
isn't easy as use() gets some custom parsing.  This explains why
VERSION requires both $Foo::VERSION and the argument to VERSION to be
sane (lax) version number -- it's matching the semantics of "use Foo
1.23" which would blow up for "use Foo 3crap" or "$Foo::VERSION =
q{3crap}".

To say that differently -- VERSION requires things to be upgradeable
to version objects not because version objects are inherently
desirable in themselves, but because it's what happens internally
during "use NAME VERSION" checks.

Having UNIVERSAL::VERSION return a useful value was probably a poor
API choice in retrospect.

-- David

Thread Previous | 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