C format

utzoo!decvax!minow utzoo!decvax!minow
Fri Oct 22 19:04:29 AEST 1982


A word or two of support for the "publication" indentation style:

	if (cond) {
	    subordinate statements;
	}

The '{' and '}' have little visual significance.  Placing them in different
parts of the line -- '}' is always the left-most graphic and '{' the
right-most on the line makes them more distinct.  Thus, I would reject
the format

	if (cond)
	{
	    subordinates;
	}

Note, also, that in the publication style, the '}' is aligned with the
keyword (if/while/for, etc.) that initiated the clause.  Putting '{'
directly under the keyword obscures the visual connection.

Finally, I would highly recommend the programmer enclosing all
subordinate statements with { }.  This makes the structure explicit,
doesn't bite you when you have to add another statement (or a debugging
printout), and avoids "dangling else" problems.

Oh yes, don't ever let me catch you writing a null body on the same line:

	for (sp = string; *sp != EOS; sp++);	/* WRONG	*/

always put the ';' on the next line:

	for (sp = string; *sp != EOS; sp++)
	    ;

Martin Minow
decvax!minow




More information about the Comp.lang.c mailing list