develooper Front page | perl.perl5.porters | Postings from July 2013

Re: Using braces on 'if'; Was: Re: Asan help request

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
July 31, 2013 11:33
Subject:
Re: Using braces on 'if'; Was: Re: Asan help request
Message ID:
20130731113344.GU2177@iabyn.com
On Tue, Jul 30, 2013 at 06:56:14PM -0600, Karl Williamson wrote:
> On 07/25/2013 02:19 AM, Nicholas Clark wrote:
> >I don't think that using a comma operator in void context just to avoid
> >needing braces is really worth it. It doesn't feel like idiomatic C.
> 
> I agree, and I'd like to put in a plug for using braces.
> 
> The coding standards where I $worked called for always using braces
> when the 'then' clause was not on the same line as its 'if'.  The
> reason was bitter experience with maintenance safety.  It's too easy
> for someone to later come in and fail to notice the absence of
> braces, and turn this:
> 
> 	if (a)
> 	   b;
> 
> into
> 	if (a)
>            c;
>            b;

My own personal preference is no braces for a single statement, and that
seems to be generally what the core does. But I don't think  it should be
a rigid rule.

-- 
"Strange women lying in ponds distributing swords is no basis for a system
of government. Supreme executive power derives from a mandate from the
masses, not from some farcical aquatic ceremony."
    -- Dennis, "Monty Python and the Holy Grail"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About