Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Brendan Eich
Oliver Hunt wrote: That's an unfortunate side-effect. I think that developers should be able to pick their own code styles. After all, most of these choices are subjective. Anyway, thanks for the head's up. They can choose their own style, just not their own syntax. Right, and syntax can re

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Brendan Eich
Tab Atkins Jr. wrote: Remember the general rule: semicolons are always automatically inserted at the end of lines*unless* doing so would cause a syntax error on that line or the next. No, this is not accurate. Consider A (B); Inserting a semicolon as you wrote: A; (B): does not mak

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
On 28/05/2014 2:59 PM, Tab Atkins Jr. wrote: On Wed, May 28, 2014 at 11:51 AM, cowwoc wrote: Wow, what a mess. I've been pretty methodical about semicolons in my code so I forgot about this "feature" :) I'm not a fan of ASI, but in light of your example I agree there is ambiguity. Thanks for t

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Tab Atkins Jr.
On Wed, May 28, 2014 at 11:51 AM, cowwoc wrote: > Wow, what a mess. I've been pretty methodical about semicolons in my code so > I forgot about this "feature" :) > > I'm not a fan of ASI, but in light of your example I agree there is > ambiguity. Thanks for the clarification. Remember the general

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Oliver Hunt
> On May 28, 2014, at 11:48 AM, cowwoc wrote: > > > That's an unfortunate side-effect. I think that developers should be able to > pick their own code styles. After all, most of these choices are subjective. > Anyway, thanks for the head's up. They can choose their own style, just not their

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
On 28/05/2014 2:43 PM, Oliver Hunt wrote: On May 28, 2014, at 11:39 AM, cowwoc wrote: Don't we use a semicolon to denote the end of an expression context? Perhaps I'm missing something, but I see no ambiguity in the example you gave. I expect: return {}; and return {}; to return

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
On 28/05/2014 2:42 PM, Brendan Eich wrote: Oliver Hunt wrote: What you're asking for is grammatically ambiguous in a way that would potentially break existing content, and (generally) leads to really interesting parsing behaviour. As Doug Crockford has argued, this is why K&R style is better

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Brendan Eich
Oliver Hunt wrote: What you're asking for is grammatically ambiguous in a way that would potentially break existing content, and (generally) leads to really interesting parsing behaviour. As Doug Crockford has argued, this is why K&R style is better in JS: always put the { at the end of the l

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Oliver Hunt
> On May 28, 2014, at 11:39 AM, cowwoc wrote: > > > > Don't we use a semicolon to denote the end of an expression context? Perhaps > I'm missing something, but I see no ambiguity in the example you gave. I > expect: > > return {}; > > and > > return > {}; > > to return an object li

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
On 28/05/2014 2:33 PM, Oliver Hunt wrote: On May 28, 2014, at 11:23 AM, cowwoc > wrote: if (foo) return { L: print(something) } The only way to disambiguate this in the general case is to have a rule such as to allow us to be sure that the opening brace is i

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Oliver Hunt
ing content, and (generally) leads to really interesting parsing behaviour. --Oliver > Thanks, > Gili > > > > -- > View this message in context: > http://mozilla.6506.n7.nabble.com/RFE-Allow-newline-when-returning-an-anonymous-object-tp316480p316482.html > Sent from

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
n you explain (or point me to a layman explanation) of the difference between the two forms? Thanks, Gili -- View this message in context: http://mozilla.6506.n7.nabble.com/RFE-Allow-newline-when-returning-an-anonymous-object-tp316480p316482.html Sent from the Mozilla - ECMAScript 4

Re: RFE: Allow newline when returning an anonymous object

2014-05-28 Thread Oliver Hunt
> On May 28, 2014, at 11:10 AM, cowwoc wrote: > > I would like the specification to also allow the following syntax: > > return > { > key: "value" > }; This is currently valid syntax, and has an entirely different behaviour (and side effects) from returning an object literal. This means

RFE: Allow newline when returning an anonymous object

2014-05-28 Thread cowwoc
ing syntax: return { key: "value" }; Meaning, allow a newline between "return" and the opening brace. Should I create an issue at https://bugs.ecmascript.org/enter_bug.cgi?product=ECMA-262 for tracking this? Gili -- View this message in context: http://mozilla.6