« Return to Thread: Tail calls via trampolining and an explicit instruction

Re: Tail calls via trampolining and an explicit instruction

by Martin Odersky :: Rate this Message:

Reply to Author | View in Thread

On Wed, Nov 26, 2008 at 7:01 PM, James Iry <jamesiry@...> wrote:

> The phrase "tail call optimization" often confuses because it sounds like
> proponents primarily want things to be "faster" - after all speed is the
> most common target of optimizations.   But while faster is certainly nicer,
> what we really want from TCO is for things to not explode in the face of
> large or even infinite sequences of tail calls.   It's a space optimization
> rather than a time optimization.  In the right circumstances is optimizes
> O(n) memory stack usage to O(1).  That's often far more important than a
> mere constant factor loss in time performance.
>
> Hickey made an interesting choice.   He makes the user do the work to
> indicate when trampolining should be used.  That means the user gets to make
> the choice about the trade-offs involved.
>
> A variation in Scala
>
I only found out you had sent that now, James. It looks like your
solution and mine are pretty much equivalent.

Cheers

 -- Martin

 « Return to Thread: Tail calls via trampolining and an explicit instruction