From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 3833DBBAF for ; Fri, 5 Feb 2010 20:17:07 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvQBAPL9a0tIDtyckGdsb2JhbACROYlbPAEBAQEJCQwHEwOsdoFKhQiIcQEBAwWETQQ X-IronPort-AV: E=Sophos;i="4.49,414,1262559600"; d="scan'208";a="51468835" Received: from fg-out-1718.google.com ([72.14.220.156]) by mail1-smtp-roc.national.inria.fr with ESMTP; 05 Feb 2010 20:17:05 +0100 Received: by fg-out-1718.google.com with SMTP id 22so2057fge.9 for ; Fri, 05 Feb 2010 11:17:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=87xSmPNjpgaCjFtyy0oTEzAWkJmflUyJLY+aY+hZzKg=; b=sRC1H5NErDo/lPAVQbZQYQcsn0dxQ7+ZSjFN18go7HVbbZs8eVzqw2Eh8A5yMlqcEM 6iSHkVlx5M1SuiivmnkgvOoeocYhsMIZJFhwlScja7A3M7uvvJm7PYUieCpckiBZRmBQ Su12curYzjmxE0S1D8Wa+k/jzJbyd1etdF5XM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=rJN/2m9UTwV9LyJh++UluIJ3pOY1igtDNmCggLKxUNGqeNbwsU1YsZTkxwFTQNwLMI Yaarp34PCL85pALqOX17QV72N/pZB89CCSVM3TUFekE3scVDVbX8EYJrI1o7l+wi2qUn 9JmV8Ubo7Ql1br5v0+XZgW/OkbDq6t4shnMWM= MIME-Version: 1.0 Received: by 10.216.87.12 with SMTP id x12mr1713394wee.48.1265397410616; Fri, 05 Feb 2010 11:16:50 -0800 (PST) From: Tim Hanson Date: Fri, 5 Feb 2010 14:16:24 -0500 Message-ID: <9d2084741002051116y188cbc55t4961e254ed4b72dd@mail.gmail.com> Subject: Classes/objects with internal references to lists of objects of the same type To: OCaml List Content-Type: text/plain; charset=ISO-8859-1 X-Spam: no; 0.00; val:01 mutable:01 val:01 mutable:01 expr:01 expr:01 pads:98 pads:98 imperative:01 data:02 tree:02 objects:02 objects:02 module:03 float:03 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