in reply to Re^5: Perl oddities ("if" w/o parens)
in thread Perl oddities
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.if /^ (f+) / -> *$i { # Do stuff }
Or look at it another way. Suppose you run into a new control construct:
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 seefrob my $x = bar() {...}
then you absolutely know that $x is local because it's explicitly being passed as a parameter.frob bar() -> $x {...}
I think people who initially perceive this as Bad or Ugly will eventually come around to seeing it as Kinda Pretty.
|
---|