From: Tim Hanson <sideskate@gmail.com>
To: OCaml List <caml-list@inria.fr>
Subject: Classes/objects with internal references to lists of objects of the same type
Date: Fri, 5 Feb 2010 14:16:24 -0500 [thread overview]
Message-ID: <9d2084741002051116y188cbc55t4961e254ed4b72dd@mail.gmail.com> (raw)
Hi All,
I'm trying to make two classes that have internal references to
themselves and each other, but can't figure it out. e.g:
-------
class a_pad = object
val mutable parent_mod = new a_mod
val mutable connnected : 'a_pad list = []
end
class a_mod = object
val mutable pads : 'a_pad list = []
end
-------
The a_pad objects need to call routines in their parent module, and
most importantly, they need to know what other pads they are connected
to.
I understand that this is possible with stuff like:
-------
type expr = Mod of float * float * float * expr list
| Pad of float * float * float * expr * expr list
-------
But that's quite cumbersome. The imperative programming style is
useful here, since all the contained float data needs to change
constantly. (the tree structure does not).
thank you in advance for your help.
Tim
next reply other threads:[~2010-02-05 19:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 19:16 Tim Hanson [this message]
2010-02-05 21:04 ` [Caml-list] " Andreas Rossberg
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=9d2084741002051116y188cbc55t4961e254ed4b72dd@mail.gmail.com \
--to=sideskate@gmail.com \
--cc=caml-list@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