Generator issue: exceptions while initializing arguments

Brendan Eich brendan at mozilla.com
Mon Sep 10 17:38:53 PDT 2012


Dmitry Soshnikov wrote:
> FOO = 45;
>
> bar(); // 48
>
> Use cases like:
>
> function bar(y = FOO + 3) {
>   var FOO = 10;
>   return y;
> }
>
> May look subtle, however, if again to accept lexical scope as the 
> function definition, then FOO again should be resolved in the 
> bar.[[Scope]], not in the bar's activation:
>
> bar(); // still 48

It's a good point. The ES6 proposal is more expressive than Python and 
subsumes it. You can compose:

   var FOO = 42;
   function bar(x, y = FOO + x) {...}

and use both activation-scope parameters and outer-scope closed-over 
variables as usual.

/be


More information about the es-discuss mailing list