d at domenic.me (2015-01-05T20:34:24.020Z)
@Dave @Allen
Thanks for the support and thanks for making the spec more clear to me (that table example is priceless, i noticed it before, but didn’t understand it quite well :). Would be great if you could consider this syntax for the next version (and sorry for the incorrect version that I proposed).
Just to provide some use case:
I think the only time that you are very likely to do `export default AssignmentExpression` is to expose a default polyfill:
```js
var setImmediate;
if (window.setImmediate) {
setImmediate = window.setImmediate;
} else {
setImmediate = callback => setTimeout(callback, 0);
}
export default setImmediate;
```
And the gotcha, like others have pointed out, is that without the “=“ syntax proposed by Dave, it’s not very clear that the exported local variable is unbound.
But if this is allowed:
```js
export default var setImmediate;
if (window.setImmediate) {
setImmediate = window.setImmediate;
} else {
setImmediate = callback => setTimeout(callback, 0);
}
```
Then there is no gotcha, and like Dave said, it’s very consist with existing vanilla export syntax: you get to decide what is exported before you rebind it to another value (it can be done with `var setImmediate; export {setImmediate as default}`, but you no longer has a nice one-liner.)
My vice versa part in the previous post is trying to cover `export default let` and `export default const`. :)
@Dave @Allen Thanks for the support and thanks for making the spec more clear to me (that table example is priceless, i noticed it before, but didn’t understand it quite well :). Would be great if you could consider this syntax for the next version (and sorry for the incorrect version that I proposed). Just to provide some use case: I think the only time that you are very likely to do `export default AssignmentExpression` is to expose a default polyfill: var setImmediate; if (window.setImmediate) { setImmediate = window.setImmediate; } else { setImmediate = callback => setTimeout(callback, 0); } export default setImmediate; And the gotcha, like others have pointed out, is that without the “=“ syntax proposed by Dave, it’s not very clear that the exported local variable is unbound. But if this is allowed: export default var setImmediate; if (window.setImmediate) { setImmediate = window.setImmediate; } else { setImmediate = callback => setTimeout(callback, 0); } Then there is no gotcha, and like Dave said, it’s very consist with existing vanilla export syntax: you get to decide what is exported before you rebind it to another value (it can be done with `var setImmediate; export {setImmediate as default}`, but you no longer has a nice one-liner.) My vice versa part in the previous post is trying to cover `export default let` and `export default const`. :) > On Dec 17, 2014, at 12:11 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote: > > > On Dec 16, 2014, at 12:07 AM, Glen Huang wrote: > >> A little tweak: >> >> Syntax >> export default var VariableDeclaration; >> >> ExportEntries >> Let names be the BoundNames of VariableDeclaration. >> Let localName be the sole element of names. >> Return a new List containing the Record {[[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: localName, [[ExportName]]: "default"} > > Still not enough, you'd also have to make sure that things like the following are rejected as syntax errors: > > export default var {a,b,c} = obj; //their can only be one binding per module that is exported as 'default' > > Regardless, ES6 is now frozen except for significant bug fixes. Extensions like this can be considered for future for subsequent editions. > > BTW, I should have also pointed you to https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records> and in particular, the last table in that section. > > Allen > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141217/b132a457/attachment.html>