Re: OCaml and tail recursion

From: Xavier Leroy (
Date: Tue Dec 14 1999 - 09:20:35 MET

Date: Tue, 14 Dec 1999 09:20:35 +0100
From: Xavier Leroy <>
To: Norman Ramsey <>,
Subject: Re: OCaml and tail recursion
In-Reply-To: <>; from Norman Ramsey on Mon, Dec 13, 1999 at 12:27:37PM -0500

> 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

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:29 MET