Dave Herman (2014-12-15T15:31:34.000Z)
On Fri, Dec 12, 2014 at 8:19 PM, Glen Huang <curvedmark at gmail.com> wrote:

> You can already do "var a = 1;export default a;”. Why not make "export
> default var a = 1;” valid?
>

Because the former is creating an exported variable called 'default' and
assigning its initial value to the result of evaluating an expression that
happens to evaluate the current value of 'a'. There's nothing special about
the fact that you used 'a' there, it's just an ordinary expression that
happens to evaluate a variable.

(For historical interest, this was why I was in favor of using the equals
sign in the syntax, to make it clear that export default is doing an
assignment of an initializer expression to a variable, e.g.:

  export default = a;

But this was unpopular and I didn't push the issue.)

At a more basic level, from a "principle of least surprise" perspective, I
would have no idea what `export default var a = 1;` was supposed to mean.

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141215/fb68b763/attachment.html>
d at domenic.me (2015-01-05T20:21:00.690Z)
On Fri, Dec 12, 2014 at 8:19 PM, Glen Huang <curvedmark at gmail.com> wrote:

> You can already do `var a = 1;export default a;`. Why not make `export default var a = 1;` valid?

Because the former is creating an exported variable called 'default' and
assigning its initial value to the result of evaluating an expression that
happens to evaluate the current value of 'a'. There's nothing special about
the fact that you used 'a' there, it's just an ordinary expression that
happens to evaluate a variable.

(For historical interest, this was why I was in favor of using the equals
sign in the syntax, to make it clear that export default is doing an
assignment of an initializer expression to a variable, e.g.:

    export default = a;

But this was unpopular and I didn't push the issue.)

At a more basic level, from a "principle of least surprise" perspective, I
would have no idea what `export default var a = 1;` was supposed to mean.