Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 from ihnp4 4.3bsd-beta 6/6/85; site chinet.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!chinet!rlk From: rlk@chinet.UUCP (Richard L. Klappal) Newsgroups: net.lang.c Subject: Re: C bites / programming style Message-ID: <177@chinet.UUCP> Date: Sat, 7-Sep-85 15:57:12 EDT Article-I.D.: chinet.177 Posted: Sat Sep 7 15:57:12 1985 Date-Received: Mon, 9-Sep-85 04:44:07 EDT References: <418@phri.UUCP> <700002@fthood> <209@3comvax.UUCP> Reply-To: rlk@chinet.UUCP (Richard L. Klappal) Distribution: net Organization: chi-net, Public Access UN*X, Chicago IL Lines: 64 In article <209@3comvax.UUCP> mikes@3comvax.UUCP (Mike Shannon) writes: > >With regard to changing > > if(condition) { | if(condition) > s1; into { > s2; | s1; > } | s2; > | } > >[the idea is to indent the braces so that they are in the same column as > the statements they enclose] > > Why do you like this style? This seems to indicate that >the braces are associated in your mind with the enclosed statements. > In my mind, the braces are associaed with the 'if' statment, and >so they should be indented at the same column as the 'if'. I look for >the closing brace in the same column to be a sort of 'statement terminator' >(i.e. when I see it, I think "Ah, the end of the if statement"). > I've seen this unusual indentation style before, and I'm curious >if you developed a preference for it in learning some other language? >For some reason, I find this style to be especially hard to read. Anybody >else feel the same way? >-- > Michael Shannon {ihnp4,hplabs}!oliveb!3comvax!mikes Personally, I use the second construct you illustrated only in PL/I, reason being that the list output from the compiler shows the indent level in this format, E.i.: b: if (cond) then c: do; c: stmts; c: end; b: more stmts; where the b:, c: represent the indent level. In C, the cb program outputs statements in the style of your first example, or (again my preference): if (cond) { stmts; } I generally try adapting my coding style to the debugging/style aids are available on the system/language I which I have to work. I may not agree entirely with the way those aids put things, but when I have to repair/update someone elses code, one pass thru the PrettyPrinter puts that code into my style. -- Richard Klappal UUCP: ..!ihnp4!chinet!uklpl!rlk | "Money is truthful. If a man MCIMail: rklappal | speaks of his honor, make him Compuserve: 74106,1021 | pay cash." USPS: 1 S 299 Danby Street | Villa Park IL 60181 | Lazarus Long TEL: (312) 620-4988 | (aka R. Heinlein) -------------------------------------------------------------------------