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 6B7DBBC6B for ; Sat, 15 Dec 2007 16:19:47 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAADh/Y0fRVYC4nmdsb2JhbACQAgIBAQcEBimXRw X-IronPort-AV: E=Sophos;i="4.24,171,1196636400"; d="scan'208";a="20352740" Received: from fk-out-0910.google.com ([209.85.128.184]) by mail4-smtp-sop.national.inria.fr with ESMTP; 15 Dec 2007 16:19:47 +0100 Received: by fk-out-0910.google.com with SMTP id b27so555719fka.11 for ; Sat, 15 Dec 2007 07:19:45 -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=1EhyTQrv5DlPu2AjH2+71AI96eRd40QHIbu5RP8lEj4=; b=R/gY5eQLzEzB6+Ahm8bhzEHTqE8ji336Hw2oSOLdxuPB4jAOgSaezjPGCgaRQ+whOKMTJrK3zKZPUxPxVuTvtypqcq4JbEMcRkovAGALmDW1bxdFeXZjTtaMWjMHy73kOARxbMnk+wd98VUTVhFTs/AAXZTpZ4U8q7Wmo0NNWoc= 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=HLPaQNSfENCSPgrje2Zpn3N4Rt6yQVsipnGKut3YsiDOopPpmHBaW2+QdvIWW3wXRCnRnj4p3aBcRRjzd8K5CFwaTrV/vqJxHR9jNN3+MvvCRdaRY+WzFtvU7yjAEOi9Phh+bNDcPQVSvojON2ymmbYfUmrq+ffUHHSq5PQt2Nc= Received: by 10.82.158.12 with SMTP id g12mr923148bue.3.1197731985593; Sat, 15 Dec 2007 07:19:45 -0800 (PST) Received: by 10.82.154.16 with HTTP; Sat, 15 Dec 2007 07:19:45 -0800 (PST) Message-ID: <6cb897b30712150719p12652b76s9db6437f838e1e44@mail.gmail.com> Date: Sat, 15 Dec 2007 16:19:45 +0100 From: "Pierre-Evariste Dagand" To: oleg@pobox.com, caml-list@yquem.inria.fr Subject: Re: "Ref" and copy of functions In-Reply-To: <20071215120855.4A826AF01@Adric.metnet.fnmoc.navy.mil> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071215120855.4A826AF01@Adric.metnet.fnmoc.navy.mil> X-Spam: no; 0.00; mutable:01 lesson:98 functions:01 unsafe:01 emulate:01 unit:03 refs:04 perhaps:05 thread:06 clone:06 clone:06 function:08 function:08 rather:08 packaging:09 > If you like using the mutable state, (...) Now, I feel guilty to have used a Ref :-) One Ref for ~5000 lines of code, it's not so bad to me :-) (To be honnest, there are 8 Refs but 7 are used in order to emulate the Thread.kill function) > perhaps you might find the > following code helpful. The key idea is packaging the clone function > along with the arrow. There is no longer any need in any unsafe > features. The lesson from our tagless final APLAS paper is that many > things are significantly easier if we do the work at the production > site rather than at the consumption site. > > (* The first component is the arrow itself, the second one is the clone > function*) > type ('a,'b) arrow = {arrow: 'a -> 'b; clone: unit -> ('a,'b) arrow};; I see... It's disappointing of simplicity... Thanks ! -- Pierre-Evariste DAGAND