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.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 61FD1BC0A for ; Mon, 21 May 2007 15:04:43 +0200 (CEST) Received: from looneymail-a3.g.dreamhost.com (d071c805.dreamhost.com [208.113.200.5]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4LD4gXJ002198 for ; Mon, 21 May 2007 15:04:43 +0200 Received: from [192.168.101.113] (unknown [66.84.219.53]) by looneymail-a3.g.dreamhost.com (Postfix) with ESMTP id 351A927B5C for ; Mon, 21 May 2007 06:04:43 -0700 (PDT) Message-ID: <465198E5.3010004@SmokejumperIT.com> Date: Mon, 21 May 2007 08:04:37 -0500 From: Robert Fischer Organization: Smokejumper Consulting User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] tail rec References: <1179543365.26755.33.camel@rosella.wigram> <4651973F.9010503@janestcapital.com> In-Reply-To: <4651973F.9010503@janestcapital.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at discorde with ID 465198EA.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; recursion:01 recursive:01 recursion:01 recursive:01 tailcall:01 tailcall:01 rec:01 rec:01 caml-list:01 tail:01 tail:01 let:03 let:03 guess:04 brian:04 I'm with Brian on this, although it the "tailrec" specification needs to be optional. I use tail recursion by accident a lot when I'm coding ("Oh, hey, I guess this is tail recursive. Nifty!"), and I would be really annoyed to have to think about whether my recursion is tail recursive or not every time I use it. ~~ Robert. > > A better proposal would be one where the call itself is marked as a > tailcall, and bombs out if that call isn't. Maybe something like: > > let rec loop i s = > if i > 0 then > tailcall loop (i-1) (s+i) (* force this to be a tailcall *) > else s > in > let t = 2 * (loop n 0) in ... (* not a tail call, and that's OK *) > > At which point I'm neutral on the idea. The rules for what is or > isn't a tail call are not complicated. On the other hand, it's a > little bit of extra correctness for not much cost. > > Brian