Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Why version strings?

by ikegami (Pope)
on Mar 28, 2011 at 18:17 UTC ( #895988=note: print w/replies, xml ) Need Help??

in reply to Why version strings?

If I want to use Perl 5.12 as if it were 5.10 then that is the exception to the rule

If that's true, you are an exception. Most people expect scripts written before Perl 5.12 was released to still run using perl 5.12 (for example).

I doubt it's true though. Contrary to what you say, I suspect you're not ok with new versions of Perl breaking your scripts.

if I have Perl 5.12 installed why should I have to specify: use 5.012;

You don't have to specify «use 5.012;». You just have to specify «use 5.012;» if you want backwards incompatible features of version 5.12. This enables the language to change without breaking backwards compatibility.

For example, «use feature qw( say );» (or «use 5.010;» or «use 5.012;») is required to use the say builtin since not requiring it would break the following program:

sub say { print "foo\n" } say();

Replies are listed 'Best First'.
Re^2: Why version strings?
by sundialsvc4 (Abbot) on Mar 28, 2011 at 22:47 UTC

    (Not really a “reply” ... oops.)

    “Quirky” though such a notion may seem to be at first blush, there actually is a reason for it, and it is arguably the best-all-around engineering choice that could have been made.

    use versionstring is a pragma which Perl has supported for a very long time.   Both older and newer Perls will understand it, and the older ones will also know to reject5.012.”   External code which knows how to search a source-file for a use versionstring statement, such as CPAN, also will continue to see what it needs to see ... without needing to be upgraded in order to “do the right thing.”

    If you intend to use a new or redefined feature, then of course you will do whatever it takes to do so.   But that’s really not what this application of use is all about.   The goal of this design is to prevent older Perl installations from running into trouble with newer code ... and to prevent newer interpreter versions from doing the wrong thing with older code.   A barrier mechanism had to be devised, such that it would work correctly whether it was included, or (certainly more likely to be the case...) omitted, and that would be backward-compatible.

      I don't see how this relates to the OP at all. He asked why the new features of a language (e.g. say) weren't on by default. He didn't mention or imply any issue with the use of use version; you describe.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2021-05-10 20:56 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (108 votes). Check out past polls.