From: Ryan Davis Date: 2006-04-15T03:02:55+09:00 Subject: Re: Calling instance_eval on a block in C On Apr 14, 2006, at 10:33 AM, John Lam wrote: > If I have this ruby method: > > def eval_it(obj, &b) > obj.instance_eval(&b) > end > > How do write the C code to make this happen? If I do this: > > rb_funcall(obj, rb_intern("instance_eval"), 1, zz); > > Ruby is apparently expecting a String for the type of zz. Hey John, I'm not positive, but I don't think it is possible, because of the block. Blocks come in through manipulated ruby_frames, even if they look like they are passed in via shells. Clues being: static VALUE rb_f_block_given_p() { if (ruby_frame->prev && ruby_frame->prev->iter == ITER_CUR && ruby_block) return Qtrue; return Qfalse; } and the first hunk of specific_eval reading: if (rb_block_given_p()) { if (argc > 0) { rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc\ ); } return yield_under(klass, self); }