Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I was reading the docs for splice recently and came across this:

Starting with Perl 5.14, splice can take a scalar EXPR, which must hold a reference to an unblessed array. The argument will be dereferenced automatically. This aspect of splice is considered highly experimental. The exact behaviour may change in a future version of Perl.

To avoid confusing would-be users of your code who are running earlier versions of Perl with mysterious syntax errors, put this sort of thing at the top of your file to signal that your code will work only on Perls of a recent vintage:

use 5.014; # so push/pop/etc work on scalars (experimental)

I have to ask, is it really worth breaking backwards compatibility, that is, forcing an upgrade to a newer version of Perl, by adding this "feature"? I have never had a problem using @{$foo} when using splice (or push or pop or anything else expecting an array or list) on an array reference. Yes, the old syntax still works just fine, but if I want to use a module that has the newer syntax I now have to load a newer version of Perl.

I doubt that I will ever use this new syntax unless I am convinced that 99% of the Perl universe will support it. Simply put, if it ain't broke, don't ..., errr, fix it.

Disclaimer: until quite recently I had to work with Perl 5.8.8 the vast majority of the time and only rarely saw 5.10. Consequently I write code to run on 5.8.8 and hope that new modules will load on it. (If you ever need an excuse for a long lunch break install Dist::Zilla on 5.8.8.)


In reply to Is auto-dereferencing worth forcing upgrades to newer versions of Perl? by boftx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-03-28 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found