News for hackers. Stuff that matters.
Re:GOTOphobia Considered Harmful (In C) by lolinder on Monday February 27, 2023 @09:57AM (#34957129)
My point is that it's meaningless to make the argument that CONTINUE and BREAK can be implemented with GOTO, because every control flow structure can be. That you could use a GOTO to implement them isn't in question, what's in question is if you could do the reverse.

It's a subtyping problem, and you have the is-a relationship backwards: a cat is an animal but not every animal is a cat. GOTO is a BREAK (could always be substituted for one), but a BREAK is not a GOTO.

When you need a BREAK you could implement that in terms of GOTO, but no amount of coercion will allow you to use a BREAK as a generic GOTO.

Re:GOTOphobia Considered Harmful (In C) by bdowling on Monday February 27, 2023 @03:59PM (#34961770)
> GOTO is a BREAK (could always be substituted for one), but a BREAK is not a GOTO.

You wrote this backwards, but you seem to understand the relationship and that GOTO is more general. That is, every BREAK is a GOTO (because you can always substitute a GOTO), but every GOTO is not a BREAK (i.e., you can't substitute a BREAK for some GOTOs because BREAK cannot jump to an arbitrary label).

Re:GOTOphobia Considered Harmful (In C) by lolinder on Monday February 27, 2023 @04:17PM (#34961969)
No, I wrote it in exactly the order I wanted to. Because of the substitution property that you acknowledge, GOTO is a subtype of BREAK. BREAK is not a subtype of GOTO because it cannot always be substituted for GOTO. Thus, "GOTO is a BREAK, but a BREAK is not a GOTO."

A GOTO is just one possible implementation of BREAK, just as a cat is one possible implementation of an animal.

The practical impact of this is that it is incorrect to ascribe to BREAK the same weaknesses as GOTO, because BREAK is not a GOTO.

Re:GOTOphobia Considered Harmful (In C) by strangattractor on Tuesday February 28, 2023 @02:16PM (#34973519)
The moment I received a down vote for a simple opinion/observation about relieving naming overload and the similarities of BREAK and CONTINUE to GOTO I knew where this was going:)