domenic at domenicdenicola.com (2013-09-08T00:51:05.148Z)
The reason for the * is substantially (IIRC) to make it possible for an engine to help prevent developers from unintentionally creating a generator function, and to make it possible for someone attempting to use a function to identify immediately whether it is a generator or a regular function.
On Aug 31, 2013, at 12:15 PM, Yuichi Nishiwaki <yuichi.nishiwaki at gmail.com> wrote: > Hi all, I just found a post that the current generator syntax > (function *) seems have decided in: > > https://mail.mozilla.org/pipermail/es-discuss/2011-July/015799.html > > According to the post, the biggest reason the star syntax is adopted > for now is that you cannot write empty generators with star-less > functions in a consistent simple way. But the situation has changed, > and in the current spec (rev 17) yield* is now capable of taking any > kind of iterator, so you can make empty generators just like > > ```js > function * () { > yield * []; > } > ``` > > This looks enough good and simple at least to me. And I wonder if even > now generators still need to be declared with 'star's. What are the > advantages of 'star'ed generators rather than 'star'-lesses? If not > exist, shouldn't it be removed (for the simplicity)? > The reason for the * is substantially (IIRC) to make it possible for an engine to help prevent developers from unintentionally creating a generator function, and to make it possible for someone attempting to use a function to identify immediately whether it is a generator or a regular function. --Oliver > Thank you. > > -- > Yuichi Nishiwaki > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss