Re: Coding Style

John Cavan (johncavan@home.com)
Fri, 19 Jan 2001 20:26:01 -0500


David Ford wrote:
> > One other thing. Allot of people neglect to brace a statement if
> > it has a single line body. This is VERY bad, always brace your
> > statements....
> >
> > if (x = 1)
> > if (y = 2)
> > if (z = 3)
> > for (i = 1; i < 10; i++)
> > if ....
> > switch (foo)
> > .....
> >
> > ...is really stupid. DON'T DO IT!
>
> No, it's really stupid to surround it with braces that aren't needed. The
> above is incredibly easy to read and incredibly easy to trace and debug.

"really stupid" is probably too harsh in both cases...

Anyways, he has a point here: clarity. When doing late night debugging,
your eyes are not going to be fooled as easily if the result of the
condition is braced. Whether you consider it important is a personal
taste, but it is also consistent with multi-line if statements, and when
rapidly scanning code consistency is very useful.

The rest of it, I generally agree with, except I like perl. :o) But,
just like working for a company, you follow the standards for the system
you're working on.

John

P.S. What's wrong with perl? Very useful language IMHO.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/