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

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
David Golden
Date:
July 3, 2013 15:03
Subject:
Re: postfix dereference syntax
Message ID:
CAOeq1c86X12vwgj18UxxJv8D2013Z4VNSJRnLWAjsamriQNpmQ@mail.gmail.com
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