On Sat, Sep 15, 2012 at 2:14 AM, Brendan Eich <[email protected]> wrote:
> So to sum up:
>
> 1. Default parameter expressions are evaluated in the activation scope,
> with all formal parameters bound, no use-before-set dead zone (so formals
> are var-like), functions hoisted and in scope -- because in this case,
> simpler and worse are better.
>
> 2. Generator function with default parameters has implicit yield after
> defaulting (which per 1 comes after function hoisting) -- because:
>
> let n = 0;
>> function *gen(a = ++n) {}
>> for (let x of gen()) {}
>> assert(n === 1);
>>
>
> This is where I am currently, FWIW.
Apologies in advance for making you repeat yourself, but I just want to
circle back to the original question :)
The implicit yield means the thrower example will throw an exception at loc
1, correct?
function thrower() {
throw "exception";
}
function * G(arg = thrower()) {
yield arg;
}
let g = G(); // Exception seen here?
Rick
>
>
> /be
> ______________________________**_________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss