<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 28, 2013 at 5:29 PM, Christopher Olsen <span dir="ltr"><<a href="mailto:chrisaolsen@gmail.com" target="_blank" class="cremed">chrisaolsen@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for the feedback.  I've updated the patch:<br>
<br>
Added the flag SpacesInAngles - A<int> vs A< int ><br>
<div class="im">Note that LanguageStandard=Cpp03 overrides SpacesInAngles=false in the<br>
case of '>>' as in A<A<int> ><br>
<br>
</div>While I tend to agree with you on spacing in template arguments I have<br>
5+ million lines of code developed over 12 years in strict "pad<br>
everything" style to contend with.  Honestly, I'm hoping clang-format<br>
will eventually allow us to re-evaluate certain style choices if it<br>
gets adopted on our project.<br></blockquote><div><br></div><div>As I said, I can perfectly understand the necessity for SpacesInAngles (both because there are large codebase where consistency matters and that it is a strong matter of what one is used to). So this option is totally reasonable. Sorry if I was unclear.</div>
<div><br></div><div>The patch looks fine except that there doesn't seem to be a test for the parsing of the configuration option. That should also be done in unittests/Format/FormatTests.cpp along with the tests for parsing all the other options. Do you have commit access or should I submit this patch for you?</div>
<div><br></div><div>Cheers,<br>Daniel</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chris<br>
<div class="HOEnZb"><div class="h5"><br>
On Sun, Oct 27, 2013 at 4:32 AM, Daniel Jasper <<a href="mailto:djasper@google.com" class="cremed">djasper@google.com</a>> wrote:<br>
> The patch itself looks fine. However, I am also slightly skeptical that it<br>
> is a good general direction.<br>
><br>
> Specifically:<br>
> - SpaceInEmptyAngles: Quite frankly, it doesn't matter enough. Nobody really<br>
> cares (or should care about this). I'd make a decision and get on with life.<br>
> If you need that space for your codebase, make it dependent on<br>
> SpacesInAngles.<br>
> - SpaceAfterTemplateKeyword: Same as above, it doesn't matter enough. We<br>
> actually had a discussion about this very early into the clang-format<br>
> development. People don't agree, but it really does not matter (no version<br>
> is more or less readable, ..). We then actually went ahead (IIRC) to change<br>
> all instances in the C++11 standard to do exactly what clang-format does<br>
> now. I'd rather have clang-format force people into a consistent behavior<br>
> for such non-issues than add additional technical complexity to it.<br>
> - SpacesInAngles: I would personally be appalled by having to work in a<br>
> codebase that uses this. Constructs like "template < class T..." simply look<br>
> too much like comparisons to me. However, I can see that, if you are used to<br>
> it, switching might be hard. The overlapping of the language standard is<br>
> unfortunate, but I don't really see what we can do here.<br>
><br>
> So, I am more or less fine with introducing SpacesInAngles (goes well with<br>
> SpacesInParentheses), but I'd rather not introduce the other two (I know<br>
> that we have SpaceInEmptyParentheses - I also don't like that one, but "()"<br>
> is way more common than "<>", so it matters a bit more).<br>
><br>
> I also agree that, at the very least, we need some grouping of the options<br>
> soon. I have not found a way to specify style options more intuitively. And<br>
> to some extend, I think people having to carefully look through the options<br>
> or accept a default is reasonable.<br>
><br>
> Cheers,<br>
> Daniel<br>
><br>
><br>
> On Fri, Oct 25, 2013 at 11:26 PM, Sean Silva <<a href="mailto:silvas@purdue.edu" class="cremed">silvas@purdue.edu</a>> wrote:<br>
>><br>
>><br>
>><br>
>><br>
>> On Fri, Oct 25, 2013 at 4:00 PM, Christopher Olsen <<a href="mailto:chrisaolsen@gmail.com" class="cremed">chrisaolsen@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> I am evaluating clang-format and need control over spacing in template<br>
>>> argument lists to conform to our coding standards.<br>
>>><br>
>>> I've attached a patch that adds new flags to control this spacing.<br>
>>> Unittests are also included.<br>
>>><br>
>>> - SpacesInAngles - A<int> vs A< int ><br>
>>> - SpaceInEmptyAngles - template <> vs template < ><br>
>>> - SpaceAfterTemplateKeyword - template<typename T> vs template <typename<br>
>>> T><br>
>>><br>
>>> Note that LanguageStandard=Cpp03 overrides SpacesInAngles=false in the<br>
>>> case of '>>' as in A<A<int> ><br>
>>><br>
>>> Please let me know if there is anything I need to fix for submission.<br>
>><br>
>><br>
>> I foresee (and have already run into multiple real use cases) where the<br>
>> spacing before, after, in between, etc. of many different kinds of tokens<br>
>> needs to be tweaked. For example:<br>
>><br>
>> * multiplicative operators don't have spaces, but additive operators do `a<br>
>> + b*c`<br>
>> * spaces before parenthesized lists in function calls `foo (bar)`<br>
>> * spaces inside the parentheses of an `if`: `if ( cond ) {`<br>
>> * "function-like" return: `return(3)`<br>
>><br>
>> I think we should try (though it may not be realistic) to integrate this<br>
>> functionality in a way that covers the different use cases and makes them<br>
>> interact in a consistent and understandable way; otherwise we will just end<br>
>> up growing a forest of not-easy-to-discover options that don't have very<br>
>> good coverage of the configuration space for the next project. For example,<br>
>> adapting clang-format to the OP's project coding standards requires adding 3<br>
>> new options; is there a realistic upper bound on the number of such options<br>
>> that we will need in order for clang-format to support, say, 1000 different<br>
>> projects from 50 different companies/open-source communities?<br>
>><br>
>> One possibility that I can imagine (although I don't know how feasible it<br>
>> is) is to ship another tool (or more likely keep it under an option to<br>
>> clang-format) which does a "one time" analysis to determine a set of<br>
>> parameters that will conform with a given sample source file (or files) and<br>
>> emits a configuration file. This analysis could work with a larger (but very<br>
>> consistent and well-defined) "plumbing" configuration space that essentially<br>
>> parameterizes the "guts" of clang-format (such as `spaceRequiredBefore`,<br>
>> `spaceRequiredBetween`, `splitPenalty`, etc.) in a data-driven way.<br>
>><br>
>> On the other hand, I think it has been put out there before is that one of<br>
>> the benefits of clang-format is to help "standardize" to some extent on a<br>
>> common subset of style options, and so providing too-fine-grained support<br>
>> for "tweaking" the output might be undesirable from such a perspective. On<br>
>> the other hand, if clang-format wants to "dominate the world", it can't<br>
>> impose arbitrary changes on a project's coding style. A poignant question is<br>
>> "is it a goal for clang-format be able to conform with<br>
>> more-or-less-arbitrary styles without requiring requiring the users to get<br>
>> involved with clang-format development?", but I can't speak as to the<br>
>> answer.<br>
>><br>
>> Daniel, what do you think?<br>
>><br>
>> -- Sean Silva<br>
>><br>
>>><br>
>>><br>
>>> Thanks!<br>
>>> Chris<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> cfe-commits mailing list<br>
>>> <a href="mailto:cfe-commits@cs.uiuc.edu" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
>>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>>><br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>