[pulseaudio-discuss] Coding style question regarding curly braces

2011-01-20 Thread Tanu Kaskinen
Hi,

When reviewing code, should I complain about excessive curly brackets in
code like this?

if (foo) {
bar = 0;
}

Pulseaudio source code follows quite consistently the unwritten rule
that you shouldn't use curly braces unless necessary, so I was surprised
to notice that the unwritten rule was really unwritten (ie. not
mentioned in http://pulseaudio.org/wiki/CodingStyle). So, should I add
the rule to that page, or should I stop caring about this?

(As a personal preference, I actually would like to have excessive
curly braces, but even more than that I would like consistency.)

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Coding style question regarding curly braces

2011-01-20 Thread Arun Raghavan
On Thu, 2011-01-20 at 15:03 +0200, Tanu Kaskinen wrote:
 Hi,
 
 When reviewing code, should I complain about excessive curly brackets in
 code like this?
 
 if (foo) {
 bar = 0;
 }
 
 Pulseaudio source code follows quite consistently the unwritten rule
 that you shouldn't use curly braces unless necessary, so I was surprised
 to notice that the unwritten rule was really unwritten (ie. not
 mentioned in http://pulseaudio.org/wiki/CodingStyle). So, should I add
 the rule to that page, or should I stop caring about this?

I vote for making the convention explicit, but then I'm biased since I
prefer not putting braces around one-line conditionals. :)

Cheers,
Arun

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] Coding style question regarding curly braces

2011-01-20 Thread Colin Guthrie
'Twas brillig, and Arun Raghavan at 20/01/11 14:34 did gyre and gimble:
 On Thu, 2011-01-20 at 15:03 +0200, Tanu Kaskinen wrote:
 Hi,

 When reviewing code, should I complain about excessive curly brackets in
 code like this?

 if (foo) {
 bar = 0;
 }

 Pulseaudio source code follows quite consistently the unwritten rule
 that you shouldn't use curly braces unless necessary, so I was surprised
 to notice that the unwritten rule was really unwritten (ie. not
 mentioned in http://pulseaudio.org/wiki/CodingStyle). So, should I add
 the rule to that page, or should I stop caring about this?
 
 I vote for making the convention explicit, but then I'm biased since I
 prefer not putting braces around one-line conditionals. :)

My own personal taste is to only use braces when needed but if one part
of a logical block (if,else if,else) needs braces, then they should all
get them.

But Lennart always says he prefers compact code so the general rule is
to not use them unless needed.

This policy has led to at least one bug (in rtp stuff) related to an
else being matched against the wrong if, but the only policy that would
have mitigated that would be always use braces anyway, which at least
Lennart, Arun and myself don't like as a general rule.

So I would say: chuck a comment in on the CodingStyle page about
avoiding braces when possible, as per Lennart's general taste!

Col
-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss