Path: utzoo!utgpu!watmath!clyde!att!ihlpb!gregg From: gregg@ihlpb.ATT.COM (Wonderly) Newsgroups: comp.unix.wizards Subject: Re: Latest indent request Message-ID: <9149@ihlpb.ATT.COM> Date: 6 Dec 88 15:55:10 GMT References: <9125@rpp386.Dallas.TX.US> Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 51 From article <9125@rpp386.Dallas.TX.US>, by jfh@rpp386.Dallas.TX.US (The Beach Bum): > In article <9063@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) writes: >>In any case, when modifying existing code we use the >>same style as in the existing code, whatever it may be (unless the >>code is totally misformatted, in which case we beautify it first). > > Here I agree 100%. One of our vendors uses the above mentioned > horrible bracketing style and as little white space as possible. > The first thing I do now is beautify the code. I don't even waste > time deciding if it is ugly or not. One of the most frustrating things for me is that so many people insist on using a mixture of spaces and tabs for indentation. It seems obvious that editors like vi(1) have commands like ":set tabs=4 sw=4" for some reason! How many vi(1) users know that '[[' and ']]' can be used to get to the top of the previous/current or next C function providing you follow the standard coding scheme and place the opening '{' at the beginning of the line? This is very handy while writing a C function. You get down into the middle of the function, and need a new variable so you say, "oh, better go declare 'foo' now". Just type "[[" while in command mode and back you go. Do the declaration, and then type "''" and you are back on the line that you were on before. WoW!!! The other thing is the use of bracing. PLEASE always use braces around any block that contains more than two lines. Just because for (i=1; i < MAXVAL; ++i) switch (foobar (i)) { case 1: case 2: case 40 jillion: } is legal doesn't mean you have to exploit the language just to be clever or lazy. I religously use the '%' command in vi(1) to skip over blocks of code that are not of any interest, and it greatly improves my productivity to not have to scroll over 100 lines just to get to the part that interests me. Those braces also make it easy to use ">%" and "<%" to alter block indentation to add or remove a flow control statement. And, yes I do always avoid using braces as part of the program just so that I don't confuse vi(1) (i.e. #define LBRC '{', #define RBRC '}' ). Your editor will help you program if you will just let it... -- It isn't the DREAM that NASA's missing... DOMAIN: gregg@ihlpb.att.com It's a direction! UUCP: att!ihlpb!gregg