in reply to Re: Re: Re: Iterative vs Recursive Processes
in thread Iterative vs Recursive Processes

For tail-recursion I'm not sure what intermediate results you would ever need to recreate? Maybe it's just the time of day, but I can't off the top my head think of any way to get at that information in current perl.

Let me take a simple example:

sub factorial { my $n = shift; my $mult = @_ ? shift : 1; return $mult if $n < 2; return factorial($n - 1, $mult * $n); }

Ah, now I see the problem: I had forgotten about the 'invisible' caller() arguments, @DB::args, which are used (for example) by Carp to show the parameters each subroutine was called with in a stack trace. Ok, scratch that approach. :)

Hugo