81
submitted 2 months ago* (last edited 2 months ago) by ruffsl@programming.dev to c/programmer_humor@programming.dev
you are viewing a single comment's thread
view the rest of the comments
[-] Gladaed@feddit.org 15 points 2 months ago

Error handling and multi loop exiting are permitted use cases of go-to.

[-] bss03@infosec.pub 4 points 2 months ago

Java doesn't allow goto, but specifically does have labels for labeled break/continue to support the multi-loop exiting case.

I imagine these two "structures" will always be implemented in C source through disciplined use of goto.

[-] Gladaed@feddit.org 4 points 2 months ago

It's literally the only way to do this. Other ways include checking of loads of bools. That's slow.

[-] bss03@infosec.pub 3 points 2 months ago

In C maybe. In language that support proper recursion schemes, the apomorphism models the early-exit loop.

[-] ZILtoid1991@lemmy.world 3 points 2 months ago

I also use it for avoiding recursive function calls. In theory, this will tell the compiler to just ditch the current stack and go back to the beginning of the function.

[-] bitcrafter@programming.dev 8 points 2 months ago

In civilized languages tail recursion takes care of this for you. ๐Ÿ˜

[-] bss03@infosec.pub 5 points 2 months ago

gcc can do tail-call optimization in C, and sometimes in C++. It doesn't even have to be a recursive call, tho I do think it might depends on the calling convention.

[-] bitcrafter@programming.dev 3 points 2 months ago

Oh, cool! I did not know that.

this post was submitted on 07 Oct 2025
81 points (98.8% liked)

Programmer Humor

28098 readers
2024 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS