# What is the ruby C API equivalent of this

**URL:** <https://www.ruby-forum.com/t/what-is-the-ruby-c-api-equivalent-of-this/145441>\
**Category:** Ruby\
**Created:** [August 9, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/what-is-the-ruby-c-api-equivalent-of-this/145441 "2008-08-09T13:45:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 9, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/what-is-the-ruby-c-api-equivalent-of-this/145441/1 "2008-08-09T13:45:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 9, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/what-is-the-ruby-c-api-equivalent-of-this/145441/2 "2008-08-09T16:56:32Z")

</div>

On Aug 9, 2008, at 5:43 AM, removed\_email\_address@domain.invalid wrote:

> Hello friends,

Hi!

> 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
