3 ms·
It's funny how there's still a considered-harmful goto buried in the language, even though they don't call it that.
by _yosefk 11y ago
It's funny how there's still a considered-harmful goto buried in the language, even though they don't call it that.
- Alupis 11y ago> It's funny how there's still a considered-harmful goto buried in the language, even though they don't call it that. Not quite. GOTO allowed you to jump anywhere in the code, for any reason, at any time. Java's Label only really allows you to break out of a loop and jump to a label that was previously defined before that loop. It's mainly used for breaking out of a set of nested loops on some condition.
- pkolaczk 11y agoIt's also funny to sometimes see the same people who say goto is bad, use break and continue heavily in their loops. Which are only tad better than goto and often just as hard to read.
- kuschku 11y agoLoops in general are a problem. Tail-Recursive functions would be a far better solution. And almost every loop can be replaced with a simple map, fold, or filter.
- frik 11y agoRecursion can be expensive (call stack) depending on the language implementation. For example Lua 5.1 and recent JS implementations have a proper recursive tail call implementation. The Lua manual explains it: "Without proper tail calls, each user move would create a new stack level. After some number of moves, there would be a stack overflow. With proper tail calls, there is no limit to the number of moves that a user can make, because each move actually performs a goto to another function, not a conventional call." -- http://www.lua.org/pil/6.3.html http://www.lua.org/pil/6.3.html