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:
Rafael Garcia-Suarez
Date:
July 24, 2014 20:20
Subject:
Re: New feature proposal : <<>> to disable magic open of ARGV
Message ID:
CAMoYMM_kt6ay4d_p9ydWA6rPESncrKVuaNtfTuVR7Ko9Rfvz+A@mail.gmail.com
On 24 July 2014 22:15, Abigail <abigail@abigail.be> wrote:
> On Fri, Jul 25, 2014 at 07:27:34AM +1200, Kent Fredric wrote:
>> On 25 July 2014 05:13, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>>
>> > I like the feature, but I think it might be too small a change to pick up
>> > a new
>> > operator.  What about a pragma/feature?
>> >
>>
>> +1 on pragma/featurizing it.
>>
>> I'm half of the mind that <> allowing pipe opens constitutes a kind of bug
>> in itself.
>>
>> So a lexical pragma that turns on/off that behavior seems more sensible
>> than new syntax, and once we do that, we can discuss whether or not the
>> pragma should default on/off somehow in a future perl.
>
>
> -1 here.
>
> People don't like magic open because you can't see what you're getting.
>
> Disabling this with a feature means, you're disabling it with something
> you don't see.
>
>
>    while (<>) {
>        ...  # Magic open or not?
>    }

Ah, yes, I meant to mention that as well.

> Whether or not it's a magic open is something you can't see locally.
> You'd have to scroll the file to see whether a feature is active or not.
>
>    while (<<>>) {
>        ... # Obvious
>    }
>
>
>
> Note 1: I'm well aware this is not something specific about <>/<<>>, but
>         that it's general uneasyness I have with features (or pragmas)
>         controlling behaviour. It's often too much "action in a distance"
>         for my liking. (Pragmas also means that whenever you explain something
>         about a construct, you always have to put a disclaimer there about
>         the pragmas affecting the construct -- it doesn't make it easier
>         to learn or teach the language).
>
> Note 2: Having said that, to eliminate the magicness of open(), we got
>         3-arg open(), instead of controlling it with a pragma.

But then you miss the magicness of the ARGV filehandle.

> Note 3: (To ease the feeling of the pumpkin): Instead of seeing '<<>>' as
>         a new operator, just see it as the '<>' operator with a special
>         cased operand.
>
>
> Abigail

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