From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA03960 for caml-redistribution; Tue, 15 Jun 1999 22:48:42 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id TAA00549 for ; Tue, 15 Jun 1999 19:01:59 +0200 (MET DST) Received: from zarya.maya.com (zarya.maya.com [192.70.254.128]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id TAA21784; Tue, 15 Jun 1999 19:01:54 +0200 (MET DST) Received: (from prevost@localhost) by zarya.maya.com (8.9.3/8.9.3) id NAA21459; Tue, 15 Jun 1999 13:04:18 -0400 To: Jerome Vouillon Cc: Hendrik Tews , caml-list@inria.fr Subject: Re: grammar for class types, reraised References: <199906140804.KAA01028@ithif20.inf.tu-dresden.de> <19990614233019.41897@pauillac.inria.fr> From: John Prevost Date: 15 Jun 1999 13:04:17 -0400 In-Reply-To: Jerome Vouillon's message of "Mon, 14 Jun 1999 23:30:19 +0200" Message-ID: User-Agent: Gnus/5.070084 (Pterodactyl Gnus v0.84) Emacs/20.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: weis Jerome Vouillon writes: > This would probably be possible, but it is not trivial. And then, you > would probably expect to be able to include in the recursion other > construct, such as value definitions (for instance, if a function > using the type b is used by the class a). This would make the > implementation even more complicated. > > On the other hand, you can get rid of the mutual recursion by adding a > type parameter to one of the type. For instance, you can change > class type a = object method m : b end > and > type b = Node of a | Tree of b * b > into > type 'a b = Node of 'a | Tree of b * b > class type a = object method m : a b end My situation was somewhat more obscene, and would've required this: type ('foo,'bar,'baz,'qux,'blatz,'zuttle,'potz,...) cast = | Foo of 'foo | Bar of 'bar | ... class type node = object method downcast : (foo,bar,...) cast end and bar = object ... end ... The whole point of the excercise was to have a downcast method for a set of specific classes, in a type-safe way. I eventually wrote code using < ... > for all of the types. John.