On 18 March 2013 13:28, Domenic Denicola <[email protected]> wrote: > On Mar 18, 2013, at 7:54, "Sam Tobin-Hochstadt" <[email protected]> wrote: > >> On Sun, Mar 17, 2013 at 11:44 PM, Domenic Denicola >> <[email protected]> wrote: >>> >>> 1. implicit global variable creation >>> 2. `with` >>> 3. `delete`ing free variables >>> 4. `eval` introducing local bindings >>> >>> 2 and 4 make perfect sense, but I don't understand how 1 and 3 interfere >>> with static scoping. In particular, given a language with no `with` and >>> with ES5-strict semantics for `eval`, I was unable to contrive scenarios >>> where implicit global variable creation or `delete`ing a free variable >>> introduced an ambiguity in the scope chain that prevented static knowledge >>> of what an identifier referred to. >>> >>> Does anyone have any idea how 1 and 3 interfere with static scoping? >> >> The point is that given these features, you can't predict statically >> whether a variable reference is bound to a global variable, or is >> unbound and will produce a ReferenceError. >> >> Here's case 1: >> >> if (something_random()) window.xxx = 7; >> xxx; // ReferenceError or not? >> >> And here's case 3: >> >> if (something_else_random()) delete xxx; >> xxx; // ReferenceError or not? > > Thanks, but what does your example for case 1 have to do with implicit global > variable creation?
Nothing, but Sam probably meant to write: if (something_random()) xxx = 7; xxx; // ReferenceError or not? > It actually demonstrates how the situation is exactly the same with > *explicit* global variable creation. Strict mode does nothing to change the > result. > > Similarly, in case 3, the code could be `delete window.xxx` and we still > cannot statically predict whether there's a `ReferenceError` on the > subsequent line or not. Again, strict mode does not change the result. That is true, and the proper answer is that the global object should be on the above list as well. Not sure why Mark did not include it. /Andreas _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

