<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">> It's certainly not the most *popular* formatting style, but it's the</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">one I learned. Some other formatting tools, such as astyle, support</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">this style.</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">I</span><span style="font-family:arial,sans-serif;font-size:13px">'m guessing the reason I learned this style was because my background</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">was C before C++, and most C code uses "int *var" but a lot of C++</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">code uses "int& var" and avoids pointers.</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">Note that the ambiguity doesn't usually happen in practice with</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">references because references must be initialized so only one is</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">d</span><span style="font-family:arial,sans-serif;font-size:13px">eclared on each line.</span><div>
<font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Well, it is also quite rare that people declare multiple uninitialized pointers in one line (and it would be a questionable practice).</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">My key argument against this style would be that it suggests that "*" and "&" have a different binding behavior, which I don't think they have.</font></div>
<div><font face="arial, sans-serif"><br></font><div><span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">I'm trying to go from manually-enforced style to automatically, and I</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">don't want the first formatting run to introduce a huge diff. I think</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">that is the *single* *biggest* *thing* people want out of a formatting</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">tool. It's not your job try to force one particular style on anyone</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">> </span><span style="font-family:arial,sans-serif;font-size:13px">(unless you're writing a new language - Go did this well).</span></div><div><font face="arial, sans-serif"><br>
</font></div><div><font face="arial, sans-serif">Well, it is not quite as easy:</font></div><div><font face="arial, sans-serif">1. I am responsible for maintaining clang-format. Ensuring that all combinations of options do the right thing gets significantly harder with more options.</font></div>
<div><font face="arial, sans-serif">2. I want to make clang-format as useful as possible to as many people as possible. Need to churn through pages and pages of flag documentation to find the important flags makes it harder to use. I am not saying that this should be a counterargument to adding any flag at all. However, if it is a flag for a style only used by one or two projects, adding the flag might be a net loss.</font></div>
<div><font face="arial, sans-serif">3. There are style choices that are bad or chosen for bad reasons. I think I would put this one into this category. Now, if we support that style choice in clang-format we ingrain it even further. If we don't (but clang-format still delivers good value) we might convince a few people/projects to move a way from this style.</font></div>
<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Regarding #2: I don't know how many people would be interested in this style. I have never seen it before and would think it is rare, but I might just be ignorant.</font></div>
<div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 28, 2013 at 6:43 AM, Ben Longbons <span dir="ltr"><<a href="mailto:brlongbons@gmail.com" target="_blank" class="cremed">brlongbons@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Wed, Nov 27, 2013 at 6:15 PM, Alp Toker <<a href="mailto:alp@nuanti.com" class="cremed">alp@nuanti.com</a>> wrote:<br>

> On 28/11/2013 01:50, Ben Longbons wrote:<br>
</div><div class="im">>> I'm trying to go from manually-enforced style to automatically<br>
</div><div class="im">> Would an option to not touch the existing pointer/reference style be<br>
> satisfactory?<br>
</div>Well, there already is an option DerivePointerBinding, which my patch<br>
changes to do separate deduction for references.<br>
<br>
Changing that to keep the existing style at each individual site would<br>
solve the problem of the initial diff when applying it to my repo, but<br>
not the main problem that a code formatter is supposed to solve.<br></blockquote><div><br></div><div>I agree.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">
> I can see a wider appeal for controlling what gets formatted and what<br>
> doesn't, as opposed to just trying to support every personal taste here.<br>
</div>I admit, when I first started messing with the GNU indent program as a<br>
novice, I asked "why doesn't this program ONLY change indentation?" At<br>
the time I didn't even know about expand(1).<br>
<br>
But what I want *now*, as a maintainer, is to be able to say to my<br>
contributors: "if you run 'make format', your code will comply to all<br>
style guidelines".<br>
<br>
I actually think it's a bad idea for a formatter to *ever* preserve<br>
anything, except in an initial "clang-format --detect-style ><br>
.clang-format" run.<br></blockquote><div><br></div><div>Once we have such an option, my argument #2 looses a lot of its weight. Until then, we should keep a close eye on the number of flags clang-format has.</div><div>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
The only hard cases I can think of are:<br>
1. if it decides to break a comment (which is irreversible, so should<br>
never be done by default ... I'm not sure what exactly clang-format<br>
does with PenaltyBreakComment)<br></blockquote><div><br></div><div>Turn PenaltyBreakComment to a high value. clang-format will then avoid breaking comments.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

2. when preserving multiple blank lines between logically distinct<br>
parts of a source file (but what you really want in that case is<br>
probably either a documentation section or a namespace or something,<br>
so I could live without that).<br></blockquote><div><br></div><div>You can probably change MaxEmptyLinesToKeep. Or do you mean you need a context dependent setting of this?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
-o11c<br></blockquote><div><br></div><div>Alp: Yes, I agree that "attach" or "align" (which astyle uses) would be better names for this flag. But I am waiting to resolve a few questions around this (e.g. there is also a request to support astyle's "middle" alignment). We basically have to be backwards compatible, so I'd like to change flags as seldomly as possible.</div>
<div><br></div><div>Cheers,<br>Daniel</div></div><br></div></div></div></div>