From: Mikkel Bruun Date: 2001-10-17T23:42:36+09:00 Subject: [ruby-talk:22674] SV: Re: blocks in C??? (and hi guys) Thanks a lot... However, being a c newbie i dont really understand the syntax of this specific API call... So here is how I see it, i want to perform the following urby code obj.method(parm1){ |retval1| dostuff(retval1) } using the specified API call I would have to pull the block out, making a function with the following signature: block(reval1) so now that I have identified the two funcs specified in the API call., my call would be like below rb_iterate(method(), parm1, dostuff(), 0) or??? it doesnt look right, and my C skills is not adequate... could someone please show me how to translate the ruby code into c??? thanks in advance Mikkel Bruun > -----Oprindelig meddelelse----- > Fra: ts [mailto:decoux@moulon.inra.fr] > Sendt: 17 October 2001 14:59 > Til: ruby-talk@ruby-lang.org > Cc: ruby-talk@ruby-lang.org > Emne: [ruby-talk:22671] Re: blocks in C??? (and hi guys) > > > >>>>> "M" == Mikkel Bruun writes: > > M> im writing a c extension to ruby, and I have to call a > method defined in a > M> ruby class. however, the method needs to be passed a block... > > M> How do i pass a block i c??? > > rb_iterate(), you have in README.EXT > > VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE > (*func2)(), void *arg2) > > Calls the function func1, supplying func2 as the block. > func1 will be > called with the argument arg1. func2 receives the value > from yield as > the first argument, arg2 as the second argument. > > > > Guy Decoux >