English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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-20 (22:52)
From: Damien Doligez <damien.doligez@i...>
Subject: Re: [Caml-list] Hash over ref
On May 20, 2004, at 22:37, Jon Harrop wrote:

> Is it possible to hash a ref itself, rather than the object it 
> references?

If I understand the question correctly, you want the hash to remain
constant even when you update the reference.  Then the answer is no.

The normal technique for this case is to replace your reference with
a record of two fields: a mutable field for the contents, and an int
field which you initialize with a random number (or a sequential
counter) when you create the record.  Then your hash code is this

-- 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