aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-20 01:07:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-20 01:07:40 +0000
commit8a80fbf219541533e64129114c8360a3649e8251 (patch)
tree42470ef4bb00ff1fb6ddd7b99d8656ae8d7f9935
parentc65e90a90977a81a0b91d00f9f05c4a53aa7ceb9 (diff)
downloadruby-8a80fbf219541533e64129114c8360a3649e8251.tar.gz
cont.c: append to continuations doc [ci skip]
* cont.c (rb_callcc): [DOC] append continuations example accros methods. [Fix GH-1026] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--cont.c18
2 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e7efff7837..4c436cc287 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Sep 20 10:07:35 2015 Anton Davydov <antondavydov.o@gmail.com>
+
+ * cont.c (rb_callcc): [DOC] append continuations example accros
+ methods. [Fix GH-1026]
+
Sun Sep 20 03:20:21 2015 Koichi Sasada <ko1@atdot.net>
* iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.
diff --git a/cont.c b/cont.c
index 774a026bd5..ba72fd5990 100644
--- a/cont.c
+++ b/cont.c
@@ -893,6 +893,24 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
* 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:
*