<div dir="ltr">On Sun, Aug 11, 2013 at 11:58 PM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This was decided to be the best way to go forward with Google's C++ style. I am reasonably certain that the style guide does not contain anything that says otherwise. The section you quote:<div>
a) applies to boolean expressions, which a conditional expression is not.</div>
<div>b) explicitly says that you can also wrap them to the new line.</div><div><br></div><div>If you find anything else in the style guide, please let me know, I am happy to get that changed.</div></div></blockquote><div>
<br></div><div>The Google style guide used to explicitly ban wrapping before an operator (not just a boolean operator, but any operator) rather than after. IIRC it no longer does so, but Chrome code generally dates from before this change and is very consistent about this wrapping, not just for ?:, but importantly for other operators as well (where we also need consistency).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>As for "This is not done in Chromium":<br></div>
<div><a href="https://code.google.com/p/chromium/codesearch#search/&q=%5E%5C%20*%5C?&all=1&sq=package:chromium&type=cs" target="_blank">https://code.google.com/p/chromium/codesearch#search/&q=%5E%5C%20*%5C?&all=1&sq=package:chromium&type=cs</a><br>
</div><div>and</div><div><a href="https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?.*%5Cn%5Cs*%5C:)%20pcre:yes&all=1&sq=package:chromium&type=cs" target="_blank">https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?.*%5Cn%5Cs*%5C:)%20pcre:yes&all=1&sq=package:chromium&type=cs</a></div>
</div></blockquote><div><br></div><div>Your search includes things like v8 and third_party, which have their own conventions and are not "Chromium" code. Restrict to Chromium code, and I suspect the ratio will change.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>The basic reasoning for going with the slightly less popular style is this very basic example:<br>
</div>
<div><br></div><div><font face="courier new, monospace">aaaaa ? bbbbb :</font></div><div><font face="courier new, monospace"> ccccc;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">aaaaa ? bbbbb</font></div>
<div><font face="courier new, monospace"> : ccccc;</font></div><div><br></div><div>Here, the second formatting looks more structured and is easier to grasp at first sight. If the operands get more complex, this gets even more obvious. And for consistency with that formatting, ? and : should both be wrapped to the new line where necessary.</div>
</div></blockquote><div><br></div><div>The Google style guide generally directs line wrapping to begin at a 4-space indent. Indenting even with something on a previous line is generally used for lines of function arguments. So the correct way of formatting the first example would be:</div>
<div><br></div><div><font face="courier new, monospace">aaaaa ? bbbbb :</font></div><div><font face="courier new, monospace"> ccccc;</font></div><div><br></div><div>...which is generally less appealing than</div><div><br>
</div><div><font face="courier new, monospace">aaaaa ?</font></div><div><font face="courier new, monospace"> bbbbb : ccccc;</font></div><div><br></div><div>...which is why most Chrome code that needs to linebreak these at all does it this way. Whereas your indenting is not only unusual for breaking before an operator, it's also unusual for indenting even.</div>
<div><br></div><div>Finally, regardless of all other arguments, and even ignoring the fact that the above codesearch links included code they shouldn't: there's a way of formatting these in Chromium code that is clearly more common even by a pessimistic search, and is clearly compliant with the style guide. Therefore, the auto-formatter for Chromium code should use this pattern. It doesn't matter if your way is legal or not, the most important rule in the whole style guide is "be consistent", which this does not do as well as it could.</div>
<div><br></div><div>PK </div></div></div></div>