ruby-changes:39825
From: nobu <ko1@a...>
Date: Sun, 20 Sep 2015 10:07:59 +0900 (JST)
Subject: [ruby-changes:39825] nobu:r51906 (trunk): cont.c: append to continuations doc [ci skip]
nobu 2015-09-20 10:07:40 +0900 (Sun, 20 Sep 2015) New Revision: 51906 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51906 Log: cont.c: append to continuations doc [ci skip] * cont.c (rb_callcc): [DOC] append continuations example accros methods. [Fix GH-1026] Modified files: trunk/ChangeLog trunk/cont.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51905) +++ ChangeLog (revision 51906) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Sep 20 10:07:35 2015 Anton Davydov <antondavydov.o@g...> + + * cont.c (rb_callcc): [DOC] append continuations example accros + methods. [Fix GH-1026] + Sun Sep 20 03:20:21 2015 Koichi Sasada <ko1@a...> * iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries. Index: cont.c =================================================================== --- cont.c (revision 51905) +++ cont.c (revision 51906) @@ -893,6 +893,24 @@ cont_restore_0(rb_context_t *cont, VALUE https://github.com/ruby/ruby/blob/trunk/cont.c#L893 * Ron * Max * + * Also you can call callcc in other methods: + * + * require "continuation" + * + * def g + * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] + * cc = callcc { |cc| cc } + * puts arr.shift + * return cc, arr.size + * end + * + * def f + * c, size = g + * c.call(c) if size > 1 + * end + * + * f + * * This (somewhat contrived) example allows the inner loop to abandon * processing early: * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/