Make comma at the end of line optional

classic Classic list List threaded Threaded
58 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Алексей
You should have a reason to write it like this. And if you have than
```js
var arr = [
  1, 2, 3
  4
];
```
would probably be better than
```js
var arr = [
  1, 2, 3,
  4
];
```
And even if you don't - you always have an option to insert a coma at the end on the line

But in most cases dropping of a comma at the end would not reduce the readability but only remove the duplicated (by a line break) punctuation

Would you agree that
```js
var a = {
  x: 1
  y: 2
}
```
is not reading worse than
```js
var a = {
  x: 1,
  y: 2
}
```
?

2017-09-12 20:10 GMT+03:00 Jordan Harband <[hidden email]>:
Of course not:
```js
var arr = [
  1, 2, 3
  4
];
```

If JS was the kind of language where a line break definitively ended a statement, that'd be a different story - but it's not.

On Tue, Sep 12, 2017 at 9:57 AM, Алексей <[hidden email]> wrote:
Don't you think that line break is a strong punctuation by itself?

2017-09-12 19:54 GMT+03:00 Jordan Harband <[hidden email]>:
Punctuation isn't noise.

On Tue, Sep 12, 2017 at 9:51 AM, dante federici <[hidden email]> wrote:
I think the only place I see as a current inconsistency is with class definitions vs object definitions. It probably should have been looped into the object shorthand definition:

```js
class MyClass {
  prop = 123
  constructor() {}
  method() {}
}
```
vs
```js
const myObj = {
  prop: 123,
  constructor(){},
  method(){},
};
```

Also, to wit on the class-fields proposal and this issue: https://github.com/tc39/proposal-class-fields/issues/7

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss





_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Dante Federici
In reply to this post by Алексей
In terms of style, and in terms of version control, either of these are fine:

```js
const obj = {
  x: 10
  y: 23
};
// or
const obj2 = {
  x: 10,
  y: 23,
};
```

The mixed case is the most obnoxious one:
```js
const bad = {
  x: 12,
  y: 7
}
```


However, as pointed out, there is ambiguity with:
```js
const obj = {
  get
  x: 10
  y
  z: 24
  get
  myMethod() {
  }
}
```

I just don't see optional comma in a collection as a useful feature for the language -- "whitespace matters" always makes me uncomfortable, especially since there are different standards for line breaks across machines (looking at you `\r\n`), whereas the `,` token, which is already used to delineate arguments, is suited exactly for this job.

The one thing I still have a gripe over is the class definition syntax -- where neither `,` or `;` are used at the end of method expressions.


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Jeremy Martin
In reply to this post by Алексей
> The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). 

This seems to come from the perspective that ASI was a poorly specified feature, as opposed to a recovery mechanism for poorly terminated statements.

That being said, even with ASI completely removed from the discussion, your proposal has some significant barriers to overcome -- most notably the lack of backwards compatibility.

Examples have already been provided where your proposal would change the semantics of already valid code. E.g.,

  const get = "foo";

  const obj = {
    get
    y: 2
  };

  console.log(obj.get);
  // under current rules: `undefined`
  // under your new proposal: `"foo"`

If you introduce new rules to resolve that ambiguity or to preserve backwards compatibility, you've now created a situation similar to ASI, where developers have to remember a list of exceptions before they elide a comma. 

Even in the absence of backwards compatibility concerns, you need to provide a persuasive argument that the cost-benefit ratio justifies the effort, and judging from initial feedback, I think that will be an uphill battle.

On Tue, Sep 12, 2017 at 2:12 PM, Алексей <[hidden email]> wrote:
The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). And they can't be fixed because fixes are not backward compatible. Based on this experience it would be possible to determine the rules that would not have that gaps or their kind.

2017-09-12 20:32 GMT+03:00 Claude Pache <[hidden email]>:

> Le 12 sept. 2017 à 18:57, Алексей <[hidden email]> a écrit :
>
> Don't you think that line break is a strong punctuation by itself?

It could have been. Unfortunately, in JS, it is not.

Automatic semi-colon insertion (ASI) could be seen as an attempt to have their cake and eat it too. Or, as a compromise between the two options by making *some* line breaks significant (e.g., the one after `return`).

But in general, line breaks are not significant enough to allow to introduce ASI-like rules after the fact, that would work reliably enough.

BTW, the title of the thread, “Make comma at the end of line optional”, reveals a probable misunderstanding of the feature. In JS, semicolons are not “optional”, they are “automatically inserted”. That makes a difference when parsing:

```js
a = b
+c
```


—Claude



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
661.312.3853

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Allen Wirfs-Brock
In reply to this post by Dante Federici

On Sep 12, 2017, at 11:22 AM, dante federici <[hidden email]> wrote:

The one thing I still have a gripe over is the class definition syntax -- where neither `,` or `;` are used at the end of method expressions.

Look at the grammar.

`;` is not part of the concise method production, but it is still perfectly fine to insert a a `;` at the immediate end of a concise method.  This is exactly like function declarations.  A ‘;` is not a required part of a function declaration, but you can put one there if you want.

```js
function f() {};

class C {
   m() {};
   n() {};
}  //you can put a ;  here, too if you want
```


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Алексей
In reply to this post by Jeremy Martin
Am... no. Right now this example would just not work. For now this code is invalid.

2017-09-12 21:33 GMT+03:00 Jeremy Martin <[hidden email]>:
> The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). 

This seems to come from the perspective that ASI was a poorly specified feature, as opposed to a recovery mechanism for poorly terminated statements.

That being said, even with ASI completely removed from the discussion, your proposal has some significant barriers to overcome -- most notably the lack of backwards compatibility.

Examples have already been provided where your proposal would change the semantics of already valid code. E.g.,

  const get = "foo";

  const obj = {
    get
    y: 2
  };

  console.log(obj.get);
  // under current rules: `undefined`
  // under your new proposal: `"foo"`

If you introduce new rules to resolve that ambiguity or to preserve backwards compatibility, you've now created a situation similar to ASI, where developers have to remember a list of exceptions before they elide a comma. 

Even in the absence of backwards compatibility concerns, you need to provide a persuasive argument that the cost-benefit ratio justifies the effort, and judging from initial feedback, I think that will be an uphill battle.

On Tue, Sep 12, 2017 at 2:12 PM, Алексей <[hidden email]> wrote:
The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). And they can't be fixed because fixes are not backward compatible. Based on this experience it would be possible to determine the rules that would not have that gaps or their kind.

2017-09-12 20:32 GMT+03:00 Claude Pache <[hidden email]>:

> Le 12 sept. 2017 à 18:57, Алексей <[hidden email]> a écrit :
>
> Don't you think that line break is a strong punctuation by itself?

It could have been. Unfortunately, in JS, it is not.

Automatic semi-colon insertion (ASI) could be seen as an attempt to have their cake and eat it too. Or, as a compromise between the two options by making *some* line breaks significant (e.g., the one after `return`).

But in general, line breaks are not significant enough to allow to introduce ASI-like rules after the fact, that would work reliably enough.

BTW, the title of the thread, “Make comma at the end of line optional”, reveals a probable misunderstanding of the feature. In JS, semicolons are not “optional”, they are “automatically inserted”. That makes a difference when parsing:

```js
a = b
+c
```


—Claude



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Jeremy Martin
Apologies, I was butchering the property getter syntax. With the correct syntax, the backwards compatibility concern remains, however:

    const get = "foo";

    const obj = {
      get
      y() { return 2 }
    };

    console.log(obj.get);
    // current: `undefined`
    // under this proposal: `"foo"`

You can try it yourself here: https://es6console.com/j7hy49k4/



On Tue, Sep 12, 2017 at 2:36 PM, Алексей <[hidden email]> wrote:
Am... no. Right now this example would just not work. For now this code is invalid.

2017-09-12 21:33 GMT+03:00 Jeremy Martin <[hidden email]>:
> The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). 

This seems to come from the perspective that ASI was a poorly specified feature, as opposed to a recovery mechanism for poorly terminated statements.

That being said, even with ASI completely removed from the discussion, your proposal has some significant barriers to overcome -- most notably the lack of backwards compatibility.

Examples have already been provided where your proposal would change the semantics of already valid code. E.g.,

  const get = "foo";

  const obj = {
    get
    y: 2
  };

  console.log(obj.get);
  // under current rules: `undefined`
  // under your new proposal: `"foo"`

If you introduce new rules to resolve that ambiguity or to preserve backwards compatibility, you've now created a situation similar to ASI, where developers have to remember a list of exceptions before they elide a comma. 

Even in the absence of backwards compatibility concerns, you need to provide a persuasive argument that the cost-benefit ratio justifies the effort, and judging from initial feedback, I think that will be an uphill battle.

On Tue, Sep 12, 2017 at 2:12 PM, Алексей <[hidden email]> wrote:
The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). And they can't be fixed because fixes are not backward compatible. Based on this experience it would be possible to determine the rules that would not have that gaps or their kind.

2017-09-12 20:32 GMT+03:00 Claude Pache <[hidden email]>:

> Le 12 sept. 2017 à 18:57, Алексей <[hidden email]> a écrit :
>
> Don't you think that line break is a strong punctuation by itself?

It could have been. Unfortunately, in JS, it is not.

Automatic semi-colon insertion (ASI) could be seen as an attempt to have their cake and eat it too. Or, as a compromise between the two options by making *some* line breaks significant (e.g., the one after `return`).

But in general, line breaks are not significant enough to allow to introduce ASI-like rules after the fact, that would work reliably enough.

BTW, the title of the thread, “Make comma at the end of line optional”, reveals a probable misunderstanding of the feature. In JS, semicolons are not “optional”, they are “automatically inserted”. That makes a difference when parsing:

```js
a = b
+c
```


—Claude



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853




--
Jeremy Martin
661.312.3853

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Алексей
Yes, you are right, there is a problem for an object definition. Can't think of any good idea how to overcome this scenario :(

2017-09-12 21:48 GMT+03:00 Jeremy Martin <[hidden email]>:
Apologies, I was butchering the property getter syntax. With the correct syntax, the backwards compatibility concern remains, however:

    const get = "foo";

    const obj = {
      get
      y() { return 2 }
    };

    console.log(obj.get);
    // current: `undefined`
    // under this proposal: `"foo"`

You can try it yourself here: https://es6console.com/j7hy49k4/



On Tue, Sep 12, 2017 at 2:36 PM, Алексей <[hidden email]> wrote:
Am... no. Right now this example would just not work. For now this code is invalid.

2017-09-12 21:33 GMT+03:00 Jeremy Martin <[hidden email]>:
> The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). 

This seems to come from the perspective that ASI was a poorly specified feature, as opposed to a recovery mechanism for poorly terminated statements.

That being said, even with ASI completely removed from the discussion, your proposal has some significant barriers to overcome -- most notably the lack of backwards compatibility.

Examples have already been provided where your proposal would change the semantics of already valid code. E.g.,

  const get = "foo";

  const obj = {
    get
    y: 2
  };

  console.log(obj.get);
  // under current rules: `undefined`
  // under your new proposal: `"foo"`

If you introduce new rules to resolve that ambiguity or to preserve backwards compatibility, you've now created a situation similar to ASI, where developers have to remember a list of exceptions before they elide a comma. 

Even in the absence of backwards compatibility concerns, you need to provide a persuasive argument that the cost-benefit ratio justifies the effort, and judging from initial feedback, I think that will be an uphill battle.

On Tue, Sep 12, 2017 at 2:12 PM, Алексей <[hidden email]> wrote:
The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). And they can't be fixed because fixes are not backward compatible. Based on this experience it would be possible to determine the rules that would not have that gaps or their kind.

2017-09-12 20:32 GMT+03:00 Claude Pache <[hidden email]>:

> Le 12 sept. 2017 à 18:57, Алексей <[hidden email]> a écrit :
>
> Don't you think that line break is a strong punctuation by itself?

It could have been. Unfortunately, in JS, it is not.

Automatic semi-colon insertion (ASI) could be seen as an attempt to have their cake and eat it too. Or, as a compromise between the two options by making *some* line breaks significant (e.g., the one after `return`).

But in general, line breaks are not significant enough to allow to introduce ASI-like rules after the fact, that would work reliably enough.

BTW, the title of the thread, “Make comma at the end of line optional”, reveals a probable misunderstanding of the feature. In JS, semicolons are not “optional”, they are “automatically inserted”. That makes a difference when parsing:

```js
a = b
+c
```


—Claude



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Michał Wadas
In reply to this post by Jeremy Martin
On the margin: currently that's syntax error.
The only ambiguity that I see is shorthand for variable called get followed by method. 

On 12 Sep 2017 8:33 pm, "Jeremy Martin" <[hidden email]> wrote:
> The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). 

This seems to come from the perspective that ASI was a poorly specified feature, as opposed to a recovery mechanism for poorly terminated statements.

That being said, even with ASI completely removed from the discussion, your proposal has some significant barriers to overcome -- most notably the lack of backwards compatibility.

Examples have already been provided where your proposal would change the semantics of already valid code. E.g.,

  const get = "foo";

  const obj = {
    get
    y: 2
  };

  console.log(obj.get);
  // under current rules: `undefined`
  // under your new proposal: `"foo"`

If you introduce new rules to resolve that ambiguity or to preserve backwards compatibility, you've now created a situation similar to ASI, where developers have to remember a list of exceptions before they elide a comma. 

Even in the absence of backwards compatibility concerns, you need to provide a persuasive argument that the cost-benefit ratio justifies the effort, and judging from initial feedback, I think that will be an uphill battle.

On Tue, Sep 12, 2017 at 2:12 PM, Алексей <[hidden email]> wrote:
The reason why we have a discussions about whether to rely on ASI or insert them manually is because ASI has problems (return is one of them). And they can't be fixed because fixes are not backward compatible. Based on this experience it would be possible to determine the rules that would not have that gaps or their kind.

2017-09-12 20:32 GMT+03:00 Claude Pache <[hidden email]>:

> Le 12 sept. 2017 à 18:57, Алексей <[hidden email]> a écrit :
>
> Don't you think that line break is a strong punctuation by itself?

It could have been. Unfortunately, in JS, it is not.

Automatic semi-colon insertion (ASI) could be seen as an attempt to have their cake and eat it too. Or, as a compromise between the two options by making *some* line breaks significant (e.g., the one after `return`).

But in general, line breaks are not significant enough to allow to introduce ASI-like rules after the fact, that would work reliably enough.

BTW, the title of the thread, “Make comma at the end of line optional”, reveals a probable misunderstanding of the feature. In JS, semicolons are not “optional”, they are “automatically inserted”. That makes a difference when parsing:

```js
a = b
+c
```


—Claude



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
<a href="tel:(661)%20312-3853" value="+16613123853" target="_blank">661.312.3853

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Dante Federici
In reply to this post by Алексей
I mean, it's the general case of the "get" and "set" when defining a method:
https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation

That being said, there's a lot of "you just shouldn't do that" in javascript. Looking at you, `undefined` not being a reserved word.

Syntax aside, a question that hasn't been sufficiently answered is what value does this actually add other than "I don't want to type ,"? Arguments for "easier to read code" I would absolutely disagree with, since it may be easier for one person, but not another. Giving a "line break matters" is a terrible answer, since that would break a ton of backwards compatibility.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Алексей
Think of it from a different way: if there would be no ',' how would you react on the idea of adding it? Peaty sour every one would decide that would be a complete nonsense. On the other side there is a discussion about possibility of make it optional where different people have different opinions. And no, it wouldn't break a tone of code - at list for now we came to only one quite exotic case with "get" and "set". But yes, the fact that it exists making it impossible. At list in such form

2017-09-12 23:09 GMT+03:00 dante federici <[hidden email]>:
I mean, it's the general case of the "get" and "set" when defining a method:
https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation

That being said, there's a lot of "you just shouldn't do that" in javascript. Looking at you, `undefined` not being a reserved word.

Syntax aside, a question that hasn't been sufficiently answered is what value does this actually add other than "I don't want to type ,"? Arguments for "easier to read code" I would absolutely disagree with, since it may be easier for one person, but not another. Giving a "line break matters" is a terrible answer, since that would break a ton of backwards compatibility.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Tab Atkins Jr.
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Jerry Schulteis
In reply to this post by Dante Federici
I tried out "automatic comma insertion" on some real-world code examples; in my opinion it decreases code readability.
It solves the problem of needing to change two lines when adding to the end of a list, but that already has many solutions (the awful comma-first style, allowing trailing commas, just deal with it, syntax-aware diff).

On Tuesday, September 12, 2017, 3:09:51 PM CDT, dante federici <[hidden email]> wrote:


I mean, it's the general case of the "get" and "set" when defining a method:
https://www.ecma-international.org/ecma-262/6.0/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation

That being said, there's a lot of "you just shouldn't do that" in javascript. Looking at you, `undefined` not being a reserved word.

Syntax aside, a question that hasn't been sufficiently answered is what value does this actually add other than "I don't want to type ,"? Arguments for "easier to read code" I would absolutely disagree with, since it may be easier for one person, but not another. Giving a "line break matters" is a terrible answer, since that would break a ton of backwards compatibility.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Jordan Harband
In reply to this post by Tab Atkins Jr.
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Matthew Robb
Okay what would be the cons to allowing semi colons in place of commas in object literals?

I have an aversion to dangling commas. They're like,

On Sep 12, 2017 7:40 PM, "Jordan Harband" <[hidden email]> wrote:
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Dante Federici
I can totally feel the,
English break with,
Commas especially,
as a part of speech;
Semicolons do a great job of delineating sentences and statements;
But I have a special heart for separating bits from bytes.

I guess a return is a period?

Either way ---  I think my opinions are:
* end of statement style is a linting concern
* there's no benefit from comma optional
  => lint + fix can warn or make right in the exact get/set case
* ASI is... a stopgap
* srsly go to coffeescript or sugarjs if you want to type less (P.S. don't)

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Naveen Chawla
In reply to this post by Matthew Robb
Can't `get` be relegated to a reserved/keyword, like `let`, `yield` and `await` were? Just curious about that kind of process & decision?...

On Wed, 13 Sep 2017 at 05:25 Matthew Robb <[hidden email]> wrote:
Okay what would be the cons to allowing semi colons in place of commas in object literals?

I have an aversion to dangling commas. They're like,

On Sep 12, 2017 7:40 PM, "Jordan Harband" <[hidden email]> wrote:
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Isiah Meadows-2
I can assure you that will likely never happen, because it's a pretty obvious identifier to use in more generic or high-context scenarios. (Think: `get(foo, bar)`, and I've done that plenty of times.)

On Wed, Sep 13, 2017, 03:05 Naveen Chawla <[hidden email]> wrote:
Can't `get` be relegated to a reserved/keyword, like `let`, `yield` and `await` were? Just curious about that kind of process & decision?...

On Wed, 13 Sep 2017 at 05:25 Matthew Robb <[hidden email]> wrote:
Okay what would be the cons to allowing semi colons in place of commas in object literals?

I have an aversion to dangling commas. They're like,

On Sep 12, 2017 7:40 PM, "Jordan Harband" <[hidden email]> wrote:
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Naveen Chawla
Very interesting point. Is there another way to get this optional comma proposal through while being backwards compatible? I really like the idea.

If it worked like ASI, then surely it would allow the multi-line `get` case?:

```js
{
    get
    x() //valid syntax after "get", so no comma inserted
}
```

Can someone remind me of the problem doing it this way, if any? (I'm not sure it has been mentioned yet)



On Wed, 13 Sep 2017 at 18:11 Isiah Meadows <[hidden email]> wrote:
I can assure you that will likely never happen, because it's a pretty obvious identifier to use in more generic or high-context scenarios. (Think: `get(foo, bar)`, and I've done that plenty of times.)

On Wed, Sep 13, 2017, 03:05 Naveen Chawla <[hidden email]> wrote:
Can't `get` be relegated to a reserved/keyword, like `let`, `yield` and `await` were? Just curious about that kind of process & decision?...

On Wed, 13 Sep 2017 at 05:25 Matthew Robb <[hidden email]> wrote:
Okay what would be the cons to allowing semi colons in place of commas in object literals?

I have an aversion to dangling commas. They're like,

On Sep 12, 2017 7:40 PM, "Jordan Harband" <[hidden email]> wrote:
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Make comma at the end of line optional

Boris Zbarsky
On 9/13/17 9:05 AM, Naveen Chawla wrote:
> Can someone remind me of the problem doing it this way, if any?

You mean apart from all the existing footguns ASI has?

-Boris
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: Make comma at the end of line optional

Jeremy Martin
In reply to this post by Naveen Chawla
> Can someone remind me of the problem doing it this way, if any? (I'm not sure it has been mentioned yet)

The problem is in how this proposal has currently been structured:

> [...] if line is a complete statement and next line is not an operator than consider it as complete argument (field, element) declaration.

In the provided example...

```js
{
    get
    x() //valid syntax after "get", so no comma inserted
}
```

... the `get` line is a valid, complete shorthand property declaration, so a comma would be inserted, and thus changing the semantics of already valid code.

As is the case with virtually all potential syntax ambiguities, this can be worked around through exceptions and extra rules regarding when commas are/aren't inserted, but that tends this proposal towards the same idiosyncratic footguns that come with ASI.

This is obviously a subjective analysis, but this proposal seems to introduce too much wtfjs material in exchange for too little in time/character savings.


On Wed, Sep 13, 2017 at 9:05 AM, Naveen Chawla <[hidden email]> wrote:
Very interesting point. Is there another way to get this optional comma proposal through while being backwards compatible? I really like the idea.

If it worked like ASI, then surely it would allow the multi-line `get` case?:

```js
{
    get
    x() //valid syntax after "get", so no comma inserted
}
```

Can someone remind me of the problem doing it this way, if any? (I'm not sure it has been mentioned yet)



On Wed, 13 Sep 2017 at 18:11 Isiah Meadows <[hidden email]> wrote:
I can assure you that will likely never happen, because it's a pretty obvious identifier to use in more generic or high-context scenarios. (Think: `get(foo, bar)`, and I've done that plenty of times.)

On Wed, Sep 13, 2017, 03:05 Naveen Chawla <[hidden email]> wrote:
Can't `get` be relegated to a reserved/keyword, like `let`, `yield` and `await` were? Just curious about that kind of process & decision?...

On Wed, 13 Sep 2017 at 05:25 Matthew Robb <[hidden email]> wrote:
Okay what would be the cons to allowing semi colons in place of commas in object literals?

I have an aversion to dangling commas. They're like,

On Sep 12, 2017 7:40 PM, "Jordan Harband" <[hidden email]> wrote:
I would take commas over a mixture a thousand times over; I'd do the same with semicolons - it's not the presence or absence of these tokens that causes a problem, it's the ambiguity.

Introducing the same horrific ambiguity around semicolons, for commas, does not sound like a good idea.

On Tue, Sep 12, 2017 at 1:57 PM, Tab Atkins Jr. <[hidden email]> wrote:
On Tue, Sep 12, 2017 at 1:49 PM, Алексей <[hidden email]> wrote:
> Think of it from a different way: if there would be no ',' how would you
> react on the idea of adding it? Peaty sour every one would decide that would
> be a complete nonsense.

This sort of hypothetical isn't useful; you're not proposing switching
over to *solely* comma-less, you're proposing a *mixture* of comma and
comma-less being allowed.  That has very different ergonomics than
either all-comma or all-comma-less.

The hypothetical comma-less language would also have made many
different syntax decisions over the years to accommodate that, which
current JS has *not* made.  This causes the sorts of problems that
Claude/etc have pointed out.

~TJ
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss




--
Jeremy Martin
661.312.3853

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
123