Leopold Toetsch wrote:

mark sparshatt wrote:

I'd like advice on how to handle method invocations that include special block parameters such as

method() {do something}

The idea is to turn the block into a closure pmc. The problem is how to pass this to the method, so that it knows that it's a special block parameter. Particularly in a way so that a language which doesn't know about blocks can still call Ruby code.


Can't you just compile the code like this:

  new_pad 0
  newsub $clos, .Closure, _do_something
  method($clos)
  ...
.sub _do_something
  new_pad -1
 ...

and pass the closure as additional argument to the method?

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?

--
Mark Sparshatt



Reply via email to