>>>>> "W" == Wai-Sun Chia <waisun.chia / compaq.com> writes: W> Perhaps you can share some sample code to emulate a simple Ruby iterator W> in 'C'?? pigeon% cat tt.c #include <ruby.h> static VALUE tt_i_tt(res, opt) VALUE res, opt; { VALUE str = rb_inspect(res); rb_warn("received <%d> %s", NUM2INT(opt), STR2CSTR(str)); return Qnil; } static VALUE tt_tt(obj) VALUE obj; { return rb_iterate(rb_each, obj, tt_i_tt, INT2FIX(12)); } void Init_tt() { rb_define_method(rb_cArray, "tt", tt_tt, 0); } pigeon% pigeon% ruby -rtt -e '[1, 2, "abc", [1, 2, "a"]].tt' -e:1: warning: received <12> 1 -e:1: warning: received <12> 2 -e:1: warning: received <12> "abc" -e:1: warning: received <12> [1, 2, "a"] pigeon% You can still write for (i = 0; i < RARRAY(ary)->len; i++) { call_your_function(RARRAY(ary)->ptr[i]); } Guy Decoux