modules proposal

David Herman dherman at
Thu May 13 16:41:37 PDT 2010


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:

Briefly, the proposal provides a static module form:

    module Widgets { ... }

The declaration binds the module name lexically. Modules declared at the same scope can be mutually recursive. They can also be loaded from external URL's:

    module Even = "";
    module Odd = "";

The body of a module contains nothing in scope except for outer module bindings. Modules are truly lexically scoped, with no global object pollution. Modules can easily import bindings from other modules, either by dereferencing the modules that are in scope directly:

    module Client { ... Widgets.messageBox("hello!"); ... }

or by importing them explicitly:

    module Client {
        import Widgets.messageBox;

Although modules are static entities, they can be dynamically reflected as objects.

There's plenty more details on the wiki page.

* Dynamic module loaders:

These provide an API for dynamically loading and evaluating modules, and creating separate isolated contexts in which modules can be evaluated. You can create a separate module loader that shares no module instances with the current module loader; this could be used e.g. by an IDE (such as Bespin) that wants to run client code without letting the client code affect the running environment of the IDE itself. You can also share some module instances, to have finer-grained control over the sharing between module loaders.

There are some API notes on the wiki page. I expect it'll be revised and refined over time. Feedback welcome!


More information about the es-discuss mailing list