Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Why version strings?

by chromatic (Archbishop)
on Mar 28, 2011 at 16:54 UTC ( #895971=note: print w/replies, xml ) Need Help??


in reply to Why version strings?

I've heard the argument that it allows you to switch off features introduced in the latest version but shouldn't it be done the other way round, ie. specify if you want limitations, not to enable what is available by default?

Perl should work that way, but Perl hasn't worked that way in any version of 1 through 5, and so you have a choice to make. Make that change arbitrarily with Perl 5.16 next year and for everyone running code written for earlier versions to edit that code to run on Perl 5.16, or do it the current way and ease upgrading worries.

(Even so, it's still a good idea to specify the version number of the Perl language against which you've written any program, no matter what Perl 5's behavior regarding default behaviors.)

Replies are listed 'Best First'.
Re^2: Why version strings? (uh, no)
by tye (Sage) on Mar 29, 2011 at 05:33 UTC
    Even so, it's still a good idea to specify the version number of the Perl language against which you've written any program

    That's a nice theory. And it sounds so reasonable.

    It is too bad that the feature isn't actually implemented in a reasonable way for that use case. There is no "I wrote this on 5.10.1 so I can't be sure it will work on other versions" feature. There is only the "I'm damn sure that this will never, ever work on 5.10.0 or before and so any prior version will just tell you 'tough shit' with no real explanation" feature.

    Since the 'require/use VERSION' feature has become increasingly misused, it would be nice if that feature became pluggable so, for example, an automated smoke test of 5.8.9 could arrange for "require 5.010.001;" (for example) in a module to be non-fatal in a deterministic way so that the module could actually be tested on 5.8.9 and the test results would actually record either "no, this actually works on 5.8.9; shame on the module author" or "one reason this doesn't work on 5.8.9 is that it uses //".

    It is quite unfortunate that 'use VERSION' doesn't even allow the author to include a reason.

    use 5.010 'uses //'; Perl v5.10.0 required (uses //) -- this is only v5.12.1, stopped. # No, this doesn't actually work.

    Much better to just roll your own reasonable implementation

    BEGIN { die "// not implemented in Perl $]\n" if $] < 5.010 }

    Or even avoid the silly version number BS altogether:

    BEGIN { die "// not implemented in Perl $]\n" if ! eval "undef() // 1" + }

    Well, at least for cases where the existing diagnostic is worse (like this one):

    perl5.8 -e'my $x= undef() // 1;' Search pattern not terminated ...

    Or, for chromatic, it would be:

    use v5.14 "Your Perl is old. Please don't waste my time. Go away until + you upgrade.";

    ...except that hard-coding v5.14 probably seems unfortunate to him. :)

    - tye        

      There is no "I wrote this on 5.10.1 so I can't be sure it will work on other versions" feature.

      Yet.

      There can only be such a feature if sufficient numbers of Perl 5 programmers stop pretending that perl is completely forward and backwards compatible without explicitly including version numbers in all files.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://895971]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2021-05-14 02:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (147 votes). Check out past polls.

    Notices?