develooper Front page | perl.perl5.porters | Postings from July 2014

Re: New feature proposal : <<>> to disable magic open of ARGV

Thread Previous | Thread Next
From:
Ricardo Signes
Date:
July 27, 2014 22:10
Subject:
Re: New feature proposal : <<>> to disable magic open of ARGV
Message ID:
20140727221020.GA3808@cancer.codesimply.com
* Abigail <abigail@abigail.be> [2014-07-27T14:19:44]
> Imagine:
> 
>     use 5.022;   # Enables turning off magic-open.
>     ...
>     while (<>) {
>         ...
>     }
> 
> Time passes, and the code gets run [1] on 5.20. It dies with a version 
> error. Someone removes the 'use 5.022' (what, you've never done that?
> I have), and lo, it works. Well, with the safety off.

Yeah, this is precisely what I've been frowning at all day.  I'm still not a
huge fan of <<>>, but I think in the end, it will be better than features.  I'm
not decided either way, I'm flip-flopping around, but I've always been pretty
unhappy about invisible changes being introduced by features (because then you
can't get rid of the feature, ever, for one thing!), and I think this is
probably another place where it would be a problem.

What I *didn't* say originally was that this would be a great place for adverbs
in the Perl 6 style.  I'd hardly say that we should not merge <<>> just because
adverbs would be better, but it would be a *resuable* and *multi-purpose*
extension of syntax.  For example:

  while (<>:nomagic) {
    ...
  }

So maybe this message is a formal notice of "this would be useful here," so
that I remember it in the future in other cases, like <>:chomp and whatever
else comes to mind.

-- 
rjbs

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About