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
[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.


Ram Bhamidipaty - 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?
>To unsubscribe, mail Archives:
>Bug reports: FAQ:
>Beginner's list:

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: