# Passing proc objects to ruby extensions

**URL:** <https://www.ruby-forum.com/t/passing-proc-objects-to-ruby-extensions/105176>\
**Category:** Ruby\
**Created:** [May 26, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/passing-proc-objects-to-ruby-extensions/105176 "2007-05-26T19:04:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stutrail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@stutrail](https://www.ruby-forum.com/u/stutrail)\
**Post date:** [May 26, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/passing-proc-objects-to-ruby-extensions/105176/1 "2007-05-26T19:04:24Z")

</div>

Hi list! Its a been a while since I was around here, but I remember it  
being the place to ask these sorts of questions, especially since Yarv  
has now merged into real Ruby.

How does a proc object get passed when writing a ruby extension in c?  
ie

**Ruby**  
a = Proc.new{|z| z\*2}  
f(a)

**C**  
void f(VALUE a){  
switch(TYPE(a)){  
…  
}  
}

None of the usual types match. What is ‘a’ here? There doesn’t seem to  
be a struct for Procs in ruby.h. Might it be a pointer to the iseq  
struct? 🙂

(FTR, I’m mesing around with what is now quite an old build -  
yarv-0.4.1, I’m hoping it hasn’t changed much since the merge?)

warm regards,  
stu

---

<div class="post-metadata">

**Author:** ![stutrail](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/22d042/32.png) [@stutrail](https://www.ruby-forum.com/u/stutrail)\
**Post date:** [May 27, 2007, 8:36am UTC](https://www.ruby-forum.com/t/passing-proc-objects-to-ruby-extensions/105176/2 "2007-05-27T08:36:30Z")

</div>

Hi,

At Sun, 27 May 2007 02:04:24 +0900,  
Stuart Trail wrote in [ruby-talk:253118]:

> How does a proc object get passed when writing a ruby extension in c?

> None of the usual types match. What is ‘a’ here? There doesn’t seem to  
> be a struct for Procs in ruby.h. Might it be a pointer to the iseq  
> struct? 🙂

T\_DATA.

See rb\_obj\_is\_proc() in proc.c.
