Reading back through I think the consensus, at least for initializer lists
was:

   1. Prefer parenthesis, ie:
   , mBool(true)
   2. If using braces, maintain the same spacing you would use with
   parenthesis, ie:
   , mStructWithoutCtor{42}

1. was pragmatic as this is what we already do, 2. was for consistency with
1.

To answer Bogdan's question, it looks like we prefer [1], although it would
be nice to see that codified in our style doc.

jya, you make some interesting points, but we should keep the scope of this
discussion focused. You might want to raise them in separate threads --
"Should we recommend initialization at member declaration", "Should we
recommend where a ctor should is defined", etc.

-e


On Tue, Jun 5, 2018 at 5:50 AM, Jean-Yves Avenard <jyaven...@mozilla.com>
wrote:

>
>
> > On 5 Jun 2018, at 12:54 pm, bposteln...@mozilla.com wrote:
> >
> > I would like to resurrect this thread since it would help us a lot for
> bug 1453795 to come up to a consensus on when to use bracelets and when to
> use parenthesis. Also I must point out a thing here, that was also
> mentioned here earlier, that there are situations where we cannot use
> parenthesis. This is when we want to initialize a structure that doesn't
> have a ctor, like:
> > [1]
> > struct str {
> >  int a;
> >  int b;
> > };
> >
> > class Str {
> >  str s;
> >  int a;
> > public:
> >  Str() : s{0}, a(0) {}
> > };
> >
> > Also it would help a lot if we would establish how many, spaces should
> be between the parenthesis or the bracelets, like how do we prefer [1] or
> [2]
> >
> > [2]
> > class Str {
> >  str s;
> >  int a;
> > public:
> >  Str() : s{ 0 }, a( 0 ) {}
> > };
> >
> > I don't have a personal preference here, but right now there are several
> places in our code that combine spaces between parenthesis/bracelets with
> no spaces.
>
> The current coding style: https://developer.mozilla.org/
> en-US/docs/Mozilla/Developer_guide/Coding_Style states to not use space.
>
> There’s no case where a parenthesis should be followed by a space.
>
> Many things wrong here:
> First the bracket { should be on a new line :
>
> class/struct str
> {
> …
> }
>
> Initialization are to be on multiple-lines.
>
> clang-format would have made it:
>   class Str
>   {
>     str s;
>     int a;
>
>   public:
>     Str()
>       : s{ 0 }
>       , a(0)
>     {
>     }
>   };
>
> IMHO, should be going for C++11 initializer, it’s much clearer, and avoid
> duplicated code when you need multiple constructors.
> What is str? I assume not a plain object, so it should have its own
> initializer.
>
> so it all becomes:
>   class Str
>   {
>     str s;
>     int a = 0;
>
>   public:
>     Str() {}
>   };
>
> or:
>   class Str
>   {
>     str s;
>     int a = 0;
>
>   public:
>     Str() = default;
>   };
>
> (and I prefer constructors to be defined at the start of the class
> definition)
>
> My $0.02
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to