From: Virgile Prevosto <virgile.prevosto@m4x.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] recursive records with weak hashtbl
Date: Wed, 4 Mar 2009 15:00:36 +0100 [thread overview]
Message-ID: <20090304150036.1fb63c2d@gavalla> (raw)
In-Reply-To: <49AE8296.5040009@mail.ru>
Hello,
Le mer. 04 mars 2009 16:31:02 CET,
Vsevolod Fedorov <sevaAtWork@mail.ru> a écrit :
> 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?
mutually recursive types are defined like this:
type a = { ... }
and b = { ... }
> 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 = { ... a_list: 'a Weak.t }
- a.ml -
type a = { ... 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,
--
E tutto per oggi, a la prossima volta.
Virgile
next prev parent reply other threads:[~2009-03-04 14:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-04 13:31 Vsevolod Fedorov
2009-03-04 13:55 ` [Caml-list] " Florent Ouchet
2009-03-04 14:00 ` Virgile Prevosto [this message]
2009-03-04 14:00 ` Martin Jambon
2009-03-04 14:11 ` Christophe TROESTLER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090304150036.1fb63c2d@gavalla \
--to=virgile.prevosto@m4x.org \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox