From: William Djaja Tjokroaminata Date: 2002-09-05T22:47:41+09:00 Subject: Re: Is It Possible to Create Block from within C? Thanks for the help. So again and again, the key is apparently "rb_iterate()". Am I correct if I assume that we cannot create a "physical" Ruby block in C (something which is of class Proc, which can be "call"-ed)? (Yesterday when I browsed the Ruby classes, there is no such thing as "proc.c", even though Proc is one of the built-in classes. So I assume that Proc and Ruby block are "special", which belong only to the Ruby parser/interpreter, but not accessible via the C API's. Now I see where Joel VanderWerf was going when he answered how to convert a Proc into a block in C.) Regards, Bill ============================================================================ nobu.nokada@softhome.net wrote: >> obj.func() do |arg| >> statements >> end >> > To call a method with block: > static VALUE > statements(VALUE arg, VALUE val) > { > return block_result; > } > static VALUE > call_func(VALUE obj) > { > return rb_funcall(obj, rb_intern("func"), 0); > } > rb_iterate(call_func, obj, statement, 0); > -- > Nobu Nakada