From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA24349; Mon, 26 Jan 2004 14:27:14 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA24148 for ; Mon, 26 Jan 2004 14:27:12 +0100 (MET) Received: from inria.fr (macaque.inria.fr [128.93.8.158]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i0QDRBv09543; Mon, 26 Jan 2004 14:27:12 +0100 (MET) Date: Mon, 26 Jan 2004 14:27:46 +0100 Subject: Re: [Caml-list] sharing problem ... Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v553) Cc: ocaml ml To: Pietro Abate From: Damien Doligez In-Reply-To: <20040126104345.GA3978@pulp.anu.edu.au> Message-Id: <6DCE648A-5003-11D8-8717-00039310CAE8@inria.fr> Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.553) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 damien:01 damien:01 pietro:01 abate:01 hashtbl:01 clone:01 library's:01 applicative:01 mymap:01 mymap:01 hashtbl:01 mutable:01 doligez:01 doligez:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Monday, January 26, 2004, at 11:43 AM, Pietro Abate wrote: > I'm trying to implement a (string * set) hashtbl > where some element (set) should be shared between different > objects. > the main point is that when I clone an object I want to duplicate > some sets and shared others (sticky sets) This doesn't make sense because your set type is built from the standard library's Set module. Thus your sets are purely applicative: you cannot modify them with side-effects. Shared or not, the elements of a1 will not change when you change the elements of a2, because changing the elements of a2 doesn't change the elements themselves, it only replaces them with new elements (which are not shared, by definition). That can be seen in your code: sets <- MyMap.remove name sets; sets <- MyMap.add name (set',t) sets You don't change the shared set, you remove it from the map and then add a new one under the same name. If you really need mutable sets, maybe you should use the Hashtbl module instead of Set. -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners