On Fri, Apr 15, 2011 at 4:45 PM, Sam Tobin-Hochstadt <[email protected]>wrote:
> On Fri, Apr 15, 2011 at 4:32 PM, Dmitry A. Soshnikov > <[email protected]> wrote: > > > > OK, what I was saying is that you mixing the terminology calling as > "dynamic > > scope" the "runtime bindings". And I mentioned that the dynamic scope is > > when a binding is resolved in the respect to the _callee_, but not in > > respect of the _definition place_ (i.e. _lexical_ place in the source > code). > > > > var foo = 10; > > > > function bar() { > > console.log(foo); > > } > > > > (function () { > > var foo = 20; > > bar(); // 10 in static scope, 20 in dynamic scope! > > })(); > > I understand how dynamic scope works. And ES5 with the mutable global > object has it: > > function bar() { return foo }; > bar() // error: foo is not defined > var foo = 7; > bar(); // produces 7 > > Lexical scope would produce the error both times. > Hi Sam, this does establish that ES5 does not have lexical scope. But I don't how ES5 has dynamic scope. In the above example, the 'foo' that bar has in scope during the second call still has nothing to do with what's in scope at the call site from which bar is called. -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

