From: Rahul Kumar Date: 2011-05-19T00:50:07+09:00 Subject: Re: Making fibers enumerable --0016e65aeac692573f04a38ed775 Content-Type: text/plain; charset=UTF-8 On Wed, May 18, 2011 at 4:42 PM, Robert Klemme wrote: > > > If I understand correctly, writing generators was one of the purposes of > > fibers. Why can't fibers be made enumerable by default? > > I am not sure how that interacts with the original intent of Fibers: > their main purpose is to bring coroutines to Ruby. > > http://en.wikipedia.org/wiki/Coroutines Right. But aren't semi co-routines(don't send data; just receive) used to implement generators? > http://www.ruby-doc.org/core/classes/Enumerator.html#M000299 > > fib_gen = Enumerator.new { |y| > a = b = 1 > loop { > y << a > a, b = b, a + b > } > } > > Oh, didn't know about this - somehow "The Ruby Programming Language" doesn't mention it or I missed it. I simply translated my Python code to Ruby. Thanks for the info Robert. --0016e65aeac692573f04a38ed775--