[deleted]
Re:PHP: why GOTO instead of recursion?
by crimsonalucard on Tuesday September 23, 2014 @01:01PM
(#8356405)
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.
Re:PHP: why GOTO instead of recursion?
by wtetzner on Tuesday September 23, 2014 @02:07PM
(#8356975)
> 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.
Re:PHP: why GOTO instead of recursion?
by crimsonalucard on Tuesday September 23, 2014 @06:32PM
(#8358762)
No, 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.