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=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 9EC2DBC6B for ; Fri, 14 Dec 2007 17:55:52 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAP1DYkdA6ba4kmdsb2JhbACQAwEBAQEHBAQTFpl1 X-IronPort-AV: E=Sophos;i="4.24,168,1196636400"; d="scan'208";a="20331254" Received: from nf-out-0910.google.com ([64.233.182.184]) by mail4-smtp-sop.national.inria.fr with ESMTP; 14 Dec 2007 17:55:52 +0100 Received: by nf-out-0910.google.com with SMTP id e27so945397nfd.13 for ; Fri, 14 Dec 2007 08:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=W3cz8q5VHMP1CWxgy2R7c0Fd/okCw1M5+52ud1F5Kcw=; b=bC6jiB5S82LZWutXQhzAUO8JPKDEIpQlWfDwp1C+iZyR71xREahiG/oBWE/B9sy6flg4rSN2A9u7ndFjVpi7EEUMycWquPlIRvDnp4X9wdqlv6pEMwjDv1GCRKOzQI+XOxuWsZvwBPX6pBeTJPcWzlyoyKtxR/DQYNjF98Km1Yw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TtsW1xR//EIfnh6vWSy3RU/tnyoBU7WqEiO0zofWL0MT2Xtf3S+6Ef5lCxlrQVyCN/Vd0taxtVVF+SU32zL22eoLiTuKi8oF18byZbvdDthJ07ax+/sWTY+4VFxkqloQWVekMUSlreoM7XwfJP/L4atp7NZaidMCBaaBMbi2/sU= Received: by 10.82.112.3 with SMTP id k3mr9551878buc.15.1197651351027; Fri, 14 Dec 2007 08:55:51 -0800 (PST) Received: by 10.82.154.16 with HTTP; Fri, 14 Dec 2007 08:55:50 -0800 (PST) Message-ID: <6cb897b30712140855m4c14ef70v73ebc1616ece8e69@mail.gmail.com> Date: Fri, 14 Dec 2007 17:55:50 +0100 From: "Pierre-Evariste Dagand" To: "Zheng Li" , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Re: "Ref" and copy of functions In-Reply-To: <87zlwdi7cf.fsf@pps.jussieu.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6cb897b30712130927m7df88e3axec56eacba4d47fdf@mail.gmail.com> <87d4t9k0uy.fsf@pps.jussieu.fr> <6cb897b30712140654v26a0ef96we6007c868d3d1829@mail.gmail.com> <87zlwdi7cf.fsf@pps.jussieu.fr> X-Spam: no; 0.00; mutation:01 ad-hoc:01 high-level:01 mutable:01 ocaml:01 existential:01 encode:01 caml-list:01 caml-list:01 functions:01 marshal:01 closure:01 closure:01 functional:02 cps:02 > I guess you won't be able to find such a solution. In the Ref-based > implementation, the result arrow type is stateful. You won't be able to > _implicitly_ copy a state _inside_ the language, otherwise first-class > continuation would already appear. That's why I asked this to the Caml-list : to find a black magic recipe :-) > Since the corresponding mechanics in Ref and CPS are mutation and > closure (de)construction, no wonder the former is faster. One ad-hoc > solution, if you only have to provide high-level functional API to > outside, is to make states explicit, like > > type ('a,'b) arrow = {mutable state: 'c; eval: 'c -> 'a -> 'b} > > This is not valid OCaml, since the 'c type is out of scope. You can > either encode it with existential type (which also involve closure > (de)construction, but I'm not sure about the cost). Or simply using > Obj.t instead of 'c as far as you won't expose it, at least it won't be > unsafer than Marshal and faster. This solution looks promising, I will look at it and see if it suits my needs. Thanks, -- Pierre-Evariste DAGAND