The scoping rules are much simpler now. And because blocks are closures, you can pass parameters to them, which are
scoped to the block. So you could write your statement like this:
if /^ (f+) / -> *$i {
# Do stuff
}
where the * on the parameter list treats the pattern match result as binding to a list value, so the search result
acts like a list value and binds $1 to $i. And arguably it's more readable because it puts the first thing that happens, the pattern match, out front. The parameter binding only happens if the pattern match succeeds.
Or look at it another way. Suppose you run into a new control construct:
frob my $x = bar() {...}
Tell me quick whether $x is local to that block? In the Perl 5 world, you don't know for sure, because the scoping rules are arbitrary, and change between builtins and user-defined control verbs. In the Perl 6 world you know it isn't local, because the my isn't inside the block. Period. On the
other hand, if you see
frob bar() -> $x {...}
then you absolutely know that $x is local because it's explicitly being passed as a parameter.
I think people who initially perceive this as Bad or Ugly will eventually come around to seeing it as Kinda Pretty. | [reply] [Watch: Dir/Any] [d/l] [select] |