On 5-Mar-09, at 4:53 PM, Lex Spoon wrote: > On Thu, Mar 5, 2009 at 5:10 PM, Matt Mastracci > <[email protected]> wrote: >> function x() { >> var a = 3; >> return new Function("alert(a); a = 4;"); >> } > > I hadn't thought of that! Unfortunately, the code in question has > definitions like "function foo() { ... } " that are intended to end > up defined at global scope. > > Joel suggests that it would work to rearrange the code to look more > like "foo = function() { ...}" or even "window.foo = function() { > ...}". I agree, but that means the compiler would need to be coaxed > into generating this alternate code. It ultimately needs to, anyway, > for supporting the cross-site linker, but I was hoping to avoid > getting into that right now.
Ah yeah - any of the new definitions in the body of Function end up in the Function's private scope, even though the parent scope of the function body is the global one. --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
