develooper Front page | perl.perl5.porters | Postings from December 2010

Re: [perl #80306] Quoting behaviour of => is too generous

Thread Previous
From:
Abigail
Date:
December 6, 2010 08:42
Subject:
Re: [perl #80306] Quoting behaviour of => is too generous
Message ID:
20101206164312.GI7659@almanda
On Mon, Dec 06, 2010 at 04:32:41PM +0000, Ed Avis wrote:
> Abigail <abigail <at> abigail.be> writes:
> 
> >>  $ perl -MO=Deparse -wce 'my %h = ("-aa" => 1)'
> 
> >I don't know what your point with this example is.
> 
> Sorry - stupidity on my part.  Of course it is already quoted.
> 
> >>It's a bit odd for the quoting behaviour to differ like this - or at least, I
> >>would expect that if => has the effect of quoting its LHS, then it should also
> >>bind to it a bit more tightly.
> >
> >Sorry, no idea what you mean here.
> 
> I might expect
> 
>    12 -aa => 1
> 
> to be equivalent to
> 
>    12 - (aa => 1)


That still isn't a syntax error; it's just a silly way of writing '11'.
It would also mean that:

    %h = (3 + $foo => 7);

is another way of writing:

    %h = (10, undef);


I don't think we should have had => bind more tightly than binary
arithmetic operators. And I certainly don't think we should change this.


> So that if => is quoting just the 'aa' part, and not '-aa', then it should
> also bind to just the 'aa' part.  On the other hand, if - binds more tightly than
> =>, then => should not have any special quoting effect because its LHS is not
> a plain string but the seeming expression (12 - aa).



Abigail

Thread Previous


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