[llvm-dev] Codifying our Brace rules-

Nicolai Hähnle via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 23 02:00:20 PDT 2020


On Tue, Jun 23, 2020 at 4:30 AM Mehdi AMINI via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> On Mon, Jun 22, 2020 at 2:38 PM Steve Scalpone via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>
>> Me?  I would modify the first sentence from:
>>
>> > When writing the body of an if, else, or loop statement,
>> > omit the braces to avoid unnecessary line noise. However,
>> > braces should be used in cases where the omission of braces
>> > harm the readability and maintainability of the code.
>>
>> To be:
>>
>> > Braces are optional around the body of an if, else, or loop statement,
>> > except in cases where the omission of braces harm the readability and
>> > maintainability of the code.
>
>
> The current wording is more clear as it expresses unambiguously the preferred way of formatting the code. I don't see a benefit to this change of phrasing (on the opposite, I prefer less ambiguous).

The benefit of changing is, of course, that people don't actually
agree that what's currently written down is a good idea. In other
words, it is not clear that what is written down is actually the
preferred way of formatting.

I think what's written down today is good as "this is the minimum
amount of braces that should be used". However, there are large parts
of the code where braces are used in more places, using slightly
different stylistic preferences, and where reviewers (including
myself) suggest those additional braces.

Cheers,
Nicolai

-- 
Lerne, wie die Welt wirklich ist,
aber vergiss niemals, wie sie sein sollte.


More information about the llvm-dev mailing list