<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 16, 2020 at 1:23 PM Chris Tetreault via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_5200866522542661053WordSection1">
<p class="MsoNormal">I used to agree with the “always put braces unless it fits on a single line” camp, but it turns out that it’s really hard to break in a debugger on
<span style="font-family:"Courier New"">`statement;` </span>if you write it <span style="font-family:"Courier New"">
`if (cond) statement;`</span></p>
<p class="MsoNormal"> </p>
<p class="MsoNormal">Personally, I’m in the “always put braces” camp. I think the many advantages to this approach have been stated by many people in this thread. The sole (that I’ve seen mentioned) disadvantage is “clutter”. However, I think in practice you
 learn to ignore the excess braces, especially since we write them like this:</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span style="font-family:"Courier New"">```</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">if (foo) {</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   bar;</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">} else if (baz) {</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">   quux;</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">}</span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">```</span></p>
</div></div></blockquote><div>Not that I'm advocating it, but the "omit braces" is most "powerful" when it removes lines of</div><div><span style="font-family:monospace">```</span></div><div><span style="font-family:monospace">      }<br></span></div><div><span style="font-family:monospace">    }</span></div><div><span style="font-family:monospace">  }</span></div><div><span style="font-family:monospace">```</span></div><br>I value the consistent use of braces though. Not only can my editor jump to the matching brace, but (this might sound paradoxical) it means I can be less distracted by braces. Without braces, I "focus" on the body and with braces I "focus" on the delimiters. I find needing to switch back and forth very distracting. Since we can't omit braces entirely, I'd rather we always used them.<br></div></div>