Why can’t for-of be applied to iterators?

Brendan Eich brendan at mozilla.com
Wed Jun 12 10:49:58 PDT 2013

Andy Wingo wrote:
>> >  function *giveMeAEmptyIterator() {}
> Is this valid?
>    https://bugs.ecmascript.org/show_bug.cgi?id=1283
> (I think it should be, FWIW)

It absolutely should be. See



DaveH's presentation on using generators to write asynchronous code.

How do you compose generators?  yield*

Waldemar: Given yield*, writing base-case trivial generators that
don't yield becomes useful but its syntax is a problem.  Generators
should not be distinguished from functions by the presence of a yield


This led to the "function*" syntax for generators, to enable 
empty-bodied generators as the basis cases.


More information about the es-discuss mailing list