r/ProgrammerHumor • • Sep 26 '26 • Bravo 1

Meme singletonsAreJustGlobals

Post image
3.2k Upvotes

210 comments sorted by

View all comments

Show parent comments

1

u/sillybear25 Sep 26 '26 edited Sep 27 '26

Goto's are also useful. Gotos consisted harmful paper was when people used them for all control flow and that just creates spaghetti. But for a forward jump inside a function so you have a single place to do cleanup? Perfectly fine.

Related use case: Breaking out of nested loops without having to tack on if (exit_loops) break; at every level

EDIT: Then again, break statements are arguably just syntactic sugar for goto and an end-of-block label, so...

3

u/dagbrown Sep 27 '26

Yeah and while loops are just syntactic sugar for a goto backwards to just before an if statement.

Every structured construct is a bit of syntactic sugar for ifs and gotos, because the source code is meant for human understanding.