Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing commas #111

Open
Fabien-Chouteau opened this issue Jan 26, 2024 · 1 comment
Open

Trailing commas #111

Fabien-Chouteau opened this issue Jan 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Fabien-Chouteau
Copy link
Member

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:

  • diffs that look cleaner for code reviews and version control
  • easily reorder the lines
  • easily comment/uncomment any item

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.

@Fabien-Chouteau Fabien-Chouteau added the enhancement New feature or request label Jan 26, 2024
@raph-amiard
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants