Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
try and tail call
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-22 (17:17)
From: Christophe Raffalli <Christophe.Raffalli@u...>
Subject: Re: [Caml-list] try and tail call
Chris King a écrit :
> On 10/21/06, Christophe Raffalli <> wrote:
>> consider this piece of code:
>>   (try
>>     let b = f a in
>>     (fun () -> g b)
>>   with
>>     (fun () -> h a)) ()
>> Is the call to "g" a tail call and is it omptimized as such ?
> Yes, it is, at least in the assembly code output by ocamlopt.  (Neat
> trick, btw.)
OK, but when g b is in fact a piece of code using a lot of values, it 
seems that the call is no more tail call and
the stack keeps far to much values ... anyway, I am rewriting my code in 
a completely different (and better) way to avoid the problem ...
but it would be nice to know exactly what call are tailcalls and what 
value are stored in closure in all cases.