[Melbourne-pm] Closures and scope warnings

Alfie John alfiejohn at gmail.com
Tue Jul 27 21:40:56 PDT 2010


On Wed, Jul 28, 2010 at 2:19 PM, Damian Conway <damian at conway.org> wrote:

> Scott asked:
>
> > So... the rule is that warnings only happen within the same level of
> block?
>
> Yes. The second declaration of a variable name at a given block level
> generates
> a warning. Two declarations in different blocks never has (and never will).
>

It's funny because 'my' will warn, but 'local' is fine:

  perl -we 'use strict;our $f = 10; {my $f = 20; my $f = 30; print $f,"\n"}
print $f,"\n"';
  perl -we 'use strict;our $f = 10; {local $f = 20; local $f = 30; print
$f,"\n"} print $f,"\n"';

The fact that 'local' doesn't warn makes it seem inconsistent to me. But it
could be just the way how I think 'local' works ;p

Alfie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20100728/88987ac5/attachment.html>


More information about the Melbourne-pm mailing list