Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: Coding style



Hamish Moffatt <hamish@cloud.net.au> writes:

> On Mon, Nov 29, 2004 at 04:39:01AM +0100, Oliver Endriss wrote:
>> w-thiel@gmx.net wrote:
>> > if (something) {
>> > 	doit();
>> > } else {
>> > 	that();
>> > 	and_that();
>> > }
>> > IMHO, this is perfectly readable.
>> 
>> Anyway, I prefer something like this:
>> 
>> | if (something)
>> |	doit();
>> | else
>> | {
>> | 	that();
>> |	and_that();
>> | }
>
> I had this argument with a computer science prof when I was a student
> (a few years ago now). He argued for the former, I for the latter (with
> the braces on separate lines).
>
> His argument was that the braces are for the compiler's benefit only; a
> human gets the block structure by looking at the indenting instead.
> Lines just with opening/closing braces just spread out the code and mean
> you fit less code on-screen. He convinced me.

Someone at my university insisted on using this style:

if (something)                                                             {
    doit()                                                                 ;}
else                                                                       {
    that()                                                                 ;
    and_that()                                                             ;}

He didn't convince me, or anyone else, fortunately.

> I note that the Python guys have gone one step further and made the
> compiler follow the indents.

Insane.

> Braces around a single statement are good for safety (eg Perl requires
> them). Did you mean to say that the kernel guys don't allow it?

I can't find anything to that effect in Documentation/CodingStyle.

-- 
Måns Rullgård
mru@inprovide.com




Home | Main Index | Thread Index