[Info-vax] BASIC (and Horizon)
Dan Cross
cross at spitfire.i.gajendra.net
Wed Jan 31 20:26:12 EST 2024
In article <upejl0$1nkl5$1 at dont-email.me>,
Dave Froble <davef at tsoft-inc.com> wrote:
>I've seen code that did all kinds of confusing things, just avoid a GoTo branch.
> My question is, why? If the need is a simple and rather easy to understand
>branch, why get complex,
`goto` by itself is a sharp tool; sometimes incredibly useful,
but dangerous if misused. Our industry is littered with example
after example of `goto` misused. For instance,
https://dwheeler.com/essays/apple-goto-fail.html
Because of the potential and history of misuse, it's a laudable
goal to reduce use of `goto`, and indeed, over the years we've
seen generations of languages where the primary use cases have
been analyzed and the most useful lifted into new constructs
that become first-class parts of their respective languages;
`break` and `continue` for loops, exceptions, and so on.
Moreover, this is useful in the sense that programming languages
also serve a communicative purpose. How many of us would change
a `for` loop to if's and gotos given the choice? I wager few
would; the former communicates intent far more clearly than the
latter. For that matter, if we could iterate over a collection,
that's even better again.
That said, `goto` obviously _does_ have a place when used
judiciously. As Ken Thompson once said, "if you want to go
somewhere, goto is the best way to get there." Like all goals,
the desire to reduce `goto` prevelence is mostly aspirational.
Certainly, we're well past the context of Djikstra's "GO TO
STATEMENT CONSIDERED HARMFUL" CACM letter.
- Dan C.
More information about the Info-vax
mailing list