On 2023-12-30, Lawrence D'Oliveiro <
[email protected]d> wrote:
On Sat, 30 Dec 2023 17:17:07 -0300, Julieta Shem wrote:
Lawrence D'Oliveiro <[email protected]d> writes:
On Fri, 29 Dec 2023 23:22:53 -0300, Julieta Shem wrote:
Lawrence D'Oliveiro <[email protected]d> writes:
Arbitrary gotos:
-- useful/desirable? Not so.
Very useful, very desirable.
Come on ... you don’t mean you code that way, do you?
I do and, of course, I'm not the only one.
Knuth, Donald E. ``Structured programming with /go-to/ statements.''
ACM Computing Surveys (CSUR) 6.4 (1974): 261-301.
Frankly, I don’t know how realistic his examples were: all I can say is, dynamic memory allocation was a lot less common in his day.
Here’s my exposition on goto-free programming, and why it’s such a good idea: <https://gitlab.com/ldo/a_structured_discipline_of_programming/>.
There is a fundamental difference between goto and using control
structures. Control structures nest, and so they avoid producing
program control flow graphs that have certain undesirable properties,
which is not guaranteed with goto.
For instance control structures will not produce a graph that is
analogous to what we get from this:
if (condition_a) {
// ...
label:
statement;
// ...
}
if (condition_b) {
// ...
goto label;
}
The feature here is that we have a backwards branch, but it's not
exactly an ordinary backwards branch. A backwards branch normally goes
back to a node which was necessarily visited on the way to the branch.
The branch above goes to a node which is not necessarily reached
on the way to the goto. In fact, statement may be executing for
the first time when the "goto label" branch is taken.
If you banish gotos, you can guarantee to your compiler back-end
that you don't have these kinds of branches in the program graph.
All the backwards branches to to program nodes that dominate
the branch points. (Meaning that the branch points are not reachable in
the forward direction without traversing those backwards target points.)
The Red Dragon Book discusses this (1988 edition).
I think these kinds of odd backward gotos will also tend to
make the logic harder to follow.
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
[email protected]
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)