develooper Front page | perl.perl5.porters | Postings from January 2014

Re: [perl #121077] [PATCH] Optimise 'my $x; my $y' into 'my ($x, $y)'

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
January 29, 2014 13:11
Subject:
Re: [perl #121077] [PATCH] Optimise 'my $x; my $y' into 'my ($x, $y)'
Message ID:
20140129131125.GK27210@iabyn.com
On Tue, Jan 28, 2014 at 01:55:28AM -0000, Father Chrysostomos wrote:
> Tony Cook wrote:
> > On Mon Jan 27 16:02:45 2014, perl5-porters@perl.org wrote:
> > > What is wrong with that?  It shows how perl understands the code.
> > > Evaluating it produces an op tree that behaves identically.
> > 
> > The padrange optimization which this is built on, does preserve the deparse:
> > 
> > $ ~/perl/blead/bin/perl5.19.8 -MO=Deparse -e 'sub foo { my ($x, $y); my $z; 1 }
> > '
> > sub foo {
> >     my($x, $y);
> >     my $z;
> >     1;
> > }
> > -e syntax OK
> 
> I would consider that adventitious.

(is that a word?)

Yes, the padrange deparsing was based on keeping the old pre-optimisation
tree around because otherwise far too much stuff in Deparse would have
needed fixing up.

I also agree that it doesn't matter that the Deparse output is different
as long its logically equivalent; e.g.

    $ p -MO=Deparse -e'$x && print $y'
    print $y if $x

-- 
In my day, we used to edit the inodes by hand.  With magnets.

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