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

Re: Can Perl do tail recursion?

Thread Previous | Thread Next
Ben Tilly
January 24, 2001 11:39
Re: Can Perl do tail recursion?
Message ID:
Mark-Jason Dominus <> wrote:
> > 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.
It may have been talked about, but I was not part of it.
> > 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
Sorry, I meant that I had hoped Perl would be able to
use this optimization and run quickly like a loop does.
But yes, memory usage is contained for me.   (Though a
friend who ran under 5.6.0 claimed it didn't for him, I
will have to test that tonight.)

Get your FREE download of MSN Explorer at

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