Open Fabien-Chouteau opened 7 months ago
I would like to open the discussion on a "feature" called trailing comma in Python, Rust, JavaScript, Kotlin, C99, or C++11.
Anywhere there is a comma-separated list, allow a trailing comma after the last element of the list.
For example allow:
Plop : Array_Type (1 .. 4) := ( 1, 2, 3, 4, );
Since this is Ada/SPARK, we could also allow trailing semi-colon:
procedure Plop ( A : Natural; B : Float; C : Integer; );
The motivation is the same as with other languages allowing trailing commas:
At this point I don't see a negative side for this.
As far as alternatives, I've seen some codebases where people put the comma at the beginning of the list:
enum Channel { RED ,GREEN ,BLUE };
Which works for adding new elements inside or at the end of the list. But the problem remains for the beginning.
I agree this is a "low hanging fruit" in terms of UX. Putting that up for discussion
Summary
I would like to open the discussion on a "feature" called trailing comma in Python, Rust, JavaScript, Kotlin, C99, or C++11.
Anywhere there is a comma-separated list, allow a trailing comma after the last element of the list.
For example allow:
Since this is Ada/SPARK, we could also allow trailing semi-colon:
Motivation
The motivation is the same as with other languages allowing trailing commas:
Caveats and alternatives
At this point I don't see a negative side for this.
As far as alternatives, I've seen some codebases where people put the comma at the beginning of the list:
Which works for adding new elements inside or at the end of the list. But the problem remains for the beginning.