Re: Good Use of GOTO
- Posted by Jim Brown <jbrown105 at linuxbu?dhi?t.net> Jun 06, 2008
- 829 views
c.k.lester wrote: > > > but the following simpler version is at least twice as fast: > > As I suspected, there will probably always be a way to optimize code such > that GOTO is unnecessary /for speed/. Since euphoria turns loops into goto's in the backend anyways, this may hold true for the case where we can use a loop. I think Jeremy had some good examples of cases where one could not always rely on being able to do this. > > We must now consider other "good uses" of GOTO in Euphoria: > > 1. porting code from languages that use GOTO > 2. giving programmer's an extra tool to use if they want > 3. allowing improved structure (in rare cases) > > I think the strongest argument for GOTO is #1, but even that is diminished > with the integration of PCRE into the core, and the fact that code with GOTO > has been ported just fine by others in this forum. GOTO can be refactored > into structured code and still maintain its speed. PCRE was one example where goto was a make or break deal. It is probably not the only one. Rouge can be ported without using goto ok, but as we've already seen that's not always the case. > > #2 is not compelling because the same can be said about pointers, etc. Euphoria code can use pointers from C code just fine. It even provides the ability to use function pointers! > > Alas, there remains no good reason to include GOTO. You did not address #3. I do not think it is so rare, since the there is at least one major project that uses goto extensively, but in a way to make the code very well structured. Granted, its not written in Euphoria.