[llvm-dev] Codifying our Brace rules-

Jay Foad via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 23 01:46:31 PDT 2020


On Tue, 23 Jun 2020 at 03:30, 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).

I really don't like the current wording. It reads like "Do X. However,
don't do X if ..." (where X is omit braces). I do not find this
unambiguous! And it makes me unsure how to interpret "to avoid
unnecessary line noise: did it really mean "omit the braces /if/ that
avoids unnecessary line noise"?

Jay.


More information about the llvm-dev mailing list