From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id D315FBB81 for ; Fri, 2 Dec 2005 11:16:32 +0100 (CET) Received: from smtp2.syd.swiftdsl.com.au (smtp2.syd.swiftdsl.com.au [218.214.225.98]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id jB2AGUI8014398 for ; Fri, 2 Dec 2005 11:16:31 +0100 Received: (qmail 3722 invoked from network); 2 Dec 2005 10:16:44 -0000 Received: from unknown (HELO coltrane.mega-nerd.net) (218.214.64.136) by smtp2.syd.swiftdsl.com.au with SMTP; 2 Dec 2005 10:16:44 -0000 Received: from coltrane (localhost [127.0.0.1]) by coltrane.mega-nerd.net (Postfix) with SMTP id EA4B47B68 for ; Fri, 2 Dec 2005 21:16:27 +1100 (EST) Date: Fri, 2 Dec 2005 21:16:27 +1100 From: Erik de Castro Lopo To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Reporting on sucess/failure of tail recursion Message-Id: <20051202211627.128cbfc5.ocaml-erikd@mega-nerd.com> In-Reply-To: <55541.132.166.133.216.1133515788.squirrel@panel.lost-oasis.net> References: <20051202200957.2fb14d49.ocaml-erikd@mega-nerd.com> <55541.132.166.133.216.1133515788.squirrel@panel.lost-oasis.net> Organization: Erik Conspiracy Secret Labs X-Mailer: Sylpheed version 2.0.0 (GTK+ 2.6.10; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43901EFE.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 recursion:01 basile:01 recursive:01 rec:01 recursive:01 ocamlc:01 malloc:01 wrote:01 tail:01 tail:01 functions:01 functions:01 curr:01 curr:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 basile@starynkevitch.net wrote: > Functions are not tail-recursive, but function *calls* are (or not) > tail-recursive. I mean that a given function may have both tail > [-recursive] > and non-tail [-recursive] calls. Ok, so many recursive functions are actually written like: let fact n = let rec sub_fact curr acc = if curr > n then acc else sub_fact (curr + 1) (curr * acc) in sub_fact 1 1 with a no-recursive outer function and a tail recursive inner function. It would still be nice to know if the inner function is tail recursive. > Maybe what you are dreaming of is an extension of the -dtypes flag (to > ocamlc) Ooo, I didn't know about -dtypes. That might be useful. Thanks. Yes, something like -dtypes. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "That being done, all you have to do next is call free() slightly less often than malloc(). You may want to examine the Solaris system libraries for a particularly ambitious implementation of this technique." -- Eric O'Dell (comp.lang.dylan)