Path: utzoo!attcan!uunet!yale!wald-david From: wald-david@CS.YALE.EDU (david wald) Newsgroups: comp.lang.c Subject: Re: Standard Indentation etc. Message-ID: <45719@yale-celray.yale.UUCP> Date: 15 Dec 88 03:08:58 GMT References: <663@htsa.uucp> <832@husc6.harvard.edu> Sender: root@yale.UUCP Reply-To: wald-david@CS.YALE.EDU (david wald) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 77 In article <832@husc6.harvard.edu> geoff@harvard.harvard.edu (Geoff Clemm) writes: >To emphasize > 1. {} ARE NOISE FOR THE COMPILER - humans can see in 2d, and indentation > blocks give you everything that you need. ... > 3. Editing convenience is then the determining factor for how you place > your {}'s - put them in a way that minimizes numbers of keystrokes > and errors during creation and modification of code. > >> while (1) while (1){ >> { first; first; >> second(); second(); >> etc; etc; >> } } > >You have sacrificed editing convenience (i.e. being able to kill the line >containing "first;" without messing with brackets) in order to get bracket >column matching, which as Ritchie points out, is irrelevant. I consider the editing convenience minimal on any of the editors I use. That however is irrelevant to my style (see below). >If the compiler could read white space, you would just write : > > while (1) > first; > second(); > etc; > >As it is, you need to add brackets. The only place for the open bracket >is on the first line, and you have two choices for the closing bracket >(other than Ritchie's choice) : > > while (1) { while (1) { > first; first; > second(); second(); > etc; }/*while*/; etc; > }/*while*/; > >Note : the brackets DO NOT LINE UP, and it DOESN'T MATTER. Brackets are >for the compiler, and it doesn't care where they are. Indentation >blocks are for humans, and this bracket placement emphasizes the correct >2d blocks. Getting a bit imperious here, aren't we? "The only place?" As long as the compilers rely on the braces to determine blocks I will stick with my style: while(1) while(1) { { first; or, if things first; second(); are crowded, second(); etc; etc; } } I understand the points about editing convenience and elimination of errors. This method has none of those problems. However, with this method I no longer run the risk of missing that first { when I change from a block to a single statement or vice versa. This method also visually shows the matching braces, which I do consider helpful in reading. Yes, the indentation helps. Indentation plus well-placed braces helps more in complex structures. The only objection I've heard to this style is that there's "too much white space," and I simply don't agree that that's a problem. >Disclaimer : Like all sensible people, I agree that the important point >is to use a common style - what that style happesn to be is secondary. Of course. ============================================================================ David Wald wald-david@yale.UUCP waldave@yalevm.bitnet ============================================================================