> [perhaps] > : bare blocks (even those passed as args) just > : pick up from the surrounding lexical context.
This is definitely a significant simplification. Is it a problem? > Yes, that's the problem. A bare block would > have to notice at run time that it was called > with unexpected arguments and unbind its > binding to the outer $_. That would be ughly, but I don't understand why you say it must necessarily be so. > : What does this mean: > : > : $_ = 1; mumble -> { $_ = 2 }; print; > : > : perhaps the '->' could imply that $_ /is/ > : going to be private to the block somehow? > > As it stands now, explicitly telling it there > are no arguments would have exactly the opposite > effect, and bind $_ to the outer $_. Oh. I had the vague notion that (inline) bare blocks don't do anything special beyond establishing a nested lexical scope: $_ = 1; { $_ = 2 }; print; # 2 whereas '->' means the topic gets set and is private to the block (ignoring aliasing effects): $_ = 1; for @foo -> $_ { $_ = 2 }; print; # 1 It seems to me that a logical conclusion would be that a blank arg list after a '->' would mean the topic remains private (and is set to undef). Perhaps having bare blocks work the same simple way whether or not they appear as an arg, and have -> behave the same simple way whether or not it is used with, say, a for, or as a sub def, introduces problems or lost opportunities elsewhere that nix the whole idea. But wait... > I think C<mumble> has to be able to wrap its own > idea of $_ around the block at compile time somehow. Perhaps. But presumably you agree that it would be nice if the calling syntax naturally made it clear how $_ was being bound. 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. > Perhaps we need to distinguish the type of > a "thunk" from a "sub" in the signature of > C<mumble>. This would not be necessary with the scenario I describe above. -- ralph