Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!sun-barr!newstop!sun!amdahl!drivax!braun From: braun@drivax.UUCP (Kral) Newsgroups: comp.lang.c Subject: Re: if (e1) return e2; [else] s1; Message-ID: <1TWGXTN@drivax.UUCP> Date: 28 Mar 90 16:19:01 GMT References: <1990Mar24.010629.12764@caen.engin.umich.edu> <10624@alice.UUCP> <2637@quiche.cs.mcgill.ca> Organization: Digital Research, Inc. Lines: 25 In article <2637@quiche.cs.mcgill.ca> utility@quiche.cs.mcgill.ca (Ronald BODKIN) writes: >Is this reallly a clearer and neater way of coding: >int foo() >{ > int ret; > if (cond1) { > /* do stuff */ > ret=1; > } > else { > /* do other stuff */ > ret=2; > } > return ret; >} I say yes. In addition, it's easier to modify (say you want to do some further processing before you return), and it's easier to debug with a debugger, as there is only one place you have to break to stop the return. -- kral 408/647-6112 ...amdahl!drivax!braun "To surrender is to remain in the hands of barbarians for the rest of my life; To fight is to leave my bones exposed in the desert waste" - ancient chinese poem