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
[Caml-list] Hash over ref
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-05-21 (11:01)
From: Jon Harrop <jdh30@c...>
Subject: Re: [Caml-list] Hash over ref

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 

I think I can do this given Alain's code though, thanks!


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: