JavaScript needs macros
JavaScript needs a macro compiler companion to extend the language with new statements:
defs export(VarDecleration v) {
this.{{v.varName}} = {{v.initValue}};
}
defs module(VarName n, Block b) {
var {{n}} = new function () {{b}};
}
defs import(VarName module, Period p, VarName vName) {
var {{vName}} = {{module}}.{{vName}};
}
So (~> pronounced “compiles to”):
>>> export var foo = 3;
~> this.foo = 3;
>>> module X { ... };
~> var X = new function () { ... }
>>> import A.B;
~> var B = A.B;
And there are your modules, compatible with every browser instantaneously, without having to wait for IE12 to implement any JS dialects.