[TUHS] I can't drive 55: "GOTO considered harmful" 55th anniversary

Noel Chiappa jnc at mercury.lcs.mit.edu
Sat Mar 11 01:37:02 AEST 2023


    > From: "Ronald Natalie"

    > Multilevel breaks are as bad as goto with regard to structure violation.

In a way, you are right. There isn't really much difference between:

	for (mumble) {
		for (foobar) {
			do some stuff
			break-2;
			}
		}

and:

	for (mumble) {
		for (foobar) {
			do some stuff
			goto all_loops_done;
			}
		}
	all_loops_done:


The former is basically just 'syntactic sugar' for the latter.

I think the point is that goto's aren't necessarily _always_ bad, in and of
themselves; it's _how_, _where_ and _why_ one uses them. If one uses goto's
in a _structured_ way (oxymoronic as that sounds), to get around things that
are lacking in the language's flow-control, they're probably fine.

Then, of course, one gets into the usual shrubbery of 'but suppose someone
uses them in a way that's _not_ structured?' There's no fixing stupid, is my
response. Nested 'if/then/else' can be used to write comletely
incomprehensible code (I have an amusing story about that) - but that's not
an argument against nested 'if/then/else'.

As I've said before, the best sculpting tools in the world won't make a great
sculptor out of a ham-handed bozo.

	Noel



More information about the TUHS mailing list