From: Paul Prescod Date: 2003-03-24T12:02:08+09:00 Subject: Re: Ruby lecture slides (was Strong advantages over Python) Greg McIntyre wrote: > Jim Weirich wrote: > >>Yes and no. Although they are entirely different things, they both >>are used for do "iteration-like" stuff in their respective languages. >>That and the fact they both use the keyword "yield" (although with >>complete different semantics!) leads people to confuse the two. > > Okay, so what if, instead of saying "This functionality has been added > to Python recently as generators," I said that "This functionality has > been added to Python recently using generators"? I mean. If generators > are a more powerful and general construct, they should be able to do > what Ruby blocks can, plus more. Generators are not a more general construct. They are specific to the problem of constructing an iterator without doing a bunch of state book-keeping. You can't build generators out of blocks and you can't build blocks out of generators. You can build generators out of continuations, though. Paul Prescod