Just an amateur C programmer looking for answers. My main inspirations for code style is K&R 2nd edition and I'm curious about the instructions in Plan 9's style(6) manual page (for reference, http://man.cat-v.org/plan_9/6/style). I've tried to think about the motivations, but not everything is as clear as it
seems.

Going through style(6):

no white space before opening braces.
no white space after the keywords `if', `for', `while', etc.

This is unique to Plan 9, it seems. I can't come up with a reason -- both BSD and Linux style use whitespace, and K&R does too, while Plan 9 doesn't. Why?

no braces around single-line blocks (e.g., `if', `for', and `while' bodies).

Apologies, but I'll have to Go and do it anyway :)

automatic variables (local variables inside a function) are never
initialized at declaration.

Why not? In order to reduce visual clutter? It seems like this should be handled
case-by-case: in some situations this just wastes lines:

        int foo;
        foo = 12;
        func("blah", &foo);

follow the standard idioms: use `x < 0' not `0 > x', etc.

I'm guessing this is for consistency and more common coincidence with the flow
of spoken language.

don't write `!strcmp' (nor `!memcmp', etc.) nor `if(memcmp(a, b, c))'; always explicitly compare the result of string or memory comparison with zero using a
relational operator.

Was that a common programmer error? cmp functions should return 0 if the
arguments are identical. Smells like disaster in baking!

and this is not an exhaustive list

Is there anything missing?

That's all. Thanks for your time.

Reply via email to