[cfe-dev] clang-format chromium ternary operator
Peter Kasting
pkasting at chromium.org
Tue Aug 13 11:29:11 PDT 2013
On Tue, Aug 13, 2013 at 4:37 AM, Daniel Jasper <djasper at google.com> wrote:
> On Tue, Aug 13, 2013 at 12:08 AM, Peter Kasting <pkasting at chromium.org>wrote:
>
>> "All the existing code does it another way" is a strong enough reason to
>> me.
>>
>
> It would be, but that is simply not the case. It is hard to come up with
> good numbers, but e.g. compare the numbers for ":" on the new and old lines:
>
>
> https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?.*%5Cn%5C%20*%5C:)%20-file:v8%20-file:usr/include%20lang:cc%20pcre:yes&all=1&sq=package:chromium&type=cs
>
>
> https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?%5Cn%7B0,1%7D.*%5C%20%5C:$)%20-file:v8%20-file:usr/include%20lang:cc%20pcre:yes&sq=package:chromium&type=cs&all=1
>
> I have tried to tune the regular expressions to include all cases where
> the conditional expression is broken around the ":". The result is about
> 400:1000 (this time excluding v8 and usr/include). Yes, it is a preference,
> but clang-format's style is far from unprecedented.
>
Two more tweaks your regex needs to make:
(1) Exclude third_party.
(2) Count the cases that break after '?' and _not_ around ':', i.e.
a ?
b : c;
When both of these are done, you have 260 results formatted your way versus
1282 formatted mine*.
To me this is compelling.
1) I don't want to flip-flop. You are the first Chromium developer to
> complain about this.
>
AFAIK based on mast chromium-dev mails, clang-format has not even worked on
Chromium code until comparatively recently, and is not an explicitly
encouraged part of our workflow. Certainly there are developers using it,
but I would be surprised if it was as much as even 20% of Chromium devs,
and most of them not for more than a couple of months.
I would not go so far as to concluded that no one has a positive opinion
about this style, but I don't think it's valid to conclude that "many
others like it" either.
PK
*Here are the actual regexes:
https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?.*%5Cn%5C%20*%5C:)%20-file:v8%20-file:usr/include%20-file:third_party%20lang:cc%20pcre:yes&sq=package:chromium&type=cs
vs.
https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?%5Cn%7B0,1%7D.*%5C%20%5C:$)%20-file:v8%20-file:usr/include%20-file:third_party%20lang:cc%20pcre:yes&sq=package:chromium&type=cs
+
https://code.google.com/p/chromium/codesearch#search/&q=(?m:%5C?%5Cn.*%5C%20%5C:.%2B$)%20-file:v8%20-file:usr/include%20-file:third_party%20lang:cc%20pcre:yes&sq=package:chromium&type=cs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130813/048c0782/attachment.html>
More information about the cfe-dev
mailing list