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

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

Thread Previous | Thread Next
Ricardo Signes
July 29, 2014 21:54
Re: New feature proposal : <<>> to disable magic open of ARGV
Message ID:
* Rafael Garcia-Suarez <> [2014-07-24T11:51:40]
> I believe that this was discussed here some years ago, and that this
> was suggested by TomC. Anyway, I pushed a patch on rgs/nomagicopen.
> The patch is incomplete as it lacks docs and tests. I welcome feedback
> on the intent of the feature.

I'm still not crazy about the one-off syntax addition, but I think that it's
the best we're going to see without setting an unrealistic bar for a new,
generic feature.  If we ever *do* get <> adverbs, we can call this sugar for
one or blah blah blah it doesn't matter that much right now. :-)

While my heart wants -n to be safe, my conscience tells me that we'll break
enough (bizarre, to my mind (except maybe regarding "-")) expectations that it
isn't worth doing.  Probably we want -P and -N for safe opening.

I am gratified to see that <<X>> fails for any X, as you've only made the
literal construct <<>> iterate.  Awesome.  I think we're going to want a better
error message, if possible, though, than:

  ~/code/perl5$ ./perl -e 'while (<<ARGV>>) { print }' 'ls |'
  Can't find string terminator "ARGV" anywhere before EOF at -e line 1.

Something roughly like "safe <<>> operator meaningless on concrete filehandles"
— that's not right, but you get the idea.

I don't think I have any further thoughts on it.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About