Version française
Home     About     Download     Resources     Contact us    
Browse thread
Classes/objects with internal references to lists of objects of the same type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andreas Rossberg <rossberg@m...>
Subject: Re: [Caml-list] Classes/objects with internal references to lists of objects of the same type
On Feb 5, 2010, at 20.16 h, Tim Hanson wrote:
>
> 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
> -------

Try:

class a_pad =
   object
     val mutable parent_mod = new a_mod
     val mutable connected : a_pad list = []
   end
and a_mod =
   object
     val mutable pads : a_pad list = []
   end

Cheers,
/Andreas