Module syntax

Axel Rauschmayer axel at rauschma.de
Wed Jun 5 15:59:45 PDT 2013


This makes a lot of sense. It would obviate the need for braces, right?

> Yes, this is actually the direction I've been going in my thinking, based on the critique that export default is the only export form that isn't a binding form, especially when combined with a named function literal (`export default function f() { ... }`). I also like the conceptual simplicity of the default export simply being a public export named "default". Moreover, Yehuda has urged me to consider
> 
>    export x = 17;
> 
> as sugar for
> 
>    export let x = 17;
> 
> When you put this all together, you can actually just see `export default = ...` as sugar for `export let default = ...`. We can also allow the keyword `default` to be used for the other exported declaration forms like `export function default(...) { ... }` and `export class default { ... }`. (We'll finesse the .name property of such a declared function to be taken from the module name, a la Brandon's accepted proposal for .name in ES6.) To recap, the following all become valid ways to specify the default export:
> 
>    export let default = 17;
>    export default = 17;
>    export default = function f() { ... };
>    export default = class { ... };
>    export function default(...) { ... }
>    export class default { ... }
> 
> And you can now import both the default and non-default exports of a module in a single line:
> 
>    import { default as $, ajax } from "jquery";

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130606/0e02e7ec/attachment-0001.html>


More information about the es-discuss mailing list