Callable modules are a hugely important use case. jQuery and Underscore spring to mind. I’ve made one myself [1].
Also important: what about construct-able modules? Or to put it another way, what about exporting a module that is a class? Examples from Node [2] [3] and Node-land [4] [5] are abundant. It makes me think a more generic mechanism would be required to export any arbitrary object as the module itself. Perhaps export module as function jQuery(selector, context) { … } // or function jQuery(selector, context) { … } export module as jQuery; export module as class Runnable { … } // or class Runnable { … } export module as Runnable; [1]: https://github.com/domenic/dict/blob/master/dict.js [2]: https://github.com/joyent/node/blob/master/lib/stream.js [3]: https://github.com/joyent/node/blob/master/lib/module.js [4]: https://github.com/visionmedia/mocha/blob/master/lib/runnable.js [5]: https://github.com/visionmedia/mocha/blob/master/lib/suite.js From: es-discuss-boun...@mozilla.org [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Andreas Rossberg Sent: Thursday, March 22, 2012 07:55 To: es-discuss Subject: Re: simpler, sweeter syntax for modules One point that I haven't seen mentioned yet (and it is unrelated to syntax): "export call" makes me cringe -- making modules callable is not just weird, it seems completely future-hostile to the possibility of having parameterized modules. I don't think it is worth bending the notion of module like that if all that is gained is minor convenience. /Andreas
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss