httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: Minor(?) style questions
Date Tue, 12 Mar 2002 01:14:47 GMT
On Mon, Mar 11, 2002 at 11:55:07AM +0100, Sander Striker wrote:
> Hi,
> 
> Just checking if people have given this some thought before.
> And, maybe if there was something decided on this matter.  For
> instance, that this is free when it comes to style rules.

I think it is fine to make these consistent during your changes, but that
style rules on much of this isn't too important.

>...
> 1) Can we decide on a standard style when it comes to using
>    ++ or --?
> 
>    Example:
> 
>    lines++;
> 
>    vs.
> 
>    ++lines;

I prefer the latter. The first thing your eye sees is the increment, then
the variable. The *operation* is first, which is the most important.

>...
> 2) How should a do {} while look like?
> 
>    do {
>        ...
>    } while (...);
> 
>    or
> 
>    do {
>        ...
>    }
>    while (...);

If this isn't already in the style guide, then it should be, as the first
form. The control structure is matched with the block.

> 3) What is the preferred method of doing an infinite loop?
> 
>    while (1) {
>        ...
>    }
> 
>    or
> 
>    for (;;) {
>        ...
>    }

I prefer the former. The second form uses implicit rules about 'for', across
each of its three control components. Thus, you have to recognize the idiom
to quickly understand it, or take a small pause to process it. The while
form is also an idiom, but even simpler in construction.

As with Bill and Jeff, I'd put #2 into the style guide, and leave the others
out.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Mime
View raw message