Update on ES3.1 block scoped function declarations
Brendan Eich
brendan at mozilla.org
Thu Jul 10 11:05:37 PDT 2008
On Jul 10, 2008, at 10:55 AM, Allen Wirfs-Brock wrote:
> We discussed these issues at today’s ES3.1 conference call and
> arrived at a new plan of record:
>
> 1) We concluded that the present diversity of semantics of block
> nested function declarations among browser implementations probably
> cannot be replaced with a standard semantics without significant
> breakage of the web. One compelling use case is the apparent common
> usage of the difference in IE and FF semantics in this regard as a
> browser identification test.
>
Could you please cite a few URLs showing this common usage? It's a
new one on me.
> 3) We will still include lexically scoped block environments, but
> only for const declarations. If you want to define a block scoped
> function, do it using a const whose value is a function expression.
>
So what would this program print in ES3.1?
const C = 42;
function f(x, y) {
const C = 33;
if (x) {
const C = 21;
return eval(y);
}
return C;
}
print(f(true, "C"));
> In a latter revision, we would expect to also add block-scoped let
> declaration to enable block scoped variables.
>
"latter revision" is spelled E-S-4 :-P.
/be
More information about the Es4-discuss
mailing list