Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Is auto-dereferencing worth forcing upgrades to newer versions of Perl?

by sundialsvc4 (Abbot)
on Aug 15, 2013 at 13:40 UTC ( [id://1049589]=note: print w/replies, xml ) Need Help??


in reply to Is auto-dereferencing worth forcing upgrades to newer versions of Perl?

Definitely “not.”

There are millions of lines of Perl source-code in production service, and maintaining seamless compatibility across upgrades is very important.   Adding a fee-chur for no more reason than saving a programmer a couple of flexes of his fingertips on the keyboard .. when there already exists a way to get this done .. is an unwise thing to do, especially when the change is not “source-code obvious.”   Adding a new, convenient operator is okay because older Perl compilers will instantly reject it with a syntax error, with-or-without strict/warnings.   But adding a fee-chur which changes the meaning of existing source code is, in my opinion, a source of pointless grief.   I see no return-on-investment to warrant the greatly increased business risk.

Still want to do it?   Then introduce a use auto_dereference pragma, which only works on (say ...) 5.014 forward.   (The use 5.014; directive can stay, of course, but now it does not have “hidden meaning” that only a perlguts person would be expected to know.)   Now you are declaring, both to Perl and to the future programmers, what you mean.   Importantly, you are now doing it in a way that will generate syntax-errors in older Perls.   (You also presumably can now “bracket” specific sections of code with use/no blocks.)   The programmer gets a “heads up!!” alert to be on the lookout for “specifically, this New Thing,” and older compilers will fall on their face, flagging that particular line of source with its immediately-obvious import as their nose hits the pavement.

Replies are listed 'Best First'.
Re^2: Is auto-dereferencing worth forcing upgrades to newer versions of Perl?
by tobyink (Canon) on Aug 15, 2013 at 13:53 UTC

    I'm pretty sure that strict-or-not, you'll get a compile-time syntax error if you try this on Perls earlier than 5.14. You'd have quite a struggle to find existing Perl code that this change broke.

    I don't think it's a good feature, but it's a freeture, not a feeture.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 11:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found