3 ms·
15 years doesn't mean anything if it makes you inflexible. One GOTO statement in the right context doesn't make code unreadable. Programmers have been drilled s
by crimsonalucard 12y ago
15 years doesn't mean anything if it makes you inflexible. One GOTO statement in the right context doesn't make code unreadable. Programmers have been drilled since school never to use GOTO but if someone finds a valid case for why to use it, you as a programmer should be flexible enough to change.
Clojure another language that doesn't support tail recursion optimization (TRO) uses an ugly language construct called (recur) to mimic TRO which is essentially identical to a GOTO, so I don't see what the big deal is.
In the end, anything that can be done with tail recursion can be done in a loop which is way more readable then either using a GOTO or recursion. Tail recursion is only required for strict functional languages.
- wtetzner 12y ago> In the end, anything that can be done with tail recursion can be done in a loop which is way more readable then either using a GOTO or recursion. The real value in TCO isn't a function recurring on itself, it's mutual recursion.
- crimsonalucard 12y agoNo, that is not the only case where it has value. TRO is a mandatory optimization for functional languages where recursion is the only possible looping construct. Haskell, Clojure, Erlang and Lisps rely on it heavily.
- wtetzner 12y agoSorry, I didn't mean it was the only value. It's the value that you get from it that you don't get from having loops.