2009/5/18 Brendan Eich <bren...@mozilla.com>:
>
> On May 18, 2009, at 2:25 AM, Igor Bukanov wrote:
>
>> The remedy for this is simple - the generator can be created using
>> explicit call like Generator(f, arg1, ... argN). This would turn any
>> function into a generator and would allow for runtime checks for eval.
>
> You mean yield, not eval, right?

Right, that was a typo.

>
>> The plus side of this is that an empty generator can be created with a
>> straightforward:
>>
>>  Generator(function() {})
>>
>> and not with a rather unnatural
>>
>>  (function() { if (false) yield; })()
>
> No one makes empty generators.

For me the problem with the way the generators are defined is that a
dead code like that "if (0) yield;" affects the semantic by mere
presence of it. Surely, this is not the first feature in ES that has
that property - "if (0) var a;" is another example. But "if (0)
yield;" sets a new record affecting the nature of the whole function.

> It doesn't need more runtime
> magic machinery and global constructors that are otherwise unmotivated.

That is true, but then runtime-only generators allows to avoid opt-in
tax for all the users. How high is that tax I do not know, but surely
it prevents some user cases for the feature.

Igor
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to