Version française
Home     About     Download     Resources     Contact us    
Browse thread
recursive records with weak hashtbl
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <Christophe.Troestler+ocaml@u...>
Subject: Re: [Caml-list] recursive records with weak hashtbl
On Wed, 4 Mar 2009 16:31:02 +0300, Vsevolod Fedorov wrote:
> 
> I want to define two records referencing each other. First record (A)
> has direct reference to second (B) and second (B) has weak hash table to
> list records A, which have reference to it. For example (pseudo code):
> 
> type a
> {
>   id : int ;
>   mutable field1 : string;
>   mutable b : B;
> }
> type b
> {
>     id : int;
>     mutable field2 : string;
>     a_list : Weak-Hashtbl(a);  (* they referenced me *)
> }
> 
> Is it possible at all?

type a = {
  id : int ;
  mutable field1 : string;
  mutable b : b;
}
and b = {
  id : int;
  mutable field2 : string;
  a_list : a Weak.t;  (* they referenced me *)
};;

ChriS