When I wrote yacc, my first thought was to use goto's when implementing
the finite state machine that is the heart of the parser. That's how
FSM's work! I got the code written, but the C compiler complained and
wouldn't compile. It turned out that, while goto was implemented in C,
you could only have 10 of them! So I had to use a switch statement.
I also recently came upon one of my first C programs -- I wrote a "go
fish" game for my son as a practice in using the language. Reading the
code was most instructive:
1. I had used FOUR gotos! I can't remember the last time I wrote a
goto...
2. The program had a bug -- char being used as an int. Gave an
advantage to the player.
3. The game was surprisingly hard to beat. I had to add a "dumb me
down" flag because my kids never won.
I think the game was distributed in some of the early releases. At one
point, at a conference, the speaker accused the game of cheating! The
game was just very good at remembering that if the player had asked it
for a 6, and then it drew a 6 later, it would ask the player for 6
again.
On 2020-12-01 08:39, arnold(a)skeeve.com wrote:
> On Tue, Dec 1, 2020 at 8:39 AM
<arnold(a)skeeve.com> wrote:
> > It was recognized that goto was not necessary if one had proper control
> > structures in a language (if/else, while), and that code with no (or
> > minimal) gotos was easier to read and understand.