Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Why version strings? (uh, no)

by tye (Sage)
on Mar 29, 2011 at 05:33 UTC ( [id://896090]=note: print w/replies, xml ) Need Help??


in reply to Re: Why version strings?
in thread Why version strings?

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        

Replies are listed 'Best First'.
Re^3: Why version strings?
by chromatic (Archbishop) on Mar 29, 2011 at 16:52 UTC
    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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://896090]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2024-04-19 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found