Module literal name
import "classes/foo"; // use default namespace new foo.bar();
module ns from "classes/fo"; // alternative namespace new ns.bar();
How is the first example any better than the second? The first is far more difficult to statically analyze, since any identifier could potentially be a "namespace".
On Tue Jun 25 09:34 AM, Kevin Smith wrote:
import "classes/foo"; // use default namespace new foo.bar();
module ns from "classes/foo" ; // alternative namespace new ns.bar();
How is the first example any better than the second? The first is far more difficult to statically analyze, since any identifier could potentially be a "namespace".
It shouldn't be more difficult to statically analyse, I image that the lexer/parser would maintain a 'symbol table' of the possible variables.
Some context, say I'm trying to bundle a couple of modules together for a mobile application: jbondc/ECMAScript/blob/master/packages/mobile.js, jbondc/ECMAScript/blob/master/package.html
Under the current proposal, what I probably would end up doing is assigning everything to the global scope anyway.
I wouldn't want a developer to manually assign/import everything:
module MV from "classes/misc/color";
module MV.color from "classes/misc/color/conversion";
module MV from "classes/web/dom";
I expanded on the idea here: jbondc/ECMAScript/blob/master/packages/mobile-proposal.js, jbondc/ECMAScript/blob/master/package-proposal.html
There's more comments in "package-proposal.html" to how I imagine it could work.
Note: I have some experience with lexers/parsers but not much with JavaScript or its internals so I hope this proposal makes sense.
I've been experimenting with the modules definition and find it unfortunate there's no default literal name for a module.
Could there be an optional 'namespace' or literal name within the module block?
module "classes/foo" { namespace foo; export class bar {} } import "classes/foo"; // use default namespace new foo.bar(); module ns from "classes/foo" ; // alternative namespace new ns.bar();
Some more examples here: jbondc/ECMAScript/blob/master/index.html