AdaCore / ada-spark-rfcs

Platform to submit RFCs for the Ada & SPARK languages
62 stars 28 forks source link

Trailing commas #111

Open Fabien-Chouteau opened 7 months ago

Fabien-Chouteau commented 7 months ago

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:

   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;
                   );

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:

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.

raph-amiard commented 6 months ago

I agree this is a "low hanging fruit" in terms of UX. Putting that up for discussion