2010/5/20 Sam Tobin-Hochstadt <[email protected]> > 2010/5/20 ๏̯͡๏ Jasvir Nagra <[email protected]>: > > > The other is to limit the scope from which the imported modules imports > get > > selected to the current scope: > > module Fribble {} > > module Foo { > > module JQ = load 'http://....'; > > module Drawing = load 'http://.../gun.js'; > > module A = load 'http://.../a.js'; > > } > > module Bar { > > module JQ = load 'http://....'; > > module Drawing = load 'http://.../gui.js'; > > module B = load 'http://.../b.js'; // module B gets JQ and Drawing but > it > > can't utter something to get it the shared Fribble > > } > > Two things about this. This is the recommended solution to this > problem in our proposal, since it eliminates accidental access to the > Drawing module.
Cool - we agree that the problem is one which the modules proposal system needs to solve. I am not sure your recommended solution addresses the accidental access problem. Here's a slightly clearer example of the issue: zero.js: module One = load 'one.js'; module Drawing = load 'gun.js'; module JQ = load 'jquery.js'; one.js: import JQ; module Two = load 'two.js'; two.js: import JQ; import Drawing; Drawing.draw(); The module of concern to us is one.js. According to your proposal, one.js is doing in essence a text inclusion of the contents of two.js and as a result is susceptible to the problems unhygienic macro expansion suffers. As a result, JQ in two.js gets bound to jquery which zero.js setup and one.js imported as intended however Drawing *also* gets bound to the Drawing that zero.js setup. The author of one.js - the importee that is responsible setting up two.js - had no way of knowing that two.js needed Drawing and was going to find one in the scope chain. Nor could it take any action to withholding bindings to other imports deeper in modules that two.js may request. But note that all modules have access to Fribble, > since it's in the scope chain. Also, what you've written loads the JQ > module twice - probably you want to only load that once, and have it > shared. > -- > sam th > [email protected] >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

