Module syntax

Domenic Denicola domenic at
Wed Jun 5 14:58:49 PDT 2013

From: David Herman [dherman at]

> 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 Ideally this would extend to `function` and `class` as well. The desugarings then become

export x = 17;
export function x() { };
export class x { };


export const x = 17;
export const x = function x() { };
export const x = class x { };

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...

More information about the es-discuss mailing list