On Sat, Mar 05, 2005 at 12:04:16AM +0800, Autrijus Tang wrote: : The double evaluation bug has been fixed today. It was result of a : misunderstanding of the role of $_ when the subroutine body does : not mention $_, but makes use of slurpy arrays (as is the default with : @*_), and has no invocants when actually used; in that case $_ is : probably best undefined (or bound to the first non-invocant argument? : Can we get a ruling?);
For a real "sub", it should probably default to undefined. It's when we start dealing with internal blocks that we start having to play games with defaulting to the outer scope's $_. Pointy subs are a gray area, but the consensus seems to be that they should always topicalize their first argument (again defaulting to the outer $_ if no actual argument is passed). So they fall more into the block category than the sub category. I'm not sure what distinction you're making when you talk about a sub that "has no invocants when actually used". Unless a sub is declared "multi" or "method", it never really has any invocants, and if it's a multi or a method, it always does. Or is this some fudging based on the fact that we're trying to blur the distinction between multis and ordinary methods for single invocants? In any case, something declared with a non-multi "sub" should act very close to what Perl 5 does with an ordinary sub declaration. (Except for the fact that we're forcing $_ to be lexical, and parameters are no longer rw by default, and we can now have lexically scoped subs that hide more global subs, and probably several other things I'm forgetting...) Anyway, some code examples might help to keep me from rambling on here about things you already probably know... :-) Larry