AFAIR, I've seen in some Apocalypse that lexical scope boundaries will be the same as boundaries of block, in which lexical variable was defined.
so, my question is, what the scope of variables, defined in C<if> and C<loop> conditions?
in perl5:
my $a="first\n"; if (my $a="second\n") {print $a} print $a;
prints
second first
if I got it right, in perl6 same program will print
second second
or will emit warning about redeclaring variable in the same scope.. sad. In C<if> case it isn't so significant, but what about C<loop>?
cite from Apocalypse4:
...
The continue block changes its name to NEXT and moves inside the block it
modifies, to work like POST blocks. Among other things, this allows NEXT
blocks to refer to lexical variables declared within the loop, provided the
NEXT block is place after them. The generalized loop:
loop (EXPR1; EXPR2; EXPR3) { ... }
can now be defined as equivalent to:
EXPR1;
while EXPR2 {
NEXT { EXPR3 }
...
}
...
so,
loop (my $i=1;$i<10;$i++) { ... }
will declare $i for the rest of the block, in which loop is placed, won't it?
I feel that I will write things like:
{loop (my $i=1;$i<10;$i++) { ... }}
But I really hope that I missed something important, stating that theese curlies are not necessary.