On Thu, Nov 21, 2002 at 11:27:07AM -0600, Me wrote:
: And documenting this by the '->' distinction
: described above (ie -> means private $_ set
: by mumble, no -> means $_ is just the outer
: lexical) would look natural as well being
: logical and strikingly simple.

It would, however, force people to write:

    grep -> { /foo/ } @list;

I'd like to avoid that.  I think {...} can be somewhat context
sensitive.  It's certainly context sensitive in Perl 5, though
we'd like to get away from kludges like the $a/$b thing for sort.
But Perl 5 knows which blocks take a local $_ and which ones don't.
We aren't implementing it by temporizing a global in Perl 6, but we
could still presumably know which blocks work which way.

I think maybe the best way to think of it is to say that every block
always binds its first argument to $_, but there's enough mechanism to
make sure that the binding is to the outer $_ where that's expected,
such as for bare blocks and control structures that don't pass arguments
to their closures.  If that's known at compile time, it can be done
with ordinary lexical scoping of $_, but that's an implementation detail.

Larry

Reply via email to