Re: `static` keyword from C/C++ as own closured var declaration

2010-11-29 Thread Jason Orendorff
The location of a var establishes both the lexical scope where the variable is visible (the enclosing function) and the dynamic scope within which all uses of it refer to the same binding (each activation of that function). let has different scoping rules, but the same relationship between scope

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread David Herman
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,

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Dmitry A. Soshnikov
On 23.11.2010 12:07, David Herman wrote: 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 statementstmt and (function()stmt)(), which is a refactoring hazard. Put differently, if you have

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Asen Bozhilov
David Herman: // new more readable sugar function() { static x = 1; // hello c/c++ return ++x; } This would produce incompatibilities with ECMAScript 5 non-strict code. The word `static` can be used as an Identifier in ES5 non-strict mode.

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Mark S. Miller
On Tue, Nov 23, 2010 at 2:12 AM, Asen Bozhilov asen.bozhi...@gmail.comwrote: David Herman: // new more readable sugar function() { static x = 1; // hello c/c++ return ++x; } This would produce incompatibilities with ECMAScript 5 non-strict code. The word `static` can be used

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread David Herman
Can you give a small example (it's just interesting) -- to see the issue? Sure thing. Say you're writing some code with a constant value, and somewhere inside the code you use `static': var METERS_PER_SQUARE_KILOJOULE = 17.4; ... static foo = 1; ... f(foo,

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Allen Wirfs-Brock
Subject: Re: `static` keyword from C/C++ as own closured var declaration Can you give a small example (it's just interesting) -- to see the issue? Sure thing. Say you're writing some code with a constant value, and somewhere inside the code you use `static': var METERS_PER_SQUARE_KILOJOULE

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread David Herman
if you had said: const foo=1; In both cases, wrapping the declaration with a function changes its scope?? Allen -Original Message- From: David Herman Sent: Tuesday, November 23, 2010 9:24 AM To: Dmitry A. Soshnikov Cc: es-discuss@mozilla.org Subject: Re: `static` keyword from C/C

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Allen Wirfs-Brock
-Original Message- From: David Herman Sent: Tuesday, November 23, 2010 1:07 AM To: Bga Cc: es-discuss@mozilla.org Subject: Re: `static` keyword from C/C++ as own closured var declaration Allen suggested something like this in the September meeting. One issue people had

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Waldemar Horwat
On 11/22/10 20:18, 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; }

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Allen Wirfs-Brock
from C/C++ as own closured var declaration This was already discussed at the September meeting. Some interesting issues are: - How far does static hoist? One let-scope? One block-scope? One function-scope? One class-scope? AWB: the simple answer would be one block-scope (isn't

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Waldemar Horwat
On 11/23/10 15:18, Allen Wirfs-Brock wrote: - How far does static hoist? One let-scope? One block-scope? One function-scope? One class-scope? AWB: the simple answer would be one block-scope (isn't that the same as a let-scope??). It probably will take some experimentation to verify that the

Re: `static` keyword from C/C++ as own closured var declaration

2010-11-23 Thread Allen Wirfs-Brock
Thanks for the test examples. They point out that there are situations that need to be dealt with that don't naturally arise if a programmer writes code using the basic desugaring previous suggested. However, I don't seen anything that is insurmountable in terms of defining the semantics.

`static` keyword from C/C++ as own closured var declaration

2010-11-22 Thread Bga
// 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