Skip to content

Commit 9bc67e1

Browse files
committed
cont.c: append to continuations doc [ci skip]
* cont.c (rb_callcc): [DOC] append continuations example accros methods. [Fix rubyGH-1026] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 6628cd6 commit 9bc67e1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Sun Sep 20 10:07:35 2015 Anton Davydov <antondavydov.o@gmail.com>
2+
3+
* cont.c (rb_callcc): [DOC] append continuations example accros
4+
methods. [Fix GH-1026]
5+
16
Sun Sep 20 03:20:21 2015 Koichi Sasada <ko1@atdot.net>
27

38
* iseq.c (rb_iseq_free): free rb_iseq_t::body::cc_entries.

cont.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,24 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame)
893893
* Ron
894894
* Max
895895
*
896+
* Also you can call callcc in other methods:
897+
*
898+
* require "continuation"
899+
*
900+
* def g
901+
* arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
902+
* cc = callcc { |cc| cc }
903+
* puts arr.shift
904+
* return cc, arr.size
905+
* end
906+
*
907+
* def f
908+
* c, size = g
909+
* c.call(c) if size > 1
910+
* end
911+
*
912+
* f
913+
*
896914
* This (somewhat contrived) example allows the inner loop to abandon
897915
* processing early:
898916
*

0 commit comments

Comments
 (0)