art@dinorah.wustl.edu (Arthur B. Smith) (03/27/90)
In article <1990Mar25.222115.7161@caen.engin.umich.edu> chrisl@caen.engin.umich.edu (Chris Lang) writes: > >That reminds me to ask, what about this, which is basically my style? > >void foo(struct spam *bar) > { > if (bar->bletch != NULL) > { > printf("Ve haf a bletch!\n"); > } /* if */ > else > { > bar->bletch = 6; > printf("We have one NOW!\n"); > } /* else */ > return; > } /* foo() */ > That is our style, also. We have found it VERY helpful. >The point I am most interested in is the indentation of the entire function, >including opening and closing braces. Does this strike people as possibly >confusing? I find it clearer, and consistant (ie, every sub-block gets >indented, as do its opening and closing braces). I feel the final /* foo () */ >makes it obvious that we're at the end of a function, not one level in... >but what do others feel? I agree. It makes the functions easier to find, too, since they are the only thing in column 0. -it's just an opinion- art smith (art@dinorah.wustl.edu or ...!uunet!wucs1!dinorah!art)
daves@hpopd.HP.COM (Dave Straker) (03/27/90)
>chrisl@caen.engin.umich.edu (Chris Lang) / 11:21 pm Mar 25, 1990 / > >That reminds me to ask, what about this, which is basically my style? > >void foo(struct spam *bar) > { > if (bar->bletch != NULL) > { > printf("Ve haf a bletch!\n"); > } /* if */ > else > { > bar->bletch = 6; > printf("We have one NOW!\n"); > } /* else */ > return; > } /* foo() */ > >The point I am most interested in is the indentation of the entire function, >including opening and closing braces. Does this strike people as possibly >confusing? I find it clearer, and consistant (ie, every sub-block gets >indented, as do its opening and closing braces). I feel the final /* foo () */ >makes it obvious that we're at the end of a function, not one level in... >but what do others feel? If it helps you, and doesn't upset others who read your code, then it's ok. Personally, I think it's a waste of an indent to indent the whole function. Commenting ends of long loops to allow the reader to match it up to the start is good, especially if the loop falls off the end of a page. I either start each function on a new page, and/or (v. small functions only) put a comment bar/block between functions, which makes commenting the end redundant. Also, if you have nice small functions (< 2 pages, preferably 1) it's clear enough anyway. Dave
mlandau@bbn.com (Matt Landau) (03/28/90)
Folks, let's PLEASE see if we can avoid yet another inifinitely long string of "Well, I use THIS style of indentation..." postings, shall we? This happens about every 6 months or so on comp.lang.c, because people don't realize that NO ONE REALLY CARES WHAT !(*$&@$%# STYLE OF INDENTATION YOU USE! It's not worth posting to the net!! Yours for a less cluttered, more informative comp.lang.c, -- Matt Landau Rebel without a clue. mlandau@bbn.com