what is the ruby C API equivalent of this...

J

jrmair

Hello friends,

I'm having a hard time implementing the equivalent of this in the ruby
C API:

module M
module_function
def run(&block)
module_eval(&block)
end
end


How is the &block operation implemented in the C API? im looking for
something to convert a proc to a
block. i've scanned many of the .c files and have found nothing.
Anyone have any ideas?

cheers

John
 
T

Tim Pease

Hello friends,

Hi!

I'm having a hard time implementing the equivalent of this in the ruby
C API:

module M
module_function
def run(&block)
module_eval(&block)
end
end


How is the &block operation implemented in the C API? im looking for
something to convert a proc to a
block. i've scanned many of the .c files and have found nothing.
Anyone have any ideas?

static VALUE
m_run( VALUE module )
{
if (rb_block_given_p()) {
rb_mod_module_eval(0, 0, module);
}
return Qnil;
}


VALUE module = rb_define_module("M");
rb_define_module_function( module, "run", m_run, 0 );



Blessings,
TwP
 

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,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top