Module syntax

David Herman dherman at mozilla.com
Thu Jun 6 10:46:20 PDT 2013


On Jun 5, 2013, at 2:58 PM, Domenic Denicola <domenic at domenicdenicola.com> wrote:

> From: David Herman [dherman at mozilla.com]
> 
>> Moreover, Yehuda has urged me to consider
>> 
>>   export x = 17;
>> 
>> as sugar for
>> 
>>   export let x = 17;
> 
> I'd urge `const` instead of `let`, as `const` discourages the footgun of action-at-a-distance mutable `with`/global-like bindings that I keep talking about (e.g. at http://esdiscuss.org/topic/importandaliasingbindings). Ideally this would extend to `function` and `class` as well.

This is too bondage-and-discipline for JS. If you simply don't multiply-assign to the bindings they will be immutable anyway.

> In fact, if I had my way I'd continue down this path trying to eliminate mutable action-at-a-distance bindings entirely by removing `export let`, `export var`, and `export const`. That just leaves `let x; export { x };` as dangerous, and I think there are solutions to that but I won't bore you with them unless people are enthusiastic about this idea...

I'm not. :) I don't agree that the ability for a module to choose to export a mutable binding is bad.

Dave



More information about the es-discuss mailing list