Trailing Commas
Johannes Spangenberg
johannes.spangenberg at hotmail.de
Thu Nov 30 00:22:56 UTC 2023
Hello, I was curious about the potential consideration for extending
support for trailing commas. While I don't consider them critical, I
find myself regularly bothered that I cannot use them. I see several
areas in the language where they could be beneficial:
* Argument list in method calls
* Parameter list in method declaration
* Throws clause in method declaration
* Implements clause in classes
* Extends clause in interfaces
* Type arguments
* Type parameters
It's worth noting that array initializers and enum definitions already
support trailing commas. There have been instances where I considered
replacing a List or Set with an array simply because arrays support
trailing commas, whereas List.of does not.
A quick google search brought up JDK-6407472
<https://bugs.openjdk.org/browse/JDK-6407472>, but it's rather dated,
and I wouldn't entirely agree with the comment. Based on my subjective
experience, many, if not most, modern languages embrace trailing commas.
For instance, the official style guide of Rust and various style guides
for JavaScript recommend their use. While Python's official style guide
suggests the use of trailing commas, it doesn't make a clear recommendation.
Best Regards,
Johannes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20231130/db747650/attachment-0001.htm>
More information about the amber-dev
mailing list