Plan 9 Coding Conventions for C
plan9.bell-labs.com
Plan 9 Coding Conventions for C
1–10 of 68 posts
Re: Plan 9 Coding Conventions for C
#2don't use // comments; some old Plan 9 code does, but we're converting it as we touch it. We do sometimes use // to comment–out a few lines of code.
Doesn't make sense with any decent editor, you ought to comment via macros.
no braces around single–line blocks (e.g., if, for, and while bodies)
I kind of like enforcing the opposite (always use braces).
Otherwise you end up with things like:
if (statement)
one; two;Re: Plan 9 Coding Conventions for C
#3Re: Plan 9 Coding Conventions for C
#4Re: Plan 9 Coding Conventions for C
#5eg: http://plan9.bell-labs.com/sources/plan9/sys/src/cmd/ramfs.c
int needfid[] = {
[Tversion] 0,
[Tflush] 0,
[Tauth] 0,
syntax means? Is this some Plan 9 extension, or is it just something I've never encountered?EDIT: I guess the value in the []'s is the array index to set the value of.
Re: Plan 9 Coding Conventions for C
#6I appreciate that these are old rules, nevertheless, I have the following comments: don't use // comments; some old Plan 9 code does, but we're converting it as we touch it. We do sometimes use // to comment–out a few lines of code. Doesn't make sense with any decent editor, you ought to comment via macros. no braces around single–line blocks (e.g., if, for, and while bodies) I kind of like enforcing the opposite (al…
Not sure I follow you on the one; two; example. Why would you have two statements per line in the first place? (You do realize that the "two;" isn't in the if block, right?)
Re: Plan 9 Coding Conventions for C
#7I appreciate that these are old rules, nevertheless, I have the following comments: don't use // comments; some old Plan 9 code does, but we're converting it as we touch it. We do sometimes use // to comment–out a few lines of code. Doesn't make sense with any decent editor, you ought to comment via macros. no braces around single–line blocks (e.g., if, for, and while bodies) I kind of like enforcing the opposite (al…
Re: Plan 9 Coding Conventions for C
#8That sounds odd
Re: Plan 9 Coding Conventions for C
#9https://github.com/tcltk/tcl/blob/master/generic/tclConfig.c
Although I think arguing for less uppercase/camelcase would not be entirely out of place. Still though, it's very nice to read.
Re: Plan 9 Coding Conventions for C
#10I appreciate that these are old rules, nevertheless, I have the following comments: don't use // comments; some old Plan 9 code does, but we're converting it as we touch it. We do sometimes use // to comment–out a few lines of code. Doesn't make sense with any decent editor, you ought to comment via macros. no braces around single–line blocks (e.g., if, for, and while bodies) I kind of like enforcing the opposite (al…
if (statement)
// one;
two;