I believe is has effectively been added under the more constrained object literal extensions http://wiki.ecmascript.org/doku.php?id=harmony:object_literals
On Tue, Mar 6, 2012 at 12:50 PM, Isaac Schlueter <i...@izs.me> wrote: > 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 :) > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss