ES6 spec: `export default` HoistableDeclaration
Allen Wirfs-Brock
allen at wirfs-brock.com
Wed Nov 19 15:37:49 PST 2014
On Nov 19, 2014, at 1:59 PM, Axel Rauschmayer <axel at rauschma.de> wrote:
>>> * Do these grammar rules mean that you have to put anonymous function expressions in parentheses? Is that desirable (given that it’s a frequent use case)?
>>
>> No, HoistableDeclaration[Default] includes FunctionDeclaration that lacks a BindingIdentifier.
>
> OK, I take it the following wasn’t viable?
that’s correct. We wanted the initialization of a function like:
export default function () {}
to be hoisted, just like:
export function f() {};
>
> > `export default` [lookahead ≠ `function (` ] HoistableDeclaration
> > `export default` AssignmentExpression `;`
>
>>> * If the purpose of the first rule is to enable default-exporting of declarations (= no semicolon) – shouldn’t classes be included?
>>
>> It has nothing to do with semicolons. It's so a function that is a default export can also have a local name binding.
anything that has an AssignmentExpression as its trailing grammar element needs to end with a semicolon.
>
> Ah, interesting and useful.
>
>> We should also allow:
>> export default class Foo {};
>>
>> where Foo is a module local binding.
>
> Without the semicolon, though? The “operand” of `export default` is also a declaration, right?
right, ClassDeclaration doesn’t need to end of a semicolon.
>
>> Please file a bug.
>
> Will do, once I fully understand the issue.
>
> --
> Dr. Axel Rauschmayer
> axel at rauschma.de
> rauschma.de
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20141119/5624bc22/attachment.html>
More information about the es-discuss
mailing list