Message-Id: <4.3.2.7.0.20000803145250.00aa2310@mail.subdimension.com> X-Sender: matt DOT l AT mail DOT subdimension DOT com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Thu, 03 Aug 2000 14:57:29 -0700 To: djgpp AT delorie DOT com From: Matt Lewandowsky Subject: Re: BREAKing out of a nested loop In-Reply-To: <3989d7e4_1@news.uni-bielefeld.de> References: <005a01bffd43$030a3520$0500007b AT brk> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="--=---=-=-=--==-==---===-=----=--=---=---==-=-=-"; protocol="application/pgp-signature"; micalg=pgp-sha1 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk ----=---=-=-=--==-==---===-=----=--=---=---==-=-=- Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed One good reason to keep in mind: you may get into the habit of using it. And in C, it's a worse habit than BASIC. Let's say that you have an oft-used loop whose nesting make this one look simple. Let's say you want to break out of it simply. Lets say that you forgot there's a free() five levels out after this point. You use goto. See a potential problem? Wow. I've been reading too many "War On Drugs" propaganda items today, haven't I? Anyway, I *think* it's somewhat coherent... --Matt At 01:36 PM 8/3/00, you wrote: >djgpp AT delorie DOT com wrote: > >>Try 'goto'. You'll love it. They never taught you about it in > >>school. > > > >EEK! There are reasons for this! GoTo is "forbidden"! Nicer is to put this > >into a function > >that returns TRUE/FALSE. So, as soon as a collition is detected, you jump > >out of the > >function with false. This will break the loops. Might be considered cheating > >but it > >helps for making the code more usable so there is a good fix to this > >problem. > > > >Name just one of those reasons agains goto, other then "it looks like >BASIC and real hardcore C coders don't use that kiddy stuff."! > >I didn't yet see one solution in this thread, that was as easy to read >as a simple little goto. Checking a flag for every for, building the >whole nest in a function and return? Picture yourself reading that >code! Goto will also give you the benefit of feeling superior to the >moron who still uses goto after all this years:-) > >Back to the beginning: Name one reason against using goto. At least >name the law the forbids using goto. > >Come on, convince me! > > >-- > >Manni > >Life would be much easier if I had the source code. ----=---=-=-=--==-==---===-=----=--=---=---==-=-=- Content-Type: application/pgp-signature -----BEGIN PGP MESSAGE----- Version: PGPfreeware 6.5.3 for non-commercial use iQA/AwUBOYnqyOoMko8dOmunEQLjtgCfYL9cfMJroMXlStJUDL4/uboySIgAn0AK 3E5OXoPTn2hjHms6Wf1LdfDl =yvpG -----END PGP MESSAGE----- ----=---=-=-=--==-==---===-=----=--=---=---==-=-=---