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

Re: defererencing arrayref/hashref expressions

Thread Previous | Thread Next
From:
Chas. Owens
Date:
September 4, 2010 16:55
Subject:
Re: defererencing arrayref/hashref expressions
Message ID:
AANLkTinSEeWoP4VpuyGfh1rN=-n6S1EekGv3c=K5xWie@mail.gmail.com
On Fri, Aug 27, 2010 at 09:49, Dr.Ruud <rvtol+usenet@isolution.nl> wrote:
> I sent this before on 2010-08-25 20:58 +0200
> but didn't see it show up, so am sending it
> again.
>
> On 2010-08-25 16:18, David Golden wrote:
>
>> In casual conversation at conventions about "what still annoys you
>> about perl" -- and even in this thread -- many people cite their
>> annoyance with writing @{ ... } or %{ ... } over and over again.
>
> You could see that as a precedence issue.
>
> Writing
>
>  @$foo->{ bar }
>
> when you meant
>
>  @{ $foo->{ bar } }
>
> makes you long for a low precedence variant of the @.
>
> It could maybe look like
>
>   @:$foo->{ bar }
>
> --
> Ruud
>

Twigil derefrencing?  Why not?  It should have a higher precedence
than ++ and -- but a lower precedence than ->.  Hmmm, but : is used
for package name separation and accessing the package hash; the
difference between %: and %:: isn't large enough.  We should also
avoid any of the twigils being used by Perl 6 to avoid confusion
there; so that rules out . ! ^ : * ? = < and ~.  It can't be $, @, %,
&, or #.  It also shouldn't be , or ;.  That leaves _, -, and +.

How do these look?

print @{$ref->{a}{b}}, "\n"
print @_$ref->{a}{b},  "\n";
print @-$ref->{a}{b},  "\n";
print @+$ref->{a}{b},  "\n";

I am leaning toward - because you don't have to hit shift to get it.
It is also similar to, but distinct from ->.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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