More fun with scopes and ScriptObjectMirror
attila.szegedi at oracle.com
Wed Dec 11 05:50:41 PST 2013
On Dec 11, 2013, at 2:22 PM, Tim Fox <timvolpe at gmail.com> wrote:
> On 11/12/13 13:19, A. Sundararajan wrote:
>> The way Avatar/js project ( https://java.net/projects/avatar-js ) project implements CommonJS/require is as follows.
>> It creates a anonymous function code wrapping a module (say like http.js). The anonymous function accepts 'exports' as argument. When you eval that code at top level global scope, because of the anon function wrapping around, all top level vars in a module code like http.js become locals of that anon function.
> Isn't that the same as what I described in my last post?
> If so, the problem with that is that globals that aren't prefixed with var still leak.
More information about the nashorn-dev