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:18
Subject:
Re: [perl #121077] [PATCH] Optimise 'my $x; my $y' into 'my ($x, $y)'
Message ID:
20140129131811.GL27210@iabyn.com
On Tue, Jan 28, 2014 at 04:02:50AM -0000, Father Chrysostomos wrote:
> Dave Mitchell wrote:
> > In that case, the only thing your change would affect is that any warnings
> > that were generated post your change that affected the first 'my' would appear
> > to come from the later 'my'; e.g.
> > 
> >     my $x;  # a warning here appears to come from line 2 rather than line 1
> >     my $y;
> > 
> > but I doubt there are any such warnings.
> 
> $ perl -we 'my $x; my $x; my $y'
> "my" variable $x masks earlier declaration in same scope at -e line 1.

But that warning is generated at compile time, before the peephole
optimiser has run; so the line number will be reported ok.

-- 
Any [programming] language that doesn't occasionally surprise the
novice will pay for it by continually surprising the expert.
   -- Larry Wall

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