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 OAA09889; Thu, 26 Aug 2004 14:36:31 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA11326 for ; Thu, 26 Aug 2004 14:36:30 +0200 (MET DST) Received: from [128.93.8.158] (macaque.inria.fr [128.93.8.158]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id i7QCaUAk011781 for ; Thu, 26 Aug 2004 14:36:30 +0200 Mime-Version: 1.0 (Apple Message framework v619) In-Reply-To: <20040825195704.GA11359@red.seas.upenn.edu> References: <20040825195704.GA11359@red.seas.upenn.edu> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <8FA667D6-F75C-11D8-B0E6-00039310CAE8@inria.fr> Content-Transfer-Encoding: 7bit From: Damien Doligez Subject: Re: [Caml-list] strange tail recursion behavior by caml compiler Date: Thu, 26 Aug 2004 14:36:32 +0200 To: caml users X-Mailer: Apple Mail (2.619) X-Miltered: at nez-perce with ID 412DD94E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; damien:01 damien:01 caml-list:01 recursion:01 ted:99 compiler:01 compiler:01 million:98 caml:01 caml:01 bytecode:01 doligez:01 doligez:01 overflow:02 variant:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Aug 25, 2004, at 21:57, S. Ted Sandler wrote: > Here's a question to those who are "in the know" > about when the caml compiler eliminates tail-calls. > > I wrote the following tail-recursive function > "listbest", which is supposed to return the "best" > element of a list (where "best" is determined by the > behavior of the "compare_fn" that is passed as an > argument). [... 2 different versions of listbest ...] > The difference btwn these 2 defns doesn't seem like > one that should affect whether they are tail recursive, > does it? Thanks in advance for shedding light on this. I've just tried both versions of listbest on a list of 50 million elements, and got no stack overflow, either in bytecode or in native code. So I guess it's architecture-dependent and it's a variant of the old "not enough registers on a Pentium" problem. But how exactly, I don't know. -- Damien ------------------- 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