Date: Sun, 17 Aug 2025 11:45:08 -0500
Hi,
In general more trailing commas would be nice and useful.
The motivation you’ve shared, though, isn’t sufficient.
> This would allow formatters like clang-format to spread arguments across
newlines.
Clang-format can already do this, with or without trailing commas.
> It can also be useful for parsing partially written function calls,
allowing tools like clangd to provide information about the
function.
Tools like clangd are free to do whatever they want to handle partially
valid grammar fragments, with or without language support.
Cheers,
Jeremy
On Sun, Aug 17, 2025 at 10:40 Ungureanu Radu Andrei via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hello, I propose allowing trailing commas in function calls:
>
> int add(int a, int b);
> // Both would be valid calls of the function above:
> add(1,2);
> add(1,2,);
>
> This would allow formatters like clang-format to spread arguments across
> newlines. For example, the code above could be formatted like this:
>
> int add(int a, int b);
> add(1,2);
> add(
> 1,
> 2,
> );
>
> This behavior is similar to using a brace-enclosed initializer list.
>
> It can also be useful for parsing partially written function calls,
> allowing tools like clangd to provide information about the
> function. I personally found that lacking this feature adds friction
> when working on code.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
In general more trailing commas would be nice and useful.
The motivation you’ve shared, though, isn’t sufficient.
> This would allow formatters like clang-format to spread arguments across
newlines.
Clang-format can already do this, with or without trailing commas.
> It can also be useful for parsing partially written function calls,
allowing tools like clangd to provide information about the
function.
Tools like clangd are free to do whatever they want to handle partially
valid grammar fragments, with or without language support.
Cheers,
Jeremy
On Sun, Aug 17, 2025 at 10:40 Ungureanu Radu Andrei via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> Hello, I propose allowing trailing commas in function calls:
>
> int add(int a, int b);
> // Both would be valid calls of the function above:
> add(1,2);
> add(1,2,);
>
> This would allow formatters like clang-format to spread arguments across
> newlines. For example, the code above could be formatted like this:
>
> int add(int a, int b);
> add(1,2);
> add(
> 1,
> 2,
> );
>
> This behavior is similar to using a brace-enclosed initializer list.
>
> It can also be useful for parsing partially written function calls,
> allowing tools like clangd to provide information about the
> function. I personally found that lacking this feature adds friction
> when working on code.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-08-17 16:45:20