in reply to Tail Recursion in Perl

You can think of the overhead of recursion as either useless overhead or useful debugging information. As soon as someone implements tail recursion optimization, the output of caller becomes massively more confusing. If you further add the complexity of continuations, good luck producing something resembling a stack backtrace which is both accurate and comprehensible.

Personally I tend not to think of the overhead of recursion. If the algorithm is more clearly coded for me recursively, I just do it and worry about optimization later if I need to. (Later usually doesn't come.)

Replies are listed 'Best First'.
Re: Re: Tail Recursion in Perl
by bsb (Priest) on Jan 02, 2004 at 01:07 UTC
    caller may already get a modified/optimized stack.

    Be aware that the optimizer might have optimized call frames away before "caller" had a chance to get the information. That means that caller(N) might not return information about the call frame you expect it do, for "N > 1".