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 JAA07393; Tue, 21 May 2002 09:46:17 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 JAA07434 for ; Tue, 21 May 2002 09:46:16 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g4L7kEX06965 for ; Tue, 21 May 2002 09:46:14 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id g4L7kAH69534 ; Tue, 21 May 2002 09:46:10 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id g4L7k9dT016479 ; Tue, 21 May 2002 09:46:09 +0200 (MET DST) Date: Tue, 21 May 2002 09:46:09 +0200 (MET DST) From: Alain Frisch To: John Max Skaller cc: caml-list@inria.fr Subject: Re: [Caml-list] Tail recursion detection In-Reply-To: <3CE84EFF.3090903@ozemail.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Mon, 20 May 2002, John Max Skaller wrote: > 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