Message-ID: <006901bffda0$6ed7e2e0$0500007b@brk> From: "Johan Henriksson" To: Subject: Re: BREAKing out of a nested loop Date: Fri, 4 Aug 2000 01:10:29 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Reply-To: djgpp AT delorie DOT com >>>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."! Actually, I've been a basic programmer for a longer time that C-programmer. I ain't against basic. But it is quite crappy for anything except scripting (beats perl in nicest syntax) >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:-) Goto has it's uses. But is crap now with functions. >Back to the beginning: Name one reason against using goto. At least >name the law the forbids using goto. > >Come on, convince me! It's only a matter of opinion. You probably already know the argument. Goto usually makes code less readable. Not necesserely, of course. And yeah, then there's this sport in not using a goto anywhere :) In this case, using a return() had an advantage as well; The code should be in a function to make reuse possible. And then a return() can make a goto end;'s work.