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 9EB6CBC69 for ; Sun, 16 Dec 2007 17:39:06 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAHLjZEfRVYC7imdsb2JhbACQBQIBCAQFKpd3 X-IronPort-AV: E=Sophos;i="4.24,174,1196636400"; d="scan'208";a="20374436" Received: from fk-out-0910.google.com ([209.85.128.187]) by mail4-smtp-sop.national.inria.fr with ESMTP; 16 Dec 2007 17:39:06 +0100 Received: by fk-out-0910.google.com with SMTP id b27so1317989fka.11 for ; Sun, 16 Dec 2007 08:39:05 -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=IBmQ/csjFOUI6aYFE+dZmuDuGNrZE9f/FBcK3EV+sc4=; b=A2670GH7OWcRTiKGrs1tNNhmNzEVaexehbD3eEkBofqGyRW0yYj2OMuFMRXt6oUR8fRkKZ40U6TjMjXdW8DfHeiGmj3cS+M30+Uw6e1PuC5WM2lD3lCKE0Nkyl6np+SZZjnMKhr1fXJAeLaQT+rpQ9gZJs9k/ZoYIq1ZIYu2AHY= 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=GeLAtGctkjjSERU6TJB6NOkdYcdDkBujgedfvJZ2bDCjUurSvrcmV8LgAxFJeRRWxduE/o6FpaIIoBw6x49mnQcg0WfyeAxtdCGODjQFFFCI47obbwaSKkvInt/2552ZijtCVEPukugpyUYlFZzWAg5hkqzz1q9yveK+sEMylxE= Received: by 10.82.116.15 with SMTP id o15mr14219553buc.13.1197823144796; Sun, 16 Dec 2007 08:39:04 -0800 (PST) Received: by 10.82.154.16 with HTTP; Sun, 16 Dec 2007 08:39:04 -0800 (PST) Message-ID: <6cb897b30712160839g1efb65d2j449e4e2b66b847a1@mail.gmail.com> Date: Sun, 16 Dec 2007 17:39:04 +0100 From: "Pierre-Evariste Dagand" To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] "Ref" and copy of functions In-Reply-To: <20071216.141725.55512483.garrigue@math.nagoya-u.ac.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6cb897b30712130927m7df88e3axec56eacba4d47fdf@mail.gmail.com> <20071216.141725.55512483.garrigue@math.nagoya-u.ac.jp> X-Spam: no; 0.00; oleg's:01 microseconds:01 microseconds:01 oleg's:01 combinators:01 0.75:98 0.74:98 caml-list:01 functions:01 unsafe:01 ens-cachan:01 cps:02 objects:02 objects:02 benchmark:04 > Here is yet another solution, using objects, which actually combines > Zheng's and Oleg's ideas. That is, it separates state and function, > but provides only access to state through a cloning method, so that it > is completely type safe. This is just what objects are good at! > > class ['a,'b] arrow (f : 'a -> 'b) = > object (self) method call = f method copy = self end Yet another nice solution I would never have imagined :-) And the performance is quite good : 1.428032 microseconds on my small benchmark (the unsafe Ref implantation takes 0.75 microseconds while the CPS implantation takes 2.7 microseconds). Nevertheless, I have carried out my benchmark on Oleg's implementation and find an impressive performance : 0.74 microseconds ! Now, I will re-write my combinators and see which style better suits my needs. Thanks, -- Pierre-Evariste DAGAND http://perso.eleves.bretagne.ens-cachan.fr/~dagand/