Re: Exit(n) vs. goto
- Posted by kbochert at ix.netcom.com Feb 18, 2002
- 517 views
-------Phoenix-Boundary-07081998- Hi Derek Parnell, you wrote on 2/17/02 4:39:07 PM: >I too learned the value of consistant indentation sytle with C. I also now >always use braces >with >if/for/while statements. > > if (cond1) > { > if (cond2) > { > RtnA; > }; > } > else > { > RtnB; > } Just to be opinionated if (cond1) { if (cond2) { RtnA; } } else { RtnB; } Reasons: 1) Blank (or nearly blank) lines should be used as 'visual separators' to group related chunks of code. (Unless you are getting paid by the line, of course). One rarely wants to interrupt the reader just after an if clause starts. 2) To my view, the '{}' after if are part of the contents of the if clause, and deserve to be indented just like the other contents. 3) Nobody else does it this way (It must be better). Karl -------Phoenix-Boundary-07081998---