From: David Flanagan Date: 2007-08-23T05:55:50+09:00 Subject: Re: coroutines with Fiber::Core SASADA Koichi wrote: > Hi, > > David Flanagan wrote: >> f.transfer(100) > > Fiber::Core and Fiber::Core#transfer is black magic. So I'm > planning to rename this class and method to > Fiber::DangerousCore::__unsafe_transfer__I_cant_promise_your_program_run_correctly__! I like that method name! :-) Why expose Fiber::Core if it is so dangerous? Are there scenarios where it can be used safely? > > These method names (resume/yield) are from Lua. "transfer" is from > Modula-2. "double resume error" is from Python's generator. Thanks. These were enough hints for me to figure it out. Here's the Fibonnaci sequence: fib = Fiber.new do x, y = 0, 1 loop do Fiber.yield y x,y = y,x+y end end 20.times { puts fib.resume } > BTW, I'm thinking about name "Fiber". Current Fiber means > Semi-Coroutine. Fiber::Core is Coroutine. Yes, name of Fiber is > from Microsoft, but it's means Semi-Coroutine such as Lua's > coroutine and Python's generator. How about just calling it a Coroutine? Lua uses coroutine even though it is not a full coroutine. I'd be more concerned about the method name yield: Fiber.yield is superficially similar, but deeply different from a regular ruby yield, and I think this could cause confusion. How about using Fiber.return or even Fiber.coreturn? David