Why is no line break is needed in ArrowFunction?
Sure, this works for syntax questions.
Today no expression can start with =>, but there is the headless arrows proposal[1] which might add one. IIRC we wanted to be future compatible.
I’m not sure what the motivation for [no LT here] in yield * was, but I support it on the grounds that splitting yield and * across lines is bad :-P In general better to be more conservative than less, I suppose.
From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Eric Suen Sent: Wednesday, October 21, 2015 12:28 AM To: es-discuss at mozilla.org Subject: Why is no line break is needed in ArrowFunction?
Try to write a parser for es6, is this the right place for question about syntax?
There is no expression or statement start with =>, same goes to yield [no LineTerminator here] * AssignmentExpression ?
Although, sadly,: ``
function
foo
() {
}
is completely valid - although I also agree with Brian, and think both
"yield*" and "function*" are one unit, and should be visually grouped as
such.
On 10/21/2015 00:27, Eric Suen wrote:
Try to write a parser for es6, is this the right place for question about syntax?
There is no expression or statement start with =>, same goes to yield [no LineTerminator here] * AssignmentExpression ?
yield [no LineTerminator here] * AssignmentExpression
has the line terminator restriction because yield without the * has the same restriction:
yield [no LineTerminator here] AssignmentExpression
And that one has that restriction because there exists a third form of yield that doesn't take an expression:
yield
This is the same situation as with return statements, which also take a [no LineTerminator here] restriction. It's a convenience to prevent return from capturing the expression from the next line for the users (I'm not among them) who like to rely on semicolon insertion:
if (error) return x = y
Waldemar
Why not remove Headless Arrow Functions from ExpressionStatement like FunctionExpression and ObjectLiteral.
then statement like:
var a = i => 1
will be var a = i => 1;
instead of
var a = i; => 1;
BTW why Statement[return] exists? or why there is no Statment[break] or Statement[continue]? did I miss something?
Try to write a parser for es6, is this the right place for question about syntax?
There is no expression or statement start with =>, same goes to yield [no
LineTerminator here] * AssignmentExpression ?