Hashtable of mutable variable in Ocaml
I need to use hashtable of mutable variable in Ocaml, but it doesn't work out. let link = Hashtbl.create 3;; let a = ref [1;2];; let b = ref [3;4];; Hashtbl.add link a b;; # Hashtbl.mem link a;; - : bool = true # a := 5::!a;; - : unit = () # Hashtbl.mem link a;; - : bool = false Is there any way to make it works? Mutable variables that may happen to have the same content can still be distinguished because they are stored at different locations in memory. They can be compared with the physical equality operator ( == ). However, OCaml doesn't provide anything better than equality, it doesn't