Yes, strawman module system and proposals such as lexical scope are
cooking for Harmony:
http://wiki.ecmascript.org/doku.php?id=strawman:modules
http://wiki.ecmascript.org/doku.php?id=strawman:lexical_scope
These propose lower-level building blocks; ultimately there would be
syntactic sugar all the way up.
A namespace function that can be implemented in ES3 or even ES5
doesn't add much value, I agree -- the gaps to fill in the language
have to do with what ES1-5 leave out: better control over "program
fragments" that parse according to the spec's Program goal non-
terminal but which currently interact in embedding-specific ways, e.g.
successive <script> tags in a page.
What we really want are modules that isolate implementation details as
programmers desire, without name collisions in any object (even in
"the" or "my" global object).
/be
On Dec 3, 2009, at 12:22 PM, Patrick Mueller wrote:
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.
Patrick Mueller - http://muellerware.org/
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss