Mark J. Reed wrote:
> <exegesis4> > # Perl 5 code > for (my $i=0; 1; $i++) { > > which would translate into Perl 6 as: > > > loop (my $i=0; 1; $i++) { > </exegesis4> > > May I infer from this the return of loop-scoped variables (in > which the loop control variable is magically inserted into the > loop block's lexical scope, even though it's declared outside of > the latter's curlies)? No, you may not. ;-) Larry has said very clearly that in Perl 6 there are no "magical" lexical scopes. That is, variables declared in a C<loop> control aren't magically in the following block. > If not, then putting the 'my' inside the parens is a > tad misleading . . . Only to existing Perl programmers. To everyone else, the fact that it's declared outside the block makes it perfectly obvious that it's scoped outside the block. I should point out that I used the parens there merely to comfort existing Perl 5 programmers. The idiomatic Perl 6 usage would be: loop my $i=0; 1; $i++ { (i.e. no redundant parens), in which case it's fairly clear that the variable is scoped outside the block. BTW, apart from consistency, one of the main reasons we changed the scoping behaviour of C<loop> was that the new behaviour is much more intuitive. At least, if one judges by the dashed expectations of newcomers, who are always surprised in Perl 5 when $i *isn't* defined after the loop ends. Damian