Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] beginner question about tail recursion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warren Harris <wh232@p...>
Subject: Re: [Caml-list] beginner question about tail recursion (caml: addressed to trusted sender for this address)
Unless you're dealing with very long lists, or very deep data structures 
(or writing library code that might be used with long lists, etc), going 
to extra work to avoid tail recursion isn't worth it. Being properly 
tail recursive allows the compiler to make an optimization that keeps 
the stack from growing for each recursive call. Usually you can recurse 
quite a few times (thousands) before overflowing your stack is ever an 
issue in practice. I'm not saying that being properly tail recursive 
isn't important, but it's usually not the first thing you need to worry 
about when learning a new language.

Warren

Ram Bhamidipaty - ramb@sonic.net wrote:

>Hi I am just getting started with OCaml. My understanding is
>that it is desirable to write function in a tail recursive style.
>
>Can the OCaml system tell me if a function is tail recursive?
>
>-Ram
>
>-------------------
>To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
>Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
>Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>
>  
>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners