[Development] commas in ctor-init-lists

Tor Arne Vestbø tor.arne.vestbo at qt.io
Thu Jun 2 13:07:27 CEST 2016


On 01/06/16 14:56, Simon Hausmann wrote:
> Hi,
>
> I'm in favorof changing our coding style to adopt the model you call
> "butt ugly" because I find it more appealing and I find that it makes
> diffs easier to read.

+2

Bar::Bar(Bla *b)
     : Foo(b)
     , m_baz(123)
     , m_biz(321)
{
}

aligns and reads much easier (in both diffs and code) than:

Bar::Bar(Bla *b) :
     Foo(b),
     m_baz(123),
     m_biz(321)
{
}

especially recognizing the baseclass-init over member init. The two 
space indented colon in the coding style is even more awkward, having to 
manually indent the colon instead of using the editor's tab feature, 
plus it breaks the "put things at the end rule".

Bar::Bar(Bla *b)
   : Foo(b),
     m_baz(123),
     m_biz(321)
{
}

tor arne



>
> Simon
>
>
> ------------------------------------------------------------------------
> *From:* Marc Mutz <marc.mutz at kdab.com>
> *Sent:* Jun 1, 2016 14:41
> *To:* development at qt-project.org
> *Subject:* [Development] commas in ctor-init-lists
>
> Hi,
>
> There seems to have been a silent underground move to uglify the Qt sources
> , by using commas to introduce lines
> . I have no idea where this came from
> , but it looks butt
> -ugly and it is in violation of http
> ://wiki
> .qt
> .io
> /Qt_Coding_Style
>
> QFoo::QFoo()
>   : QBase(),
>     m_f1(),
>     m_f2()
> {
>
> }
>
> -not-
>
> QFoo::QFoo()
>   : QBase()
>   , m_f1()
>   , m_f2()
> {
>
> }
>
> (http://wiki.qt.io/Qt_Coding_Style#Line_breaks 2nd item: "Commas go at the
> _end_ of wrapped lines")
>
> Thanks,
> Marc
>
> --
> Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
> KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
> Tel: +49-30-521325470
> KDAB - Qt, C++ and OpenGL Experts
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>



More information about the Development mailing list