develooper Front page | perl.perl5.porters | Postings from January 2001

Re: Can Perl do tail recursion?

Thread Previous | Thread Next
Mark-Jason Dominus
January 24, 2001 11:24
Re: Can Perl do tail recursion?
Message ID:

> But the following example does
> not seem to show the hope-for speedup of tail recursion:

In any case, I'm pretty sure we have had this conversation already.
You don't get a time optimization because goto & has large overhead.  
See for example.

> The slowness then characteristic speedup as @_ shrinks
> indicates that tail recursion is not happening.  

It's not really clear what you mean by 'tail recursion is not
happening'.  The conclusion I would draw from this is that the goto-&
operation is copying or relocating the argument vector, or performing
some other operation that is O(n) in the size of the argument vector.
But the stack remains constant size, as you can see from a perl -Ds

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About