brendan at mozilla.org
Sun Mar 30 12:08:39 PDT 2008
On Mar 30, 2008, at 10:58 AM, Jason Orendorff wrote:
> On Fri, Mar 28, 2008 at 10:32 PM, Brendan Eich
> <brendan at mozilla.org> wrote:
>> This is a long-ish case for including generators in ES4 as proposed.
> Here's a brief case: generators let you factor a complex loop,
> dividing the value-producing part from the value-consuming part.
> Neither part has to be transformed in a non-obvious way. With
> iterators alone, you do this by rewriting the value-producing part as
> an Iterator class. This obfuscates the iterator implementation.
Thanks, this is nice and short. I wanted to give example links and
excerpts for those new to generators, but what you wrote here is a
great summary and intro.
BTW, no single nominal Iterator class or interface is required, of
course -- all you need is an object 'like IteratorType'.
> It's hardly news that abstracting from sequences is useful. Various
> languages have had iterators, streams, and lazy lists as core,
> essential features (with syntactic support) for decades now. For
> stateful languages, like Python and C#, iterators and generators fill
> this gap better than anything else I've seen.
> Adobe's position paper commented about generators not being that
> useful, because they're not "deep", like full coroutines.
Not to worry, Adobe is on board:
(I hope this is publicly readable -- it should be).
More information about the Es4-discuss