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
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,
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
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.
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
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,
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
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
-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
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;
}
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
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
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.
// 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
14 matches
Mail list logo