On 15.05.2010 15:53, P T Withington wrote:
On 2010-05-13, at 19:41, David Herman wrote:

I've updated the strawman proposals for static modules and dynamic module 
loaders and would love to get feedback from the es-discuss community.

* Static modules:

    http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules
    http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules_examples
Looks great!

I wonder if you considered having an export list, rather than tagging the 
individual exports?  I think that makes it easier to see/document the public 
API of a module.  You could at the same time allow renaming on export.

Yep, I also thought. Cons: we should repeat method name twice (and in the worth case -- three times) and can forget to export something (as e.g. Erlang programmers sometimes where should be -export([...]) statement(s) at the top of a source file). On the other hand (without common "export"), we should repeat the "export" keyword every time. As a variation, naming convention, thus the system can understand automatically what should be exported (as an example on Rhino: http://gist.github.com/363056). But, because of backward compatibility this is not acceptable (although, is convenient).

   module Cowboy {
     export {draw: d, shoot: s};
     function d () { ... };
     function s () { d(); };
   }

FWIW, the rename on import looked "backwards" to me at first glance, but I 
think I can learn.

It can be done for shortness e.g. or naming preferences of an author (maybe he doesn't like "Math" name ;)). But usually, yes, it is useful "backwards". If some module has been rewritten, then the old one can be named with "old" prefix. Thus, a user shouldn't rename it in all files but just (example from Python's django): "import oldforms as forms" and after that continue to use this "forms" name.

Do we really need to say `.*` for all?  We couldn't just say `import Math`?



Yep, ".*" seems obsolete, although, the reason is to be consistent I guess.

Another proposal:

import Geometry.{draw: drawShape};

How about:

import  Geometry:{draw: drawShape};

colon apt more for "from" word. Another variations:

from Geometry import: {draw: drawShape};

or

from Geometry import: {draw as drawShape, ...};

from Geometry import {draw as drawShape, ...}; // without colon at all

Cons:  additional/obsolete "from" and "as" keywords.

P.S.: small off-topic/proposal (just again saw this usage):

module JSON = load('JSON'  ||'http://json.org/modules/json2.js');


How about a small syntactic sugar for useful and widespread construction:

x = x || 10

to remove this repetition from the right side:

x ||= 10.

module JSON ||= load(...);

Dmitry.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to