Increment Counters in declaration or in loop? (style question)

der Mouse mouse at thunder.mcrcim.mcgill.edu
Sun Jun 16 06:42:31 AEST 1991


In article <1991Jun14.034527.11467 at uvm.edu>, wollman at emily.uvm.edu (Garrett Wollman) writes:

> I do not understand why people [put multiple actions in a for loop].
> Perhaps it makes dealing with certain brain-damaged debuggers easier
> to have

> 	for(init; cond; action1,action2,action3);

> than

> 	init;
> 	while(cond) {
> 		action1;
> 		action2;
> 		action3;
> 	}

> It's a good obfuscatory technique, but I don't think anyone would
> disagree with me when I say that the latter is stylistically much
> better.

I would disagree with any such blanket statement.  First of all, they
have different semantics when a continue statement is present in the
body of the loop.  Second, when the actions are all directly
loop-related, the first is conceptually more coherent, and if they're
short, often more readable.  (This is not to say that the latter is
never preferable; I would disagree equally with *that* blanket
assertion.)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse at larry.mcrcim.mcgill.edu



More information about the Comp.lang.c mailing list