From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 8E3E6BC20 for ; Wed, 4 Mar 2009 15:03:09 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: At8BAGsYrkmBaB4imWdsb2JhbACVAQEBAQEBCAsKBxHCPQeEAQY X-IronPort-AV: E=Sophos;i="4.38,301,1233529200"; d="scan'208";a="36081624" Received: from mx1.polytechnique.org ([129.104.30.34]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 04 Mar 2009 15:00:38 +0100 Received: from gavalla (88-121-10-103.rev.libertysurf.net [88.121.10.103]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTP id 0CA59140000B2 for ; Wed, 4 Mar 2009 15:00:38 +0100 (CET) Date: Wed, 4 Mar 2009 15:00:36 +0100 From: Virgile Prevosto To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] recursive records with weak hashtbl Message-ID: <20090304150036.1fb63c2d@gavalla> In-Reply-To: <49AE8296.5040009@mail.ru> References: <49AE8296.5040009@mail.ru> X-Mailer: Claws Mail 3.7.0 (GTK+ 2.14.7; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Wed Mar 4 15:00:38 2009 +0100 (CET)) X-Org-Mail: virgile.prevosto.1996@polytechnique.org X-Spam: no; 0.00; recursive:01 hashtbl:01 mutable:01 mutable:01 recursive:01 recursion:01 ocaml:01 2009:98 tutto:98 oggi:98 volta:98 polymorphic:01 beginners:01 caml-list:01 int:01 Hello, Le mer. 04 mars 2009 16:31:02 CET, Vsevolod Fedorov a =E9crit : > 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 *) > } >=20 > Is it possible at all? mutually recursive types are defined like this: type a =3D { ... }=20 and b =3D { ... } > Is it possible with A and B declarations in separate files? not directly, but you can use a polymorphic type to break the recursion. Assuming that a is defined in a.ml and b in b.ml and that a.ml depends upon b.ml, you'd have: - b.ml - type 'a b =3D { ... a_list: 'a Weak.t } - a.ml - type a =3D { ... mutable b: a B.b } BTW, I'd say that such a topic would be better on the ocaml beginners list (see reference below) Regards, --=20 E tutto per oggi, a la prossima volta. Virgile