I also find the mutation of System.normalize slightly worrisome but I do believe that good programming practice here would mean that you would call the previous version of it after your changes. Mostly like a pre-advice.
{ let locate = System.locate; System.locate = function(...) { if (some condition) { return your address; } return locate.call(this, ...); }; } This way it should still be possible to load two sets of libraries without them getting in each others way. On Mon Feb 10 2014 at 11:55:46 AM, John Barton <johnjbar...@google.com> wrote: > On Mon, Feb 10, 2014 at 8:32 AM, David Herman <dher...@mozilla.com> wrote: > > On Feb 7, 2014, at 8:06 AM, John Barton <johnjbar...@google.com> 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. > > > Thanks, of course I understand and agree that these goals are aspirational > and trade-offs are necessary. My argument is that this particular global is > anti-usable. > > > > > 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. > > > Indeed, however, this herring is only red on one fin: the mutability of > System is not limited to the registry and in fact every aspect of the > System is mutable. As far as I can tell, a mutation to say normalize or > locate is entirely unpredictable without runtime tracing. Unless I am > wrong about this, we should not ignore this herring just because of a small > botch of red. > > > > > 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. > > > Did we give up on <script type='module'>? > > > > Dave > > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss