Browse thread
[Caml-list] Recursive classes and subtyping
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Laurent Vibert <lvibert@i...> |
| Subject: | Re: [Caml-list] Recursive classes and subtyping |
On Fri, 1 Feb 2002, Claudio Sacerdoti Coen wrote: > # type -'a t;; > type -'a t > # class c (obj : [> `A] t) = object end > and d (obj : [`A] t) = object method c = new c obj end;; > class c : [ `A] t -> object end > class d : [ `A] t -> object method c : c end > > Is there any way to to obtain the type "class c : [> `A] t -> object end" > while keeping the mutual recursion? I think this is more or less related to http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#regle_mu so you could write : class c (obj : [> `A] t) = object end and d' (newc : [ `A] t -> c) (obj : [`A] t) = object method c = newc obj end;; class d obj = object inherit d' (new c) obj end;; -- Laurent Vibert doctorant, équipe Espresso IRISA-INRIA, Campus de Beaulieu Tél: +33 (0) 2 99 84 72 33 35042 Rennes Cedex, France Fax: +33 (0) 2 99 84 71 71 ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr