47 points · by sant0sk1 · 16y ago · 37 comments
module A {
export var myPublic = 1
var myPrivate = 2
}
and var A = new function() {
this.myPublic = 1
var myPrivate = 2
}
except that the first will clash with a bunch of existing script that use "module" and "export" as variable names. And the idea of making "load" a keyword in page 26 is just plain silly. - the goal is to not pollute the global namespace as we do today
- the module/export/load are a part of an opt-in dialect of javascript when you specify "text/es-harmony" as the language.What is the other option? The jQuery in "import jQuery.$" has to refer to something. Does he want to create a "module namespace" with special "module objects" not referenceable from normal variable scope? No thanks: that sounds like Java, not JavaScript.
the module/export/load are a part of an opt-in dialect of javascript when you specify "text/es-harmony" as the language
Why does Mozilla need to build dialects into their browser for something which can be done with a simple compiler? Between "create a little module syntax compiler which works in all browsers now" and "wait for all of the borwsers to implement the text/es-harmony dialect", I'd rather see the former.
If they keep this up, web developers will eventually abandon Firefox. Firefox is starting to be the new IE6.
Right, like this, I guess
new function() {
var jQuery = ...
}
I think this document is either omitting the important details or it simply doesn't address the namespacing problem correctly. Remember when Prototype.js had a document.getElementsByClassName? Fun times when that broke.>> the module/export/load are a part of an opt-in dialect
That doesn't seem very well thought-out. How would one access a module declared in a <script type="text/es-harmony"> from a <script type="text/javascript">? It's a pretty realistic scenario (e.g. say you have a non es-harmony codebase and you want to add a es-harmony library)
Interfering with other modules' exports is not possible. But modifying the properties of arbitrary objects is just as possible as ever. Modules are all about fixing scope, not about locking down objects.
To put it differently, the document is not a module, it's an object. The module system has nothing to do with it.
>> How would one access a module declared in a <script type="text/es-harmony"> from a <script type="text/javascript">? It's a pretty realistic scenario (e.g. say you have a non es-harmony codebase and you want to add a es-harmony library)
This is accounted for in the design. The global object is not in the scope chain of Harmony code, but it is still available to Harmony code via a standard binding in the standard library, and the Harmony modules are made available to legacy JS as module instance objects in the global object. So communication is available in both directions.
myModule: {
// don't do anything if myModule is already included
if (myModule) break myModule;
let this_is_private = ...;
var myModule = ...;
// myModule is public and won't pollute the
// global NS if it isn't included globally.
}http://openjsan.org/doc/s/sa/samuraijack/Joose/3.010/lib/Joo...
http://openjsan.org/doc/s/sa/samuraijack/JooseX/Namespace/De...
I am really excited about the future of Fuse and fusebox in web development. John David-Dalton's work on both is excellent, and I am happy I have been apart of the exciting development process.
js is coming to the server quite nicely, most modern browsers support it well too... Even microsoft starts to take the web seriously with IE9.
I am not convinced mozilla fondation is in its role breaking compatibilities when avoidable
Just because a language is dynamically typed doesn't make it a "scripting language".