Generator Arrow Functions

Claus Reinke claus.reinke at talk21.com
Thu Nov 14 13:47:44 PST 2013


> Everybody should probably review 
> esdiscuss.org/topic/why-do-generator-expressions-return-generators where we discussed this before.

which suggests using generator expressions as arrow bodies to make
generator functions with arrows

    () => (for (y of gen) y)

What I don't understand is why generator expressions are not used
as the only way to create generators, leaving 'function' alone. There
would be

- comprehension-style generator expressions, with implicit yield
     (for (...) ...)

- block-style generator expressions, with explicit yield
     (do*{ ... yield value ... })

and generator functions would be build from generator expressions
and functions (arrows or classic). No need to mix up functions and
generators. At least none I can see...

Claus
 



More information about the es-discuss mailing list