[Development] commas in ctor-init-lists

Jędrzej Nowacki jedrzej.nowacki at qt.io
Wed Jun 1 15:58:35 CEST 2016

On Wednesday 01 of June 2016 15:44:22 Marc Mutz wrote:
> > Subjective reasons against trailling commas:
> > - It's ugly
> I beg your pardon? Trailing commas are ugly? So where's the text editor
> that  folds prose text to have commas on the next line?
Aesthetics are subjective by definition, you could argue that leading commas 
are creating optically aligned result, highlighting indentation of the 
initialization list :D

> > Objective reasons in favor of leading commas:
> > - You get 1 line diffs
> You get the same when you insert fields in the middle. Only at the end
> there's  a difference.
You can not always pick where you insert new field, it may cause warnings and 
bugs cause by wrong initialization order.

> > - You can comment it out by commenting only 1 line
> > - Code generators / tooling only have to touch 1 line to add or remove
> All these are also valid for enums and function argument lists, but I see
> no- one doing similar things for enums and functions.
> If those reasons were strong enough to do away with 100s of years of 
> typesetting history, why don't we use it for functions, too:
>    func(
>          loooooooooooooooooooooooooooooooooongarg1
>        , loooooooooooooooooooooooooooooooooooooooooooonerarg2
>        , looooooooooooooooooooooooooooooongestarg3
>         );
> Hmm, sweet...
Good idea we should all that everywhere :-)

> > Weren't these reasons even a motivation for C++11 to support "trailling
> > enum comma" ?
> Yes, and we should wait for / propose that they do the same change for ctor-
> init-list, too. Not apply some horrible work-around.
We have long tradition of doing stuff before C++ standard. We can not just 
drop it :P

Enough trolling :-)

 , Jędrek

More information about the Development mailing list