I hope this is the right place to ask this question:

When are LexicalEnvironment and VariableEnvironment ever not the same? My 
understanding, derived from ECMA-262 is as follows:

(1) Mainly needed for "with", because properties should be found during 
identifier lookup, but new bindings should be made in the surrounding 
environment.

(2) Function definitions: function declarations use the VariableEnvironment as 
scope, while function expressions use the LexicalEnvironment. Rationale? To 
make function declarations function-global (=ignoring with statements)?

Did I miss any differences?

The following code can be used to test (2). Console output is "bar" on Firefox 
and Rhino, "abc" on V8 (Node.js). If you use a function expression, the output 
is "bar" on all platforms.

var foo = "abc";
with({ foo: "bar" }) {
    function f() {
        console.log(foo);
    }
    f();
}

Any confirmations are highly appreciated.

Greetings,

Axel

-- 
Dr. Axel Rauschmayer

[email protected]
twitter.com/rauschma

home: rauschma.de
blog: 2ality.com



_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to