> 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
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform