From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id MAA16698; Sun, 31 Aug 2003 12:07:42 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA20763 for ; Sun, 31 Aug 2003 12:07:41 +0200 (MET DST) Received: from mta7.pltn13.pbi.net (mta7.pltn13.pbi.net [64.164.98.8]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7VA7ef24685 for ; Sun, 31 Aug 2003 12:07:40 +0200 (MET DST) Received: from pacbell.net (adsl-216-103-214-147.dsl.snfc21.pacbell.net [216.103.214.147]) by mta7.pltn13.pbi.net (8.12.9/8.12.3) with ESMTP id h7VA7cOA008685; Sun, 31 Aug 2003 03:07:38 -0700 (PDT) Message-ID: <3F51C89B.1070802@pacbell.net> Date: Sun, 31 Aug 2003 03:06:19 -0700 From: Warren Harris User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4a) Gecko/20030401 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Ram Bhamidipaty - ramb@sonic.net" <+caml+warren+a62ff5af68.ramb#sonic.net@spamgourmet.com> CC: caml-list@pauillac.inria.fr Subject: Re: [Caml-list] beginner question about tail recursion (caml: addressed to trusted sender for this address) References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Loop: caml-list@inria.fr X-Spam: no; 0.00; harris:01 pacbell:99 caml-list:01 recursion:01 recursion:01 overflowing:01 sonic:99 bug:01 faq:01 faq:01 beginner's:01 beginners:01 bin:01 compiler:01 caml-bugs:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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