Visualization of every goto statement in the Linux 6.17 source code.Commentary from a 2003 linux-kernel mailing list discussion about the use of goto.Created...
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.
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.
Error handling and multi loop exiting are permitted use cases of go-to.
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.
It’s literally the only way to do this. Other ways include checking of loads of bools. That’s slow.
In C maybe. In language that support proper recursion schemes, the apomorphism models the early-exit loop.
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.
In civilized languages tail recursion takes care of this for you. 😁
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.
Oh, cool! I did not know that.