(01-06-2016 07:23 PM)eried Wrote: (01-06-2016 05:28 AM)cyrille de brébisson Wrote: Hello
>Abuse of goto should be avoided, but it is sometimes much better to have a
>goto than complicated booleans that are required if goto are avoided.
>This is especially true for "implicit" gotos inside loops like break and continue
I use got every once in a while.
The numerical solver has a bunch of them because it was lifted verbatim from the HP48 code which is full of them, and I was unable to extract a clear structure.
An other use of goto is to exit a function in case of error when you have a number of finalization to do.
But, by far the most frequent use of goto is to exit a double (or more) deep loop. This happens all the time and is VERY frustrating to me.
This is why, in PPL, you can do break n; or continue n; (where n is an integer), which allows to break out of n level of loops. This reduces the number of legitimate goto use by at least 90%!
Cyrille
In my opinion when goto is used just to exit a loop, and not freely jump around in the code, it does not really represent the hated/demonic roots of the goto instruction; and this is totally acceptable. C# has goto/label to exit nested loops, similar to other languages that use break "label", etc.
But I am guessing toml is thinking on the other goto the one that makes possible to have certain state machine behavior without a clean design.
Since the BASIC programs I have to run on the Prime use GOTO for all sorts of branches, my interpreter must allow them also. As I said earlier, I don't use GOTO in my new programs but I have no control over what those other programmers did. I actually prefer ANSI/ISO Full BASIC which allows programs with no GOTOs at all but that BASIC won't run some of the old programs I need to run. Besides, the exercise of writing an interpreter in HPPL seems like it will be fun!
Tom L