Version française
Home     About     Download     Resources     Contact us    
Browse thread
[ANN] OCaml-Java project: 1.0 release
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Till Varoquaux <till.varoquaux@g...>
Subject: Re: [Caml-list] [ANN] OCaml-Java project: 1.0 release
On Tue, May 27, 2008 at 8:01 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
> On Tuesday 27 May 2008 07:37:40 Till Varoquaux wrote:
>> On Tue, May 27, 2008 at 7:06 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
>> > 4. Are tail calls fully implemented and, if not, when exactly do they
>> > work?
>>
>> One cannot fully implement tail calls on the JVM: there's no such
>> thing as a goto or a tail call instruction.
>> Tail recursion can usually be done for cheap. The general requires
>> some expensive machinery (usually trampolines)
>
> What characteristics of tail calls cannot be implemented using trampolines?
>
Speed.

I am sure you are aware of this but trampolining is very expensive
[1]. A common trick to avoid using to much trampolining is to compile
the whole program in cps form (therefor all calls are tail calls) and
unwind the whole stack when we are about to overflow [2]

Till

[1] Tail call elimination on the Java Virtual Machine
[2] CONS Should Not CONS Its Arguments, Part II: Cheney on the M.T.A.
> --
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/products/?e
>
Tail call elimination on the Java Virtual Machine


-- 
http://till-varoquaux.blogspot.com/