3 ms·
Technically yes, all code eventually compiles to goto, or goto equivalents (simplifying slightly) However, the idea behind "goto considered harmful" is almost
by CJefferson 5y ago
Technically yes, all code eventually compiles to goto, or goto equivalents (simplifying slightly)
However, the idea behind "goto considered harmful" is almost all code can be written with function, loops and if/else statements and get just as efficient, and much, much easier to understand.
- kazinator 5y agoAll goto code can be mechanically translated into a network of mutually tail-calling functions arranged into an identically shaped call graph that is hardly easier to understand. What you can do with goto-based code is refactor it into a form that obeys certain conventions such that it is easy to mechanically translate to such a tail-call newtork, but then stop short of actually doing it. Then when reading the code, just pretend you're looking at function calls.