logoalt Hacker News

ape4 • today at 3:38 AM • 3 replies • view on HN

Isn't this goto by another name! Aren't they considered harmful?


Replies

ogoffart • today at 6:45 AM

What's considered harmful is unstructured programming.

Historically, goto was used where we would now use function calls, or braced if/else statements. (early programming language didn't even have these constructs)

The famous "Go To Statement Considered Harmful" paper from Dijkstra was published before C was created. The "goto" from C and C++ is mostly fine.

Panzerschrek • today at 5:16 AM

Strictly-speaking just regular break/continue is also some sort of goto. But they are not so harmful compared to actual goto, since they transfer control flow out of a scope (from current loop iteration or from the entire loop) and thus don't allow skipping variable declarations.

account42 • today at 9:07 AM

Not as harmful as repeating soundbytes as dogma without understanding the reasoning behind them.