develooper Front page | perl.perl5.porters | Postings from February 2022

Pre-RFC: use :version($version_spec)

Thread Next
Ovid via perl5-porters
February 9, 2022 09:39
Pre-RFC: use :version($version_spec)
Message ID:
I like the *idea* of (, but it's not terribly robust. Much of our ability to control exact versions of modules rely on external tools such as Carton and, while it's awesome, I think Perl should offer some native support. Even if we use tools such a Carton or Pinto, it's trivial to type `cpanm Slurp::In::A::Huge::Ecosystem` and you don't realize behind the scenes that you've upgraded versions that you thought you pinned in Carton. Many times in trying to track down a subtle bug, I've had to dump %INC and compare it to another developer's %INC.

Currently, we can do this:

    use Some::Module 3.14;

The problem is that this is the lower-bound of the version number. We have to jump through hoops if we don't want version 4 or higher, and if version 3.27 has a critical bug, yeah, make sure we don't slurp that in, either. Using a :version(...) attribute can give us a clean syntax to allow that:

    use Some::Module :version(3.14..<4,-3.27);

(I'd actually like to use interval notation, such as [3.14,4), but that kinda conflicts with the outer parentheses).

    # use only this version:
    use Some::Module :version(3.14);
    # use this version or higher (equivalent to use Module 3.14;)
    use Some::Module :version(3.14..);

    # use this version or higher, but not the buggy versions
    use Some::Module :version(3.14..,-3.27,-4.1);

There are plenty of other examples I could give, but that's the basics of the idea.

I don't know how feasible this is, given how notoriously painful version numbers are in Perl, but having native support for fine-grained control over what we're loading *in the program* and not in a third-party tool would be awesome.

(It might even be nice to allow :version(...) to skip over modules whose versions don't match the version spec and continue searching @INC, but I suspect that's not feasible)

IT consulting, training, specializing in Perl, databases, and agile development 

Buy my book! -

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About