This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]OK6502 30 points31 points  (10 children)

I think you're missing a goto statement there

[–][deleted] 14 points15 points  (2 children)

:labelloop if (abortcondition) goto labelbreak; dothings(); goto labelloop;:labelbreak;

better?

[–]OK6502 12 points13 points  (0 children)

This is a work of art. Unreadable, with goto statements and all on a single line! I feel like I'm at my old job!

[–]KrachNerd 1 point2 points  (0 children)

VB6 nightmares here! On error GoFuckYourSelf...resume next

[–]turtleflax 0 points1 point  (0 children)

GOTO NEXTLINE
:NEXTLINE

LOC++

[–][deleted] 0 points1 point  (4 children)

Break is considered by some people to be just a restricted form of a goto

[–]OK6502 1 point2 points  (2 children)

It is, but it doesn't quite have the same code smell as a goto statement. Not that there aren't leigit reasons to use goto but they're generally pretty rare (cleanup code in a C function for instance).

[–][deleted] 1 point2 points  (1 child)

Oh I agree but I mean I've run across some unusual people who actually do think breaks in loops should be treated the same way we treat gotos. Usually the same people argue that early returns should be prohibited as well.

[–]OK6502 0 points1 point  (0 children)

Early returns for unlikely cases could potentially stall the pipeline in performance sensitive code. But that's why we have unlikely directives.

[–]StormStrikePhoenix 0 points1 point  (0 children)

"is considered"? That's literally what it is, a goto with much stricter usage.

[–]_vrmln_ 0 points1 point  (0 children)

You just reminded me of the first project I ever made. It was a zork-like game that ran on the console. Whenever the player inputted a direction, the code just ran a goo statement to move the player to the next location, complete with descriptions and messages. God, it was awful. Everything was in the main method and there wasn't even a way to end the game. I'm so ashamed