Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bi?po?d.com> May 28, 2008
- 778 views
Kat wrote: > > c.k.lester wrote: > > Maintainability of code is of utmost importance. Using goto is dangerous! :) > > Why are these two blocks so different that you call the 2nd one "dangerous" > ? Because in the first one we could get this ...
procedure foo() --- many lines of code --- goto next --- many lines of code --- goto next --- many lines of code --- for loop = 1 to x do -- code if x = blah then goto next end if -- code :next end for --- many lines of code --- goto next --- many lines of code --- end procedure
But I can't do that in the second example, and thus the cost of maintenance is lower in the second example. The cost is affected by the probability of bugs, the amount of code to read, and the amount of coding to repair/enhance existing code. > And how would you know how many places called "exit" to make the > code flow change? The problem is not the 'goto' statement (ie. change of control flow), the problem is with the label and how to arrive there. The extra maintenance cost that 'goto' introduces into a program must be offset by the performance benefit derived from using it, IMHO. Demonstrate that in a specific piece of Euphoria code and I'll support the use of 'goto' in that piece of code. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell