From: eregontp@... Date: 2017-05-14T10:25:13+00:00 Subject: [ruby-core:81153] [Ruby trunk Feature#10548] remove callcc (Callcc is now going obsoleted. Please use Fiber.) Issue #10548 has been updated by Eregon (Benoit Daloze). jphelps (Jeremy Phelps) wrote: > Eregon, I have no idea what you're talking about. All the examples of Fiber usage over on ruby-doc.org shows identical behavior to Python's yield statement. The only difference is that in Python, "resume" is spelled "next", and you can iterate over the sequence of return values (just a monkey patch away with Fibers). Oh, and the way Python handles a dead generator is different (you start getting void instead of an exception). Then look for other examples than just the ones in the documentation. The fact that Fibers have a stack means Fiber.yield can be called anywhere during the Fiber execution, including in deeply nested method calls, while Python and JavaScript generators are lexically bound and restricted to only call "yield" in the generator function and not deeper. Try to reproduce this in Python: ~~~ ruby def powers_of(x, max) n = x while n < max Fiber.yield(n) n *= x end end def powers_of_range(range, max) range.each { |x| powers_of(x, max) } end f = Fiber.new do powers_of_range(2..4, 100) raise StopIteration end loop { p f.resume } ~~~ It's possible, but you either have to manually inline the two methods, or use multiple generators instead of just one Fiber here. For a more interesting usage of Fiber see https://www.igvita.com/2010/03/22/untangling-evented-code-with-ruby-fibers/ for example. ---------------------------------------- Feature #10548: remove callcc (Callcc is now going obsoleted. Please use Fiber.) https://bugs.ruby-lang.org/issues/10548#change-64805 * Author: tarui (Masaya Tarui) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- We are paying a lot of costs for callcc's consistency. and currently, we can use Fiber in many situation. In https://bugs.ruby-lang.org/projects/ruby/wiki/DevelopersMeeting20140517Japan, matz agreed to remove callcc. If there is no refutation, remove callcc in the future version. -- https://bugs.ruby-lang.org/ Unsubscribe: