On Fri, Aug 13, 2004 at 02:12:06PM +0100, mark sparshatt wrote:
: My main worry with this approach is how it would interact with slurpy 
: args. I mean if method is defined as
: 
: def method(*args)
: ...
: end
: 
: how do I make sure that $clos doesn't become part of args?

In Perl 6 circles we've been considering that a signature declaration
could have a "slurpy function" as well as slurpy arrays and hashes.
The magic block would actually be processed as a named argument with
an implicit name, so there's no problem with where to pass it in the
positional arguments.  This maps pretty well onto Ruby's magic blocks
(and admittedly was inspired by it), though Perl will have different
syntactic rules about how to pass one, of course, because we're
generalizing the concept somewhat.  In particuler, one way to pass
a magic block is as an anonymous adverb: C<< :{...} >>.  I suspect
it can also be passed as the final element on the slurpy list,
from which it could be removed at either compile time or call time.
Or it could be passed as an explicitly named parameter.  That's
what I mean by generalizing Ruby's concept--there's no "magic" syntax
for blocks--it's just another named parameter, where the name can
sometimes be omitted on the call.  It's always declared with a name
on the receiving end, and there's no magic "yield" on an implicit
closure.  Just call the named closure.

[I've cc'd p6l, so please send replies to the appropriate list.]

Larry

Reply via email to