From: nobu.nokada@... Date: 2002-09-05T09:14:25+09:00 Subject: Re: Is It Possible to Create Block from within C? Hi, At Thu, 5 Sep 2002 03:24:57 +0900, William Djaja Tjokroaminata wrote: > I have the following Ruby code: > > obj.func() do |arg| > statements > end > > How can I translate this into the corresponding C code? Basically the > function func() takes a block and it has been written in C without any > problem and it already works with Ruby scripts. Is it simply > impossible to create a Ruby block from within C, just as it is impossible > to get function pointers of the Ruby methods (as they are stored as > nodes)? 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