<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 19, 2020 at 8:15 PM antlists via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 19/12/2020 18:35, Chris Lattner via llvm-dev wrote:<br>
> On Dec 3, 2020, at 1:00 PM, Nikita Popov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> Hi,<br>
>> LLVM currently uses a coding style where arguments and parameters need to be aligned to the opening parenthesis "(".<br>
>><br>
>> someFunctionCall(Arg1, Arg2,<br>
>> Arg3, Arg4);<br>
>><br>
>> This style guideline is unfortunate for a couple of reasons:<br>
>><br>
>> 1. If a function is renamed, it is necessary to also reindent the arguments at all call-sites. For functions with many or complex arguments, this may require significant reflow.<br>
>><br>
>> 2. It causes significant right-ward drift. Especially for declarations, it's somewhat common for code ending up like this...<br>
>><br>
>> Foo SomeClassName::someMethodName(Bar &Arg1,<br>
>> Bar &Arg2,<br>
>> Bar &Arg3,<br>
>> Bar &Arg4) {<br>
>><br>
>> ... because there is just enough space to fit each argument individually, but still a need to break each one out on a separate line. Closure arguments are another common case of very awkward formatting.<br>
>><br>
>> 3. There are some arcane rules about when this is not the preferred style and you're supposed to indent arguments on the following line instead.<br>
>><br>
>> Is there any chance that the style could be changed towards indenting (but not aligning) the following line instead?<br>
>><br>
>> someFunctionCall(<br>
>> Arg1, Arg2, Arg3, Arg4);<br>
>><br>
>> This is unaffected by renames, does not cause rightward drift and results in very predictable formatting.<br>
>><br>
>> Based on past discussions, LLVM seems to be open to improving coding style for the better, so I thought I'd give this a shot, as this is a continuous source of friction for me.<br>
> <br>
> I support this change. I think you’ve done a good job of laying out a principled reason that this approach is better, and I don’t see any significant advantages to the current approach. We should obviously keep the arguments on the same line if they fit though.<br>
> <br>
There's a big argument against the current standard, which is that if <br>
you have several functions next to each other, they are all formatted <br>
differently. Very confusing on the eyes.<br>
<br>
My personal preference would be either (a) all arguments on one line if <br>
there's room (either with the function name, or the line below), or (b) <br>
one argument per line with an indent of either one or two from the start <br>
of the function name.<br></blockquote><div><br></div><div>To add my €0.02, whatever the common form is there are times when it makes more sense to escape from it. A common example is where a function has arguments that come in pairs -- common in UI toolkits with x/y or w/h pairs -- and the formatting should reflect that. It's less common in LLVM, though I've seen it happen. Being slightly more relaxed with such things would be great.</div><div><br></div><div>That said, the proposed change is clearly better even in this case, because while</div><div><br></div><div>someFunctionCall(</div><div> x1, y1,</div><div> x2, y2);</div><div><br></div><div>is best, I'd say that</div><div><br></div><div>someFunctionCall(</div><div> x1,</div><div> y1,</div><div> x2,</div><div> y2);</div><div><br></div><div>is far better than the</div><div><br></div><div>someFunctionCall(</div><div> x1, y2, x2,</div><div> y2);</div><div><br></div><div>that the current style likes to generate.<br></div><div><br></div><div>Something analogous happens with &&- or ||- chains in conditionals.<br></div><div><br></div><div>Cheers,</div><div>Nicolai<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Cheers,<br>
Wol<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">Lerne, wie die Welt wirklich ist,<br>aber vergiss niemals, wie sie sein sollte.</div></div>