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

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
Mark Allen
Date:
July 3, 2013 15:13
Subject:
Re: postfix dereference syntax
Message ID:
1372864407.32103.YahooMailNeo@web164001.mail.gq1.yahoo.com
+1 from the peanut gallery, for whatever that's worth.


________________________________
 From: David Golden <xdg@xdg.me>
To: Dave Mitchell <davem@iabyn.com> 
Cc: Ricardo Signes <perl.p5p@rjbs.manxome.org>; p5p <perl5-porters@perl.org> 
Sent: Wednesday, July 3, 2013 10:02 AM
Subject: Re: postfix dereference syntax
 

On Wed, Jul 3, 2013 at 10:23 AM, Dave Mitchell <davem@iabyn.com> wrote:
>     expr->[]
>     $a->[1,5,7]

This is even more attractive to me when considered together with
normal element access:

    $array->[]; # dereference
    $array->[$i]; # single element
    $array->[@list]; # array slice

    $hash->{}; # dereference
    $hash->{$n}; # single element
    $hash->{@list}; # hash slice

It bugs me slightly that [] and {} look "empty" when in fact they
return everything, but I like the parallelism more than I fear that
visual confusion.  That table above is easy to teach and easy to
remember.

Would we allow whitespace between [] and {}?  Or would we treat them
like a type of operator and insist that they be without a space?

David

--
David Golden <xdg@xdg.me>
Take back your inbox! → http://www.bunchmail.com/
Twitter/IRC: @xdg
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