On Nov 28, 2013, at 10:40 AM, Brendan Eich wrote:

> Kevin Smith wrote:
>> 
>>    function*(a = yield/b/g) {
>>      a = yield/b/g;
>>    }
>> 
>> 
>> Why allow yield as an identifier in parameter defaults of generators?  
>> Wouldn't it be simpler just to disallow there as well?
> 
> When proposing an irregularity, you need a better reason than "why allow?"
> 
> Parameter default values pave a cowpath of the form
> 
>  function f(a) {
>    a = a || default_a;
>    ...
>  }
> 
> (yes, falsy test and all).
> 
> The new form does not desugar that way, of course. But defaults are evaluated 
> on each activation (contrast with Python, the mutable value default shared 
> singleton side-channel). So why shouldn't yield in a default work? There 
> could be a reason, but we don't have it yet.
> 
> Allen may have a thought.

'yield' is already disallowed in generator function default initializer 
expressions (although I was reviewing the latest spec. revision yesterday and 
there may still be still bugs I have to fix in that regard).

The reason it isn't allowed is that the generator object is not yet 
instantiated and active at the point where a default value initializer would be 
evaluated. (note you yield from a invocation on the generator object, not the 
generator function that creates a generator object) .

Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to