From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL,MAILTO_TO_SPAM_ADDR autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 4E965BC6B for ; Sat, 4 Aug 2007 14:16:44 +0200 (CEST) Received: from bsd4.nyct.net (mail-out8.nyct.net [216.139.141.8]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l74CGhlt025022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 4 Aug 2007 14:16:43 +0200 Received: from [192.168.42.2] (adsl-216-139-154-52.nyct.net [216.139.154.52]) by bsd4.nyct.net (8.13.4/8.13.4) with ESMTP id l74CGXsV095109; Sat, 4 Aug 2007 08:16:35 -0400 (EDT) (envelope-from bhurt@spnz.org) Date: Sat, 4 Aug 2007 08:27:20 -0400 (EDT) From: Brian Hurt X-X-Sender: bhurt@localhost To: tmp123@menta.net Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Warning on not-tail recursive functions In-Reply-To: <46B45BE3.9040403@menta.net> Message-ID: References: <46B45BE3.9040403@menta.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 46B46E2B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursive:01 ocamlopt:01 recursive:01 2007,:98 wrote:01 wrote:01 caml-list:01 functions:01 functions:01 tail:01 tail:01 expression:02 optimization:03 generally:04 wether:04 On Sat, 4 Aug 2007, tmp123@menta.net wrote: > Hello, > > Please, knows someone if "ocamlopt" can print a warning message when a > recursive function is not tail recursive, and code with the "jmp" > optimization has not been generated?. The problem is that I often write recursive functions which are not tail recursive, and that's OK. As an example, take a look at the join (or filter) functions I wrote in priority queue implementation in my previous email (subject line: "Sorted list"). They're not tail recursive, but since they only go O(log N) deep, that's not a problem. The rules for what is or is not tail recursive are pretty simple. Boiled down, they are: 1) The tail call must not be within a try expression 2) You can not do anything except return, uninspected and unmodified, the returned value from the call. Given that the rules are simple and local, I can generally just tell, by looking at the call, wether it's a tail call or not. Brian