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

Re: postfix dereference syntax

Thread Previous | Thread Next
Dave Mitchell
July 3, 2013 14:23
Re: postfix dereference syntax
Message ID:
On Wed, Jun 26, 2013 at 09:59:02PM -0400, Ricardo Signes wrote:
>   push @y, $x->{foo}->[0]->m->@*;

> If we want the two forms to be really of equivalent value, we'll also need to
> be concerned with:
>   print "Things: $aref_of_things->@*"
> ...which gets into less clearly-introduceable behavior.

Alternatively, what about instead of expr->@*, we use


This is currently a syntax error. It has the mnemonic of a list slice
that contains all elements. Ditto expr->{}.

It's also currently a syntax error in quoted strings, so can easily be used
there too:

    print "$a->{}bar"

It could conceivably be expanded to indicate slicing, such as


*except* that this is currently valid syntax, where the list of indices is 
evaluated in scalar context, which discards all but the last element. So
the above is currently equivalent to


Potentially we could deprecate the current behaviour, then (if it turns
out not to be commonly used), repurpose it. This would also allow slices
in strings, e.g. "$a->[1,5,7]", which also currently evaluates to

I thought I was wrong once, but I was mistaken.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About