You can "optimise" out the stack frame in tail recursive code in perl5 using goto. E.g.:
sub fact { my($n, $a) = @_; return $a unless $n > 1; @_ = ($n-1, $n*$a); goto &fact; }
However, this is so wildly slow it's rarely worth the effort :-)
If perl6 doesn't manage to do tail-recursion optimisation I hope we at least get an efficient way to throw away a call-stack level so we can code it by hand.
In reply to Re^2: Recursion Alternatives?
by adrianh
in thread Recursion Alternatives?
by Cabrion
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |