On Fri, 26 Sep 2008, Sébastien Hinderer wrote: > Dear list, > > Is there a (clean) way to define simultaneously a class and a type that > are mutually recursive ? I don't think so, but you don't have to. > Something like this : > class element (c : content) = > object > ... > end and type content = > | Data of string > | Elements of element list;; > > This is of course not a valid OCaml definition, but is there a way to > express it ? With each class comes a type of the same name. Such type can also be defined independently from the notion of class. It is syntactically like a record with angle brackets: type element = < content : content > and content = Data of string | Elements of element list;; class element_class (c : content) = object method content = c end # new element_class (Elements [ new element_class (Data "abc") ]);; - : element_class = Martin > Many thanks in advance for your help, > Sébastien. > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > -- http://mjambon.com/