Re: Good Use of GOTO
- Posted by Jason Gade <jaygade at ?ahoo?com> Jun 06, 2008
- 844 views
Jeremy Cowgar wrote: > > Jason Gade wrote: > > > > Okay, so it's three functions. Here's the second: > > > > Hm, do you think the nested if's are easier to understand? The first using > goto > was much easier to understand and see the code flow, imho. > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> While I don't prefer goto, and will probably never use it (but never say never), I was taking this up for the challenge more than anything else. I don't see a clarity advantage in either one, really. The comment works as good as a label. Heck, my comment could have been "-- goto out" and it would probably have been more clear. I'm sure that someone else could improve upon my code without goto. I still can't believe I muffed the first one with the useless while... The interesting thing is how Jim's examples are progressive -- the first function has exactly one goto to one label which is easily replaced by an else statement. The second function has two gotos to one label which is again relatively easy and clear to replace, but not as much as the first. The third function has four gotos to two labels. Still working on it. Of course, I should be working on and testing 4.0 like I started to do last night... -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.