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 NAA25622; Fri, 21 May 2004 13:01:08 +0200 (MET DST) 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 NAA25528 for ; Fri, 21 May 2004 13:01:07 +0200 (MET DST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i4LB16EV003585 for ; Fri, 21 May 2004 13:01:06 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay03.plus.net with esmtp (Exim) id 1BR7ly-0004VX-BV for caml-list@inria.fr; Fri, 21 May 2004 11:01:06 +0000 From: Jon Harrop Organization: University of Cambridge To: caml-list@inria.fr Subject: Re: [Caml-list] Hash over ref Date: Fri, 21 May 2004 11:59:51 +0100 User-Agent: KMail/1.6.2 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200405211159.51384.jdh30@cam.ac.uk> X-Miltered: at nez-perce with ID 40ADE172.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 hash:01 hash:01 hashes:01 hashtbl:01 hashing:01 alain's:01 equality:01 approaches:01 int:01 simpler:01 refs:02 essentially:02 objects:02 objects:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Ok, thanks for all the advice from everyone. :-) Essentially, I wish to hash the pointer value of the reference itself. So, if a reference were reassigned, then the hash would be different. Two identical copies of an object would have different references and, consequently, would give different hashes (i.e. a != b is true where a and b are 'a ref). The reason I want to do this is to spot duplicate uses of a single object (multiple references to it) but without confusing this with different uses of identical objects (i.e. where "=" would give true but "==" would not). I can think of a couple of alternative approaches. I could implement a naff kind of set as a list which used "==" to test for equality. Or, I could loop through all of the references to the objects, marking unmarked objects with a new identifier (an int, say) and then insert them all into a Hashtbl on the basis of their identifiers. I just thought hashing refs themselves would be simpler. I think I can do this given Alain's code though, thanks! Cheers, Jon. ------------------- 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