ES Modules: suggestions for improvement

Jussi Kalliokoski jussi.kalliokoski at
Wed Jun 27 14:57:27 PDT 2012

Thanks Claus, it helped! But I still kind of like the idea I threw in. It's
a footgun, for sure, but a pretty convenient one, kinda like `with`.


On Jun 28, 2012 12:25 AM, "Claus Reinke" <claus.reinke at> wrote:
>>> let * = Math;
>>> This is dynamic scoping. The difference between import * and let * is
>>> the former is statically scoped, and the latter is dynamically scoped.
>> I'm sorry, I'm not entirely sure what static scoping means in the context
>> of JavaScript. Could you clarify? Does it mean that it's only applicable
>> the context of the current file, module, domain or something like that?
> Perhaps I can answer this, though I'm not involved with ES Modules.
> "Static" scoping means that scoping does not depend on runtime
> behavior. If "Math" is the Module object for the module "Math", then
> we have a "dynamic" object (dependent on runtime behavior). If let
> destructuring were to support "*", the variables in scope after such
> a statement would depend on the properties of a dynamic object,
> so scoping would no longer be static:
>   let * = flip_coin() ? {sin: .., cos: .. } : {apples: .., bananas: ..}
>   console.log( sin(3.14) ); // is 'sin' bound or not?
> That doesn't mean that "static" vs "dynamic" is a clear-cut distinction
> in JS, where code can be constructed and loaded at runtime. But that
> just makes it even more important to have clear phase separations,
> so that one can tell when the static and dynamic phases of each piece
> of code begin (construction followed by static followed by dynamic).
> Language designs that try to unite dynamic modules with static
> scoping are a well-known case of needing very careful design.
> "import *" is barely on the safe side, if done right, "let *" is
> just on the wrong side of this dangerous border.
> Hope this helps,
> Claus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list