Generator issue: exceptions while initializing arguments

Brendan Eich brendan at mozilla.org
Fri Sep 14 23:14:26 PDT 2012


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.

/be


More information about the es-discuss mailing list