Any event where there's a twin loop (loop within a loop) that needs to be broken out of entirely is another common case too. Breaking only the first loop usually requires another condition of similar nature being placed elsewhere to break fully, increasing the surface area of mistakes with a future update.
The litmus test should be if clarity is increased or decreased relative to other forms. e.g. replacing if/else branching with goto statements would be difficult to read and audit.
Sent with Proton Mail secure email.
On Saturday, November 2nd, 2024 at 2:46 PM, Hendrik Boom <hendrik@???> wrote:
> On Fri, Nov 01, 2024 at 05:39:43PM -0600, Bob Proulx via Dng wrote:
> ...
>
> > I have always
> > considered goto to be a keyword of the damned but this causes me to
> > stop and think and consider that maybe I have been too harsh when it
> > is used appropriately.
>
>
> In a parser generator that I wrote in Pascal once, I had a very complicated
> search operation that had to recursively wander around the incomplete LR automaton
> to do lookahead calculation. And there were two independent sets of hested searches
> -- one which had to find sometning satisfyig particular constraints,
> and another, nested one that had to search something else. in prder to validate
> what the first (outer) one tentatively found.
>
> When a search succeeded it would set a global variable to indicate what had been
> found and simply do a GO TO to get out of the entire recursive nest.
>
> Very simple, efficient, and clear.
>
> When later (for whatever reason) converting this to Modula 3, which did not
> have such exiting GOTOs, I had to make all those intermediate recursive functions
> return and test success/failure return codes -- a much more error-prone activity.
>
> I might add that these GOTOs were not there to handle error conditions.
> They were success condition.
>
> I initially tried to use Modula 3's exceptions to implement these successes,
> but thsy did not have enough precision to get to the exact right level in the
> recursion. A GOTO to a syntactically nonlocal label was exactly the right tool.
>
> -- hendrik
> _______________________________________________
> Dng mailing list
> Dng@???
> Manage your subscription: https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
> Archive: https://lists.dyne.org/lurker/list/dng.en.html