C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Allow comma at the end of a list of objects in a declaration or definition

From: Bo Persson <bo_at_[hidden]>
Date: Sun, 7 May 2023 19:33:28 +0200
On 2023-05-07 at 18:44, Frederick Virchanza Gotham via Std-Proposals wrote:
> We already allow a comma at the end of initialiser lists and enums,
> and so I propose that we also allow a trailing comma in the following:
>
> int a, b, c, ;
>
> The reason why I want that comma after 'c' is that sometimes I write
> a source file as follows:
>
> std::jthread
> thread_listener,
> thread_sender,
> thread_monitor
> ;
>
> When I add a new variable called 'thread_socket', I want the diff file
> in SVN and Git to simply show that I've added a new line. But instead,
> it shows that I've edited one line and added one line, as follows:
>
> - thread_monitor
> + thread_monitor,
> + thread_socket

I propose that we ban commas altogether, and make you write each
declaration as its own line. Then the diff will show exactly the line
that was added:

  std::jthread listener;
  std::jthread sender;
  std::jthread monitor;
+std::jthread socket;

Received on 2023-05-07 17:33:35