Passing a proc as block to a method from a C extension

D

Dominik Bathon

Hi,

I am looking for a way to do the equivalent of the following ruby functio=
n =20
in a C extension:

def foo(my_proc)
bar(&my_proc)
end

(and it should also work if bar is instance_eval or module_eval)

I couldn't find a way to do this, the only idea I have is to do something=
=20
like:

def foo(my_proc)
bar { |arg| my_proc.call(arg) }
end

This can be done using rb_iterate, but it obviously doesn't work with =20
instance_eval and module_eval.

Any ideas?

Dominik
 
Y

Yukihiro Matsumoto

HI,

In message "Re: Passing a proc as block to a method from a C extension"

|I am looking for a way to do the equivalent of the following ruby function
|in a C extension:
|
|def foo(my_proc)
| bar(&my_proc)
|end
|
|(and it should also work if bar is instance_eval or module_eval)

Currently there's no good way, since no one has complained loudly
before. Let me think about your request.

matz.
 
D

Dominik Bathon

HI,

In message "Re: Passing a proc as block to a method from a C extension"
on Sun, 19 Feb 2006 03:56:52 +0900, "Dominik Bathon" <[email protected]=
=20
writes:

|I am looking for a way to do the equivalent of the following ruby =20
function
|in a C extension:
|
|def foo(my_proc)
| bar(&my_proc)
|end
|
|(and it should also work if bar is instance_eval or module_eval)

Currently there's no good way, since no one has complained loudly
before. Let me think about your request.

Ok, thanks. That's what I thought.

I would like to have a function like

VALUE rb_iterate_proc(VALUE (*it_proc)(), VALUE data1, VALUE proc);

that would work like block_pass().

Btw. could we also get a version of rb_iter_break that breaks with a valu=
e =20
instead of just nil?


Dominik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top