Addition of a global namespace function?
mikesamuel at gmail.com
Thu Dec 3 12:51:01 PST 2009
2009/12/3 Patrick Mueller <pmuellr at yahoo.com>:
> On Dec 3, 2009, at 3:01 PM, Alex Russell wrote:
>> Personally, I don't think this is sufficient to solve the largest set of problems that users encounter with the language. Specifically, if entering a namespace does not prevent global pollution (i.e., omitting "var" still pollutes), then it seems to me like the proposal is something of a missed opportunity.
> I agree. Are there any proposals to add the capability of creating new top-level "scopes" (contexts?) and running a script in them, such that something like CommonJS modules could be implemented in user-land code? I imagine it as something like HTML5's importScripts() function (available to Workers only), but it would run the script (a single script) in a newly created top-level scope, and return that scope as an object from the function itself.
There is the hermetic eval proposal that would not create new
top-level scopes, with their attendant base Object constructor, but
would allow experimentation with module systems that address the
separation concerns resulting from global pollution.
> Patrick Mueller - http://muellerware.org/
> es-discuss mailing list
> es-discuss at mozilla.org
More information about the es-discuss