Isaac Schlueter (2012-03-06T17:50:42.000Z)
A great many letters have been typed regarding the number of letters in the
word "function".

What if we just made the keyword "function" entirely optional, dart-style?

*ShortNamedFunctionDeclaration* *:**Identifier **<no_linebreak>* *(* *
FormalParameterListopt* *) <no_linebreak> {* *FunctionBody* *}**
ShortNamedFunctionExpression* *:**Identifier **<no_linebreak>* *(* *
FormalParameterListopt* *) <no_linebreak> {* *FunctionBody* *}*Note that
the identifier is no longer optional, and that no linebreak is allowed
between the parameter list and the body, unlike current function decl/exprs.
myList.forEach(x (item) {
  item += 2
  doSomethingElse(item)
  assert(typeof x === "function")
})
// expression, not declaration
assert(typeof x === "undefined")

// declaration, hoisted
assert(typeof doSomethingElse === "function")

doSomethingElse (item) {
  // IIFE, not declaration
  ;(y (n) { item += n })(Math.random())
  assert(typeof y === "undefined")
}

Is there an obvious case I'm overlooking where this sort of construction
would fail?  Clearly, you can't put the { on the next line or else it'll be
interpreted as an invocation followed by a block, and that could be a
significant footgun.  But, it's not a *new* footgun, since \n{ is
problematic with return anyhow. (I long for a mode where \n{ is always a
syntax error.)  And, it introduces no new keywords, no syntax that isn't
already an error, and no new semantics.

I'm eager to see what I missed when you shoot this down :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120306/ed6c1f38/attachment-0001.html>
github at esdiscuss.org (2013-07-12T02:24:50.347Z)
A great many letters have been typed regarding the number of letters in the word "function".

What if we just made the keyword "function" entirely optional, dart-style?

```
*ShortNamedFunctionDeclaration* *:**Identifier **<no_linebreak>* *(* 
*FormalParameterListopt* *) <no_linebreak> {* *FunctionBody* *}*
*ShortNamedFunctionExpression* *:**Identifier **<no_linebreak>* *(* 
*FormalParameterListopt* *) <no_linebreak> {* *FunctionBody* *}*
```

Note that the identifier is no longer optional, and that no linebreak is allowed between the parameter list and the body, unlike current function decl/exprs.

```javascript
myList.forEach(x (item) {
  item += 2
  doSomethingElse(item)
  assert(typeof x === "function")
})
// expression, not declaration
assert(typeof x === "undefined")

// declaration, hoisted
assert(typeof doSomethingElse === "function")

doSomethingElse (item) {
  // IIFE, not declaration
  ;(y (n) { item += n })(Math.random())
  assert(typeof y === "undefined")
}
```

Is there an obvious case I'm overlooking where this sort of construction would fail?  Clearly, you can't put the `{` on the next line or else it'll be interpreted as an invocation followed by a block, and that could be a significant footgun.  But, it's not a *new* footgun, since `\n{` is problematic with return anyhow. (I long for a mode where `\n{` is always a syntax error.)  And, it introduces no new keywords, no syntax that isn't already an error, and no new semantics.

I'm eager to see what I missed when you shoot this down :)