Larry Wall wrote:

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.



That seems to be a reasonable way to handle this. The closure can be passed as a named parameter called something like __ruby_magic_block.

Then the question becomes how are named parameters handled in Parrot/IMC. I've looked at the calling convention docs and couldn't see anything about them.


-- Mark Sparshatt



Reply via email to