Allen suggested something like this in the September meeting. One issue people 
had with it was that it adds another violation of the equivalence between a 
statement <stmt> and (function()<stmt>)(), which is a refactoring hazard. Put 
differently, if you have some code with "static" declarations in it, you can't 
wrap the code in a function body without breaking the code, which makes it 
brittle.

Separate from that, I also don't really see how the idea really buys you all 
that much. The analogy to C is only so helpful, since C doesn't have nested 
functions (and static therefore always lifts to global scope), so mostly it 
just reads to me like a rather obscure way of saying "oops, I meant to bind 
this over there."

Dave

On Nov 22, 2010, at 8:18 PM, Bga wrote:

> // es3 way
> (function()
> {
>  var x = 1;
> 
>  return function()
>  {
>    return ++x;
>  }
> })();
> 
> // current es6/SM1.8 way
> let(x = 1) function()
> {
>  return ++x;
> }
> 
> // "new" more readable sugar
> function()
> {
>  static x = 1; // hello c/c++
> 
>  return ++x;
> }
> 
> Implementation, when compiling source code, just collects 'static' vars
> from scope and wraps current scope to closure scope with collected vars  
> 
> 
> 
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

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

Reply via email to