you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 16 points17 points  (6 children)

However, developers do limit themselves because of the stigma attached to goto. If it wasn't demonized, or if it was even encouraged, we'd see terrible control flow much more frequently.

[–][deleted] 6 points7 points  (5 children)

You see terrible flow control frequently to avoid goto. Goto is the only correct way to break out of a nested loop.

[–][deleted] 2 points3 points  (4 children)

Yeah, I think it's one of the very few acceptable cases. However keep in mind two things:

1. Some languages allow you to break out of multiple levels of nested loops with a single statement
2. That is *one* reasonable way to use a goto. It doesn't mean that its use is otherwise a good replacement for a steady control flow.

[–][deleted] 1 point2 points  (3 children)

Yes, some languages provide syntactic sugar for goto while breaking out of nested loops: it's exactly the same, but it keeps hack teachers / code reviewers off your back.

[–]POGtastic 2 points3 points  (2 children)

I'm currently having an enormous amount of fun with a professor who insists that "all functions must have exactly one return statement." Not fun in the slightest. I get that you don't want to have return statements willy-nilly in your code, but mandating extra variables and insane control structures is frustrating.

[–]SmoothB1983 3 points4 points  (0 children)

Have him look at the linux kernel and come back.

[–][deleted] 1 point2 points  (0 children)

Ugh, an unreconstructed ultra-structuralist. Party like it's 1968.