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-21 (14:00)
From: Christophe Raffalli <raffalli@u...>
Subject: try and tail call

consider this piece of code:

    let b = f a in
    (fun () -> g b)
    (fun () -> h a)) ()

Is the call to "g" a tail call and is it omptimized as such ?

If not, how to encode a feature like this one:

    ... (* the exception raised here are not handles by with but 
propagated *)

By the way I think this "try ... [end ...] with ..." syntax is usefull 
anyway because you have often a bug when
you write

  let b = f a in (* you know this may raise Not_found *)
  g b (* you assume wrongly that this can not raise Not_found *)
  Not_found -> h a

The unwanted capture of Not_found could be avoided with try ... end ... 
with ...

Christophe Raffalli