Putting cyrus-future code in CVS. Also, code style
Wesley Craig
wes at umich.edu
Mon Jun 28 20:55:57 EDT 2010
On 28 Jun 2010, at 18:21, Bron Gondwana wrote:
> Parantheses cuddle close
This is not how I write C (as you know...), tho I recognize that the
majority of Cyrus is written this way. I also "over space"
statements like:
HASH || DASH
because I've been burned trying to find cases where I meant the above
but had written:
HASH|DASH
> * braces are optional if meaning is clear
> if (foo)
> function();
> else
> other_function();
Personally, I always include the brace, with the exception of one-
liners, e.g.:
if ( foo ) goto blah;
and other one-liners. I've debugged many instances of (to use your
example):
if (foo)
function();
else
other_function();
added_by_someone_who_did_not_read_carefully();
which can be very hard to find, but reads nicely.
> * goto is permitted within a function only
As opposed to long jump? My rule for thumb for goto's is:
1) to the end of a function for cleanup
2) occasionally, to the top of a loop, but only if using another
control structure is *less* clear
> Anything else anyone want to add?
Lots, I'm sure, but nothing that would cause me to review the body of
Cyrus code and re-style it.
> * use "const char *" where possible.
While this is a fine idea, I don't think it's well practiced in the
Cyrus code base. Moving in this direction, over time, as code is
touched, is a nice idea.
> * RAII where possible.
Since C has no such concept, I assume you mean "goto (maybe several)
the end(s) of a function and clean up"? Or are you thinking of
constructor/destructor class stuff? Neither of these is well
practices in the Cyrus code base.
:wes
More information about the Cyrus-devel
mailing list