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 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id E7A83BC69 for ; Sun, 22 Oct 2006 19:17:43 +0200 (CEST) Received: from sMtp.neuf.fr (sp604002mt.neufgp.fr [84.96.92.61]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id k9MHHhQG005655 for ; Sun, 22 Oct 2006 19:17:43 +0200 Received: from [192.168.144.3] ([84.5.234.181]) by sp604002mt.gpm.neuf.ld (Sun Java System Messaging Server 6.2-5.05 (built Feb 16 2006)) with ESMTP id <0J7J009QQRZBHT80@sp604002mt.gpm.neuf.ld> for caml-list@inria.fr; Sun, 22 Oct 2006 19:16:24 +0200 (CEST) Date: Sun, 22 Oct 2006 19:16:55 +0200 From: Christophe Raffalli Subject: Re: [Caml-list] try and tail call In-reply-to: <875c7e070610210803i5abf3b78j6e83c55c991f05cf@mail.gmail.com> To: Chris King Cc: Christophe Raffalli , caml-list@inria.fr Message-id: <453BA787.5090808@univ-savoie.fr> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 8BIT References: <453A27EB.8070609@univ-savoie.fr> <875c7e070610210803i5abf3b78j6e83c55c991f05cf@mail.gmail.com> User-Agent: Thunderbird 1.5.0.7 (Macintosh/20060909) X-Miltered: at discorde with ID 453BA7B7.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; christophe:01 raffalli:01 christophe:01 raffalli:01 univ-savoie:01 univ-savoie:01 ocamlopt:01 stack:01 rewriting:01 wrote:01 caml-list:01 tail:01 tail:01 closure:01 output:02 Chris King a écrit : > On 10/21/06, Christophe Raffalli wrote: >> >> consider this piece of code: >> >> (try >> let b = f a in >> (fun () -> g b) >> with >> (fun () -> h a)) () >> >> >> Is the call to "g" a tail call and is it omptimized as such ? > > Yes, it is, at least in the assembly code output by ocamlopt. (Neat > trick, btw.) > OK, but when g b is in fact a piece of code using a lot of values, it seems that the call is no more tail call and the stack keeps far to much values ... anyway, I am rewriting my code in a completely different (and better) way to avoid the problem ... but it would be nice to know exactly what call are tailcalls and what value are stored in closure in all cases. Christophe