« 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 8:20 PM, James Iry <jamesiry@...> wrote:

> Okay, some thought gave me a case where it makes a difference
>
> def foo(x : Boolean) : TailRec[Unit] = if(x) tailCall(foo(false)) else
> done(println("hello"))
>
> val x = foo(true)
>
> With either strict or c-b-n parameters on done "hello" isn't printed until
> you trampoline(x).  But...
>
> val y = foo(false)
>
Good catch! Do done must indeed be c-b-n.

Cheers

 -- Martin

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