develooper Front page | perl.perl5.porters | Postings from August 2013

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
demerphq
Date:
August 15, 2013 14:30
Subject:
Re: postfix dereference syntax
Message ID:
CANgJU+Uo7fnshY3isSzRPRqxx_3UB5Sf+J_8g+_Pjy_y9T4GXQ@mail.gmail.com
On 15 August 2013 16:22, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
> * Father Chrysostomos <sprout@cpan.org> [2013-08-14T12:03:29]
>> Ricardo Signes wrote:
>> > « $x->@* acts exactly like @$x » is the rule.  "Except in interpolation" would
>> > be the exception.
>>
>> So we allow "$x->@*" and "$$x->@*" and "$x->$*->@*".
>>
>> What about the brace forms?  How far does the equivalance of "@{...}"
>> and "...->@*" hold?
>>
>> "@{$foo}"     --> "$foo->@*"         # 1
>> "@{$foo[0]}"  --> "$foo[0]->@*"      # 2
>> "@{*$foo}" ???                       # 3
>> "@{$foo->**}" --> "$foo->**->@*"     # 4
>> "@{$foo->()}" --> "$foo->()->@*"     # 5
>> "@{$foo++}"   --> "$foo++->@*"       # 6
>> "@{$foo ? bar() : []}" => "$foo ? bar() : []->@*" # 7
>
> We allow ->@* at the end of an expression that we would've allowed up to that
> point.  Of your examples above, which I've taken the liberty of numbering, #1
> and #2 qualify.  Of the rest, none do.
>
> So far, I don't feel like I've seen a real argument that this is complicating
> the language.  From my thready knowledge of the guts here, I also think the
> changes to the internals are pretty minor, but I'm happy to be proved wrong.
>
> That said, I have softened just a little because I got to thinking that what
> we'd really benefit from is a generic "interpolate this expression" syntax,
> which is in Ruby as "foo #{ expr } bar" or the same in Perl 6 without the
> octothorpe.
>
> In Perl 5, of course, we have this in a sense: "foo @{[ expr ]} bar" and "foo
> ${\ expr } bar".  Possibly that's as good as it gets, since such a syntax would
> need to either force one context or have two forms.  And either way, it's
> circumfix.
>
> So: "@{ $foo->[0] }" isn't so bad; generic interpolation form
>
> We lose more simplicity with:
>
>   "@{ $foo }[0,2]"
>   vs.
>   "$foo->@[0,2]"
>
> ...because the idea that "@{...}" is "generic interpolation" no longer holds
> together.

I know you put a lot of effort into this one so I am sorry to say
this, but I am pretty sure we will regret adding this syntax.

I hope I am wrong of course.

cheers,
Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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