Make comma at the end of line optional

Jeremy Martin jmar777 at gmail.com
Wed Sep 13 13:20:11 UTC 2017


*> 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 <naveen.chwl at gmail.com>
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 <isiahmeadows at gmail.com> 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 <naveen.chwl at gmail.com> 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 <matthewwrobb at gmail.com>
>>> 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" <ljharb at gmail.com> 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. <jackalmage at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> On Tue, Sep 12, 2017 at 1:49 PM, Алексей <agat00 at gmail.com> 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
>>>>>> es-discuss at mozilla.org
>>>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> es-discuss mailing list
>>>>> es-discuss at mozilla.org
>>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>>
>>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
Jeremy Martin
661.312.3853
@jmar777 <https://twitter.com/jmar777> / @j <https://stream.live/j>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170913/035ea7b1/attachment.html>


More information about the es-discuss mailing list