On May 13, 1:24 pm, Sylvain Le Gall <[email protected]> wrote:

> As you stated, converting non-tail recursive to tail recursive made the
> code a little more complex. Another argument is the expected number of
> recursive calls. If you know that you will have a limited number of
> call (e.g. 1024) and that non-tail recursive form is more clear, you
> should pick the non-tailrec.



I wrote my message too fast.

The point of the message was the performance of a compiled recursive
function.
I meant functions which you don't know anything in particular about:
so, for example, you can't assume a maximum number of iteration.

What I really want to know is: *is Ocaml compiler smart enough to
optimize a non-tail recursive function so that it run as fast as the
tail-recursive version of the same ?*

If the answer is yes, then rewriting functions as tail-recursive is
wasted time! (And in this case i will avoid to do it!).
If the answer is no, then i can still decide, case by case, if i
prefer an easier code or a faster one.

Hope I was clearer this time.

-- 
You received this message because you are subscribed to the Google Groups 
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html

Reply via email to