[](...)
public
Invokes the continuation. The program continues from the end of the
callcc block. If no arguments are given, the original
callcc returns nil. If one argument is given,
callcc returns it. Otherwise, an array containing args is
returned.
callcc {|cont| cont.call }
callcc {|cont| cont.call 1 }
callcc {|cont| cont.call 1, 2, 3 }
Show source
/*
* call-seq:
* cont.call(args, ...)
* cont[args, ...]
*
* Invokes the continuation. The program continues from the end of the
* <code>callcc</code> block. If no arguments are given, the original
* <code>callcc</code> returns <code>nil</code>. If one argument is
* given, <code>callcc</code> returns it. Otherwise, an array
* containing <i>args</i> is returned.
*
* callcc {|cont| cont.call }
* callcc {|cont| cont.call 1 }
* callcc {|cont| cont.call 1, 2, 3 }
*/
static VALUE
rb_cont_call(argc, argv, cont)
int argc;
VALUE *argv;
VALUE cont;
{
rb_thread_t th = rb_thread_check(cont);
if (th->thread != curr_thread->thread) {
rb_raise(rb_eRuntimeError, "continuation called across threads");
}
if (th->thgroup != cont_protect) {
rb_raise(rb_eRuntimeError, "continuation called across trap");
}
switch (argc) {
case 0:
th->result = Qnil;
break;
case 1:
th->result = argv[0];
break;
default:
th->result = rb_ary_new4(argc, argv);
break;
}
rb_thread_restore_context(th, RESTORE_NORMAL);
return Qnil;
}