On Feb 7, 2014, at 8:06 AM, John Barton <[email protected]> wrote:
> The first goal listed for ecmascript modules: > • Obviate need for globals > (http://wiki.ecmascript.org/doku.php?id=harmony:modules). > Ironically, the current proposal for module loading includes a global > "System" and possibly "Loader". Sorry the goal was unclear. It didn't mean we should never add globals to JS, it meant we should make it so programmers don't need to use globals as a mechanism for code sharing. That doesn't mean there's never any point to adding globals. Even in languages that are born with a module system from day one, they tend to have a standard prelude of globals that are common enough that it would be anti-usable to force programmers to explicit import them. > Worse, it seems like the global System is explicitly expected to be mutated. This is a red herring; a registry is inherently a shared mutable table, whether you make it accessible via a global variable or via a (globally accessible) module. > Just in case the not-global is goal is controversial, consider the following > code snippets: > > 1. Using Globals: > System.import('./myGreatModule'); > 2. Using Modules: > import System from './MyCustomLoader'; > System.import('./myGreatModule'); This isn't a viable option. The module system needs to be accessible from script code (e.g. HTML element attributes), which can't syntactically import. Dave _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

