Parenthesis

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sat Dec 23 09:24:42 PST 2006


Steve Horne wrote:
> On Fri, 22 Dec 2006 15:49:22 -0600, Chris Nicholson-Sauls
> <ibisbasenji at gmail.com> wrote:
> 
>> Personally, I almost always write in the braces.  It just makes things so much simpler if 
>> I later need to go back and expand that statement body, or want to add debugging/temporary 
>> output or checks of some kind.
> 
> To me, redundant braces are extra clutter, making it harder to read
> the code. I used to always use them in the past, back when I was more
> Pascal-family-influenced than now, but over time I just got irritated
> with them. And leaving them out has never caused a problem.
> 
> The basic rule is that if I only drop the braces if the whole block
> statement is on a single line - a useful way to tidy up code, and
> something that can be done similarly in Pascal, but not really
> Modula-2 or Ada due to begin/end issues.
> 
> Of course the amount of clutter we're talking about from braces is a
> trivial issue. Just like adding in the braces when they are needed is
> a trivial issue.
> 
> Not that anything above should influence anyone one way or the other.
> The point is that both views are equally valid. There never will be a
> definitive right way.
> 

I can understand.  One of the few occasions where I leave them out is with things like:
# if (x) doThis();
# else   doAnother();

Particularly if debugging output or such doesn't make any sense in there.

And also like:
# foreach (i, inout x; arr) x = foo(i);

If any sensible debug output would typically come after the for*each anyway.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list