Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!zaphod.mps.ohio-state.edu!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: <1990Mar24.010629.12764@caen.engin.umich.edu> Date: 24 Mar 90 01:06:00 GMT References: <887@dino.cs.iastate.edu> Sender: news@caen.engin.umich.edu (Mr. Usenet) Organization: University of Michigan Engineering, Ann Arbor Lines: 42 In article <887@dino.cs.iastate.edu> hascall@cs.iastate.edu (John Hascall) writes: > I'm not sure which of the above is better, but I am sort of > "stuck on" the following convention: > > if (e1) s1; \ > --or-- \ > if (e1) { | Does this seem reasonable? > s1; | (ignoring whether or not the `{' > } | belongs on the next line or not) > --but never-- | > if (e1) / > s1; / I'm probably not one to be talking about style, but... I agree. In fact, I go so far as to never use the first form (almost). I also like to spread things out a little more, so it looks more like: if (spam->flags | EATEN) { Barf(); } /* if */ else { OnlyGetQueasy(); } /* else */ The third form I never use, since I otherwise find myself forgetting to enclose 's1' in braces if I go back and add a second statement. (I will use it on rare occasions in long lists of if/elseif/else's where I am 99.9% sure I will not be adding any other statements, since otherwise they'd take up way too much much room, especially given my style of indentation and { placement...) OTOH, I change my style often enough that if you asked me this question six months from now, I'd probably vehemently criticize such a preposterous proposition. :-) -Chris -- 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