[Bug 22156] New: Allow trailing commas in Web IDL lists


            Bug ID: 22156
           Summary: Allow trailing commas in Web IDL lists
    Classification: Unclassified
           Product: WebAppsWG
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: WebIDL
          Assignee: cam@mcc.id.au
          Reporter: nbarth+w3bugzilla@google.com
        QA Contact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-script-coord@w3.org

Could we allow trailing commas in Web IDL?

Trailing commas are desired by many stylistically (for consistency and clearer
diffs), and also make automated output of lists easier.

Further, trailing commas being not allowed are a frequent cause of syntax
errors, notably in ECMAScript 3 and in JSON.

I've just been fixing trailing commas in Chromium; this is fiddly to fix and
many developers would prefer that trailing commas be allowed. Relevant bug:
Chromium 242800

Hixie also suggested this over at
Bug 21589 - SelectionMode enum should not have a trailing comma
...in Comment 2:

Concretely, I think we just need to replace
| ε
| ","
| ε
...in any production rule for the tail of a list.

Alternatively, we could add a "CommaOrNone" rule:
CommaOrNone → ","
            | ε

So long as the tail of the list can't be empty, this does not introduce any

Looking at the grammar
...I see the following rules for tails of lists:
[22]    EnumValues
[36]    Identifiers
[54]    Arguments
[62]    ExtendedAttributes
...and in all cases the tail current must be non-empty, so allowing trailing
commas would be ok.

Of these, [62] ExtendedAttributes and [22] EnumValues seem the most important
cases, as these are often rather long vertical lists, but for consistency it
seems best to allow a trailing comma for any of these.

For reference, ES5 added support for trailing commas (though ES3 did not allow
them, and this is a very common cause of errors), and JSON does not allow
trailing commas, while many languages allow them (C, Java, Python).


ES3 and ES5 spec:
 ObjectLiteral :
    { }
    { PropertyNameAndValueList }

 ObjectLiteral :
    { }
    { PropertyNameAndValueList }
    { PropertyNameAndValueList , }

You are receiving this mail because:
You are on the CC list for the bug.

Received on Friday, 24 May 2013 06:00:52 UTC