instantiating generators

Brendan Eich brendan at mozilla.com
Tue Mar 12 10:42:56 PDT 2013


This is not what we prototyped and shipped in SpiderMonkey starting in 
2006, and Rhino and probably other engines cloned, for years. That's not 
to say we should or shouldn't do it, but I'm always leery of made-up 
stuff without any prototype-implementation mileage.

Allen, is there any reason to make things more nested, with hidden 
(Generator) constructor? I see what you're getting at but the lack of it 
has never been an issue for JS1.7+ users. When in doubt, flat is better 
than nested (Zen of Python).

/be

Andy Wingo wrote:
> Hi,
>
> Given "function* g() { yield 1; }", are these equivalent?
>
>    new g();
>    g();
>
> Somehow I had assumed that /calling/ would be the normal way to
> instantiate a generator, but I see "new" in
> http://wiki.ecmascript.org/doku.php?id=meetings:proposed_generator_class_hierarcy_nov_2013.png.
>
> Thanks,
>
> Andy


More information about the es-discuss mailing list