RFE: Allow newline when returning an anonymous object
oliver at apple.com
Wed May 28 11:18:17 PDT 2014
> On May 28, 2014, at 11:10 AM, cowwoc <cowwoc at bbs.darktech.org> wrote:
> I would like the specification to also allow the following syntax:
> key: "value"
This is currently valid syntax, and has an entirely different behaviour (and side effects) from returning an object literal. This means that even if we wanted to we could not change that behaviour without potentially breaking existing content.
That said our reason for the required newline is that it provides a mechanism to disambiguate the grammar and semantics of object literal vs. block statements.
The following for instance has totally different behaviour depending on whether the new line is used:
The only way to disambiguate this in the general case is to have a rule such as <no newline> to allow us to be sure that the opening brace is in an expression context and not a statement.
More information about the es-discuss