Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!mouse From: mouse@thunder.mcrcim.mcgill.edu (der Mouse) Newsgroups: comp.lang.c Subject: Re: Increment Counters in declaration or in loop? (style question) Message-ID: <1991Jun15.204231.4186@thunder.mcrcim.mcgill.edu> Date: 15 Jun 91 20:42:31 GMT References: <1991Jun14.034527.11467@uvm.edu> Organization: McGill Research Centre for Intelligent Machines Lines: 34 In article <1991Jun14.034527.11467@uvm.edu>, wollman@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@larry.mcrcim.mcgill.edu