From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 109B0BBAF for ; Tue, 2 Feb 2010 14:36:35 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuIDAKe4Z0vB/Bd4jmdsb2JhbACDM5gZAQEBAQkLCAkRBasxkB+BLYI+WgQ X-IronPort-AV: E=Sophos;i="4.49,390,1262559600"; d="scan'208";a="55156689" Received: from smtp-msa-out01.orange.fr ([193.252.23.120]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 Feb 2010 14:36:34 +0100 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 675EB1C001C8; Tue, 2 Feb 2010 14:36:34 +0100 (CET) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 53ED71C0025C; Tue, 2 Feb 2010 14:36:34 +0100 (CET) Received: from [192.168.1.53] (APuteaux-154-1-16-70.w83-199.abo.wanadoo.fr [83.199.17.70]) by mwinf5a04.orange.fr (SMTP Server) with ESMTP id 104031C00204; Tue, 2 Feb 2010 14:36:33 +0100 (CET) X-ME-UUID: 20100202133634666.104031C00204@mwinf5a04.orange.fr X-ME-User-Auth: lexifi Message-ID: <4B682A63.8010101@frisch.fr> Date: Tue, 02 Feb 2010 14:36:35 +0100 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 MIME-Version: 1.0 To: =?UTF-8?B?RGFuaWVsIELDvG56bGk=?= Cc: caml-list@inria.fr Subject: Re: [Caml-list] Thread safe heterogenous property lists (dictionaries) References: <91a3da521002020512v758849f0mdac3538abac44161@mail.gmail.com> In-Reply-To: <91a3da521002020512v758849f0mdac3538abac44161@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; frisch:01 frisch:01 logarithmic:01 fwiw:01 syntax:01 ocaml's:01 struct:01 wrote:01 exception:01 caml-list:01 alain:01 alain:01 ids:03 ids:03 module:03 On 02/02/2010 14:12, Daniel Bünzli wrote: > The second one uses Maps for logarithmic time lookups. Operations on > dictionaries are thread safe. However key creation is not because > unique ids need to be generated for them. FWIW, a thread-safe way to generate fresh ids is: let fresh_id () = Oo.id (object end) Also, the "perfect" solution you are referring to becomes in the syntax of OCaml's trunk: let embed () (type s) = let module M = struct exception E of s end in (fun x -> M.E x), (function M.E x -> Some x | _ -> None) -- Alain