- From: <bugzilla@jessica.w3.org>
- Date: Fri, 24 May 2013 06:00:43 +0000
- To: public-script-coord@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=22156 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 https://code.google.com/p/chromium/issues/detail?id=242800 Hixie also suggested this over at Bug 21589 - SelectionMode enum should not have a trailing comma ...in Comment 2: https://www.w3.org/Bugs/Public/show_bug.cgi?id=21589#c2 Concretely, I think we just need to replace [[ | ε ]] with [[ | "," | ε ]] ...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 ambiguity. Looking at the grammar http://dev.w3.org/2006/webapi/WebIDL/#idl-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). References http://en.wikipedia.org/wiki/Coding_conventions#Lists http://stackoverflow.com/questions/7246618/trailing-commas-in-javascript http://stackoverflow.com/questions/201782/can-you-use-a-trailing-comma-in-a-json-object ES3 and ES5 spec: ES3: [[ ObjectLiteral : { } { PropertyNameAndValueList } ]] ES5: [[ 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