Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Thread safe heterogenous property lists (dictionaries)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-02-02 (13:36)
From: Alain Frisch <alain@f...>
Subject: Re: [Caml-list] Thread safe heterogenous property lists (dictionaries)
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 () = (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