Path: utzoo!attcan!uunet!samsung!umich!caen.engin.umich.edu!srvr1!chrisl From: chrisl@caen.engin.umich.edu (Chris Lang) Newsgroups: comp.lang.c Subject: Re: if (e1) return e2; [else] s1; Message-ID: <1990Mar25.222115.7161@caen.engin.umich.edu> Date: 25 Mar 90 22:21:00 GMT References: <887@dino.cs.iastate.edu> <7990006@hpopd.HP.COM> Sender: news@caen.engin.umich.edu (Mr. Usenet) Organization: University of Michigan Engineering, Ann Arbor Lines: 58 In article <7990006@hpopd.HP.COM> daves@hpopd.HP.COM (Dave Straker) writes: >However, Allman does this and is more consistent with single statement (no >braces) after the 'if' line, as it has the simple rule, 'after the 'if', indent >the following statement. It also allows the statements of a function to start >in column 1. Look what happens if you do this with K&R or Whitesmiths: > >int foo() >{ > >if (e1) >{ > s1; >} >} > >ouch! braces at the same level. 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? Thanks... -Chris > >Regards, > >Dave (brace yourself) Straker -- Chris Lang, University of Michigan, College of Engineering +1 313 763 1832 4622 Bursley, Ann Arbor, MI, 48109 chrisl@caen.engin.umich.edu WORK: National Center for Manufacturing Sciences, 900 Victors Way, Suite 226, Ann Arbor, MI, 48108 +1 313 995 0300 "I hate quotations. Tell me what you know." - Ralph Waldo Emerson