From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA31431 for caml-redistribution; Tue, 14 Dec 1999 18:26:29 +0100 (MET) 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 JAA20683 for ; Tue, 14 Dec 1999 09:20:39 +0100 (MET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id JAA13668; Tue, 14 Dec 1999 09:20:37 +0100 (MET) Received: (from xleroy@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA24437; Tue, 14 Dec 1999 09:20:35 +0100 (MET) Message-ID: <19991214092035.33700@pauillac.inria.fr> Date: Tue, 14 Dec 1999 09:20:35 +0100 From: Xavier Leroy To: Norman Ramsey , caml-list@inria.fr Cc: nr@labrador.eecs.harvard.edu Subject: Re: OCaml and tail recursion References: <199912131727.MAA20344@labrador.eecs.harvard.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1 In-Reply-To: <199912131727.MAA20344@labrador.eecs.harvard.edu>; from Norman Ramsey on Mon, Dec 13, 1999 at 12:27:37PM -0500 Sender: weis > I have just completed my first nontrival Caml program (an implementation > of the rsync algorithm) and I am distressed about the treatment of > tail calls. My code has to go through files one character at a time, > and as an SML programmer from way back, I wrote the code using three > mutually recursive functions that make tail calls to each other. > Imagine my surprise when I started getting errors with stack overflow! I'd like to see the code, since ocamlc performs tail calls, of course. (ocamlopt too, although on some platforms the tail-call optimization doesn't apply to calls with many arguments, e.g. 8 or more. But ocamlc has no such limitation.) - Xavier Leroy