Goto (2007)
41–50 of 207 posts
Re: Goto (2007)
#42At StackOverflow you're downvoted heavily when you just typ got (don't event have time for the last "o"). Then Apple comes with the glorious "goto fail" and shows that real companies use goto, and the problem wasn't "goto" itself.
Re: Goto (2007)
#43Coming from assembly language, I always found the anti-goto sentiment rather cute. A beautiful restriction, but ultimately arbitrary. Like writing poetry. Or those novels that do not ever use the letter "e". Why would an otherwise sane person write code with "rep" and without ever using "jmp"?
Re: Goto (2007)
#44void main() { goto http; printf("Hello world!"); http://www.hello-world.com }
Re: Goto (2007)
#45Earlier quoted context omitted.
goto is the idiomatic way to emulate RAII in C. It's everywhere.
Please explain a little more with an example. Certainly not in my C code, though I a huge fan of RAII in C++.
Btw that is a Cert C recommendation to use goto for RAII!
Take a look at the Linux kernel sometime, goto is everywhere there too https://www.kernel.org/doc/html/v4.10/process/coding-style.h...
Re: Goto (2007)
#46My favorite use of goto is with C#'s "yield return". The compiler converts a function with a yield command into a label. To resume a function from where it left off, the compiler adds code to test an added resumption-point variable and to goto the label for each resumption point.
Re: Goto (2007)
#47Earlier quoted context omitted.
goto is the idiomatic way to emulate RAII in C. It's everywhere.
Please explain a little more with an example. Certainly not in my C code, though I a huge fan of RAII in C++.
Re: Goto (2007)
#48I think the issue is only relevant when considering the years when programming languages began to have more nuanced instructions. For Assembly, goto is an essential construct and you'll learn how to use it reliably as jump conditions. For C, it's a great way to get out of nested code that you couldn't avoid for the given problem. For more high level languages, continue and break are the 'goto' statements and they're…
I have never liked continue or break. It always felt like I messed something up if I found myself needing them.
Re: Goto (2007)
#49Maybe "break;" should become a shortform for a generalized "break(1);" (= break one level) if we want to avoid using goto.
Perhaps this can be implemented by combining a macro with setjmmp() and longjmp() from the standard C library, without requiring a compiler change.
Re: Goto (2007)
#50Coming from assembly language, I always found the anti-goto sentiment rather cute. A beautiful restriction, but ultimately arbitrary. Like writing poetry. Or those novels that do not ever use the letter "e". Why would an otherwise sane person write code with "rep" and without ever using "jmp"?
Even in assembly there's position-dependent and position-independent code.