On Tuesday 2017-08-29 18:32 -0700, Eric Rahm wrote:
> Do we explicitly state a preferred alignment of arguments in multi-line
> function declarations (primarily in the context of C++) [1]? This question
> has come up in regards to using clang-format for cleaning up code [2] and
> it would be helpful to be able to reference a concrete example in the style
> guide.
> 
> Given this example:
> 
> int
> Foo(const nsACstring& aStr,
>     mozilla::UniquePtr<const char*>&& aBuffer,
>     nsISupports* aOptionalThing = nullptr);
> 
> Should the reformatted style:
> 
> a) *stay the same*
> b) align the argument names like so:
> 
> int
> Foo(const nsACstring&                 aStr,
>     mozilla::UniquePtr<const char*>&& aBuffer,
>     nsISupports*                      aOptionalThing = nullptr);
> 
> c) some other option

I don't know if we've had any official statements, but I tend to
reformat code *away* from option (b) towards your original example
if I'm modifying it and need to add a parameter than would throw
things out of alignment.

I think I do this because (b) has the disadvantage that more code
changes require touching additional lines, which is both changes
blame and is extra work (although it's not extra work if we're using
clang-format tree-wide).  Option (b) is also more likely to lead to
overly long lines that require wrapping.

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Attachment: signature.asc
Description: PGP signature

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to