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 NAA13834; Tue, 21 May 2002 13:36:04 +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 NAA13759 for ; Tue, 21 May 2002 13:36:03 +0200 (MET DST) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g4LBa2L03628 for ; Tue, 21 May 2002 13:36:02 +0200 (MET DST) Received: (qmail 29125 invoked by uid 0); 21 May 2002 11:36:00 -0000 Received: from c-134-104-31.k.dial.de.ignite.net (HELO laptop.gmx.net) (62.134.104.31) by mail.gmx.net (mp013-rz3) with SMTP; 21 May 2002 11:36:00 -0000 Message-Id: <5.1.0.14.0.20020521133108.01ff2ec0@pop.gmx.net> X-Sender: 9085902@pop.gmx.net X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Tue, 21 May 2002 13:35:19 +0200 To: Alain Frisch , John Max Skaller From: Benedikt Grundmann Subject: Re: [Caml-list] Tail recursion detection Cc: caml-list@inria.fr In-Reply-To: References: <3CE84EFF.3090903@ozemail.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk At 09:46 21.05.02 +0200, Alain Frisch wrote: >On Mon, 20 May 2002, John Max Skaller wrote: Maybe you want to have a look at scheme's r5rs (revised ... revised report ... scheme). After reading the section on tail calls it's obvious that they can be detected by simple pattern matching on the syntax. Good luck, Bene > > I'm in the process of writing a tail recursion detector for > > Felix, and many of the routines are tail recursive (heh!). > > However, in a few places, there are multi-way branches > > each of which terminate in identical tail calls: > > > > let rec f x y = match .. with > > | .. -> > > if .. then > > if .. then > > if .. then > > f x' y' > > else f x' y' > > else f x' y' > > else f x' y' > > .. > > >These would be tail calls even with different x' and y' ... > > > My question is: how smart is the Ocaml tail call detector? > >As far as I can tell, the detection is quite easy: just replace >during (some kind of intermediate) code generation any call followed >by a return with a tail call (after replacing any jump to a return >with the return). This is enough to detect tail call in your example. >Have a look at the OCaml bytecode generator, it is easy enough to get the >idea. > > >Does this answer your question ? > >-- Alain > >------------------- >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