in reply to Re^4: Lexical scope vs. postfix loops (perl bug?)
in thread Lexical scope vs. postfix loops (perl bug?)

Yes. I one case the special behaviour is restricted to only declarations, in the other case it would be expanded to arbitrary code. (Or at least one statement of arbitrary code). That's quite a difference, IMHO.

But my opinion doesn't count that much ;-)

Luckily Perl 6 fixes that behaviour by not special casing the scoping at all, and instead introducing blocks with signatures ("pointy blocks", known as lambdas in other programming languages).

# Perl 6 code below: while my $x < 3 { # code here } # $x still visible here for @list -> $y { # $y visible here } # $y not visible here # other uses for lambdas: my $quote = -> Str $s { "'$s'" }