Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!decvax!gsg!lew From: lew@gsg.UUCP (Paul Lew) Newsgroups: comp.lang.c Subject: Re: Standard Indentation etc. Message-ID: <291@gsg.UUCP> Date: 19 Dec 88 17:07:44 GMT Reply-To: lew@gsg.UUCP (Paul Lew) Followup-To: comp.lang.c Organization: General Systems Group, Salem, NH Lines: 43 In article <1988Dec18.003828.27013@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: > >8 columns is just fine for people who split up their code into functions >instead of cramming it all into giant monolithic lumps. Don't view hitting >the right margin with 8-column indents as a sign of overly-big indents, >view it as a sign of overly-complex code that needs to be broken up. I >find that this is *almost* always the right view, in hindsight. ditto. Once a programmer changed his tab indentation to 4 spaces and guess what happen when he tried to print the file? Most of the terminals, serial printers I have seen use 8 spaces tabs. If you use 'ed' to edit a vi file with tabstop set to 4, you better make sure your terminal is wide enough. You can not show your file on your colleague's terminal with 8 spaces tabs without extra work, you may use "set tabstop=4" in vi, but how about other tools like grep, awk? All this is just a lot of inconvenience. I think more than 5 level of indentation is too much for a function, this way you can have your code easy to write and easy to maintain. 8 spaces tabs are just right for 80 columns CRTs. Another colleage edited all his files on Sun with 132 columns windows and this made it very hard for other people to edit his files on 80 columns CRTs. An easy solution is to change tabspaces when editing files with wide lines. One great indentation style I saw recently: do { ........... ........... } while (....); It looks fine until when someone view the file happen to have the line with 'while' displayed at the top of the screen. Conclusion: you can try to educate someone but you better prepare yourself to read like C parser. -- Paul Lew {oliveb,harvard,decvax}!gsg!lew (UUCP) General Systems Group, 5 Manor Parkway, Salem, NH 03079 (603) 893-1000