Remarks about module import

ihab.awad at ihab.awad at
Mon Aug 18 17:02:50 PDT 2008

On Mon, Aug 18, 2008 at 4:46 PM, Brendan Eich <brendan at> wrote:
> On Aug 18, 2008, at 1:44 PM, ihab.awad at wrote:
> .... whether modules should be like ES1-3's weak notion of program units
> or should be something new: purely lexical scope containers.

I was making a weak reference ;) to the ES3 <Program> but picking and
choosing. Plus my head is deep in the Caja world. Apologies for the
lack of clarity.

My proposal is the latter per your question: A module is an isolated
lexical scope container, and contains no implicit references to any
shared global object.

> This reasoning seems backwards. If modules are added in a first-class way to
> the JS, they present an opportunity to avoid the global objec utterly, and
> enforce true lexical scope. Since the Program nonterminal from ES1-3 is
> evaluated using a shared global object in browser embeddings, it cannot be
> restated using this lexical-scope-only idea of a module.

Right, so yes, I agree entirely.

> Inside a module, introduced by some kind of explicit syntax, only lexical
> scope is allowed. No global properties are available. Typos in unqualified
> identifier expressions can be caught at compile time. Cats and dogs live
> together in peace ;-).

Yup, live they do. :) That said, we in Caja land have worried about
whether *some* default global properties should be made available --
objects that are essentially powerless like Function and Number, and
which would be a pain in the neck to have to explicitly pass down to
subordinate modules every time with every "importModule" statement.
What this set of defaults would or should be is up in the air, mainly
because Date would logically be one of them yet it is notably *not*



Ihab A.B. Awad, Palo Alto, CA

More information about the Es-discuss mailing list