Xref: utzoo misc.misc:5930 comp.misc:5944 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!oliveb!sun!falk From: falk@sun.Eng.Sun.COM (Ed Falk) Newsgroups: misc.misc,comp.misc Subject: Re: The "evil" GOTO (Was: 25 Years of BASIC) Keywords: Guinness, phlegm, mackerel, intestines Message-ID: <103199@sun.Eng.Sun.COM> Date: 5 May 89 05:27:26 GMT References: <1791@ubu.warwick.UUCP> <1436@onion.reading.ac.uk> <24047@agate.BERKELEY.EDU> Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 27 In article <24047@agate.BERKELEY.EDU>, ked@garnet.berkeley.edu (Earl H. Kinmonth) writes: > > Second, why not > > while(1) { > fputs("Sex (m or f) ",stdout); > gets(ls); > if(ls[0] == 'm') return(ls[0]); > else > if(ls[0] == 'f') return(ls[0]); > } > > as a subroutine? YUK! This is getting worse and worse. A "return" is basicly a GOTO to the end of the function. Besides being nit-picky, there's a LOT of reasons not to put returns in the middle of code; you're sure to get bitten by that habit. Supposing you later come back and modify this function to allocate some resource and then free it at the end before returning. If you don't notice a return in the middle of your code, you start eating resources. -- -ed falk, sun microsystems sun!falk, falk@sun.com card-carrying ACLU member.