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

Re: postfix dereference syntax

Thread Previous | Thread Next
From:
demerphq
Date:
July 2, 2013 12:51
Subject:
Re: postfix dereference syntax
Message ID:
CANgJU+X1dKnH94NJcdHXSK1bmPp4suyJiPSh3Rzg554eD-aPBw@mail.gmail.com
On 27 June 2013 03:59, Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote:
>
> Perl 5's references are fine, but sometimes dereferencing them is not.  We end
> up switching between postfix and circumfix syntax to dereference structures.
>
>   push @{ $x->{foo}->[0]->m }, $y;
>
> Blech.
>
> In 5.14, an experimental feature was added to avoid this in some contexts:
>
>   push    $x->{foo}->[0]->m  , $y;
>
> In other contexts, it (obviously) can't help:
>
>   push @y, @{ $x->{foo}->[0]->m };
>
>   subroutine( @{ $x->{foo}->[0]->m } )

I'm not convinced this is a problem we should solve (on the other hand
I'm not convinced it is not.)

I would consider this code bug-prone and probably in maintenance mode
rewrite it as:

my $array= $x->{foo}->[0]->m;
push @y, @$array if $array;

Raphael raises similar points.

Yves


--
perl -Mre=debug -e "/just|another|perl|hacker/"

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