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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id F0907BB84 for ; Tue, 7 Oct 2008 01:16:15 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtMBAJg46khA6ba+jmdsb2JhbACBcU2QZT4BAQEBCQkMBw8FoyaGIgEC X-IronPort-AV: E=Sophos;i="4.33,369,1220220000"; d="scan'208";a="18329258" Received: from nf-out-0910.google.com ([64.233.182.190]) by mail1-smtp-roc.national.inria.fr with ESMTP; 07 Oct 2008 01:16:15 +0200 Received: by nf-out-0910.google.com with SMTP id b11so1372977nfh.13 for ; Mon, 06 Oct 2008 16:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:organization:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id:from; bh=Y7PK1fZH5x3y2nY7ny0E6HfEDybAqxzNNSuY7nui6MU=; b=C/qDuHhPEL7RxuwR7X7KnooK7Zy0gS86SaRWGzVsiXMOdSpYpUPffQJHqLJB5zZZGu 2ZbiDcJSCSWl37FTM4rcSijhTj8kGvWtDEwLjdA/1UZVE2N7dSX6LaiiM8T/KoevaH0w FMy3Y4H8FnTGaO/oTLEg5ZVOZO0jO7lsP0xcY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=organization:to:subject:date:user-agent:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id:from; b=S3PK9HiBm/8GsOJ2RBoXetUxBQ6cZD2Qs5zlHQRTZvStUALTKji5VBH7naFoUUUfk9 08MQtidWstufNhb4Rf1NTgKhE/NbmAdzBTy02tKFGzG2xxnV3SIcWc+Chz32YrUJlPp1 F6C5iFLqlqJTKjj4iJkj5asby9yz7xPCws5TM= Received: by 10.210.27.20 with SMTP id a20mr7070363eba.119.1223334975165; Mon, 06 Oct 2008 16:16:15 -0700 (PDT) Received: from leper.local (host86-139-250-145.range86-139.btcentralplus.com [86.139.250.145]) by mx.google.com with ESMTPS id j8sm13203809gvb.1.2008.10.06.16.16.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 06 Oct 2008 16:16:14 -0700 (PDT) Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: Metaprogramming features Date: Tue, 7 Oct 2008 01:17:13 +0100 User-Agent: KMail/1.9.9 References: <884069.59268.qm@web54601.mail.re2.yahoo.com> <200810061656.42903.jon@ffconsultancy.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810070117.13329.jon@ffconsultancy.com> From: Jon Harrop X-Spam: no; 0.00; gmane:01 staged:01 printf:01 printf:01 discrepancy:01 frog:98 wrote:01 wrote:01 caml-list:01 exceptions:01 int:01 int:01 caml:02 latter:03 let:03 On Monday 06 October 2008 17:46:49 Chung-chieh Shan wrote: > Jon Harrop wrote in article <200810061656.42903.jon@ffconsultancy.com> in gmane.comp.lang.caml.inria: > > Exactly. The difference is (only) the performance characteristics. > > To the contrary, that is not the only difference; the timing of > side effects (including non-termination and exceptions) can also be > different. We give an example at the beginning of our Section 2. I don't follow. Your paper translates the following staged function: let power7 : int -> int = .! . .~(Printf.printf "power\n"; power 7 ..)>.;; into this: let npower7 = (fun () -> fun x -> (printf "power\n"; npower 7 (fun () -> x)) ()) ();; and notes that the result is different because the former calls printf immediately whereas the latter defers. Surely the discrepancy is because the translation should be: let npower7 = let e = printf "power\n"; npower 7 (fun () -> x) in (fun () -> fun x -> e ()) ();; because escaped code is always evaluated before the brackets that surround it, so it needs to be hoisted out of the "fun () -> ..."? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e