From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA01503; Fri, 20 Jun 2003 00:39:21 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 AAA01713 for ; Fri, 20 Jun 2003 00:39:20 +0200 (MET DST) Received: from mail.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5JMdIT08168 for ; Fri, 20 Jun 2003 00:39:19 +0200 (MET DST) Received: (qmail 7059 invoked from network); 19 Jun 2003 22:39:17 -0000 Received: from unknown (HELO grace.speakeasy.org) ([216.254.0.2]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 19 Jun 2003 22:39:17 -0000 Date: Thu, 19 Jun 2003 15:39:17 -0700 (PDT) From: brogoff@speakeasy.net To: "caml-list@inria.fr" Subject: Re: [Caml-list] Mutually recursive types and classes In-Reply-To: <20030619194557.0b5265bb.nick.name@inwind.it> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam: no; 0.00; brogoff:01 caml-list:01 functor:01 recurrence:01 recursion:01 foo:01 bug:01 faq:01 beginner's:01 beginners:01 bin:01 caml-bugs:01 ocaml:01 caml:01 inherit:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk You can use the parameterization trick and introduce an extra type variable, as has been discussed on the list before. This is the big hammer for solving all sorts of forbidden recurrences in OCaml, like the functor instance/type recurrence. Thankfully, that particular problem now appears to be fixed in the CVS snapshot. You can also have recursion between object types and types, and use coercion to make sure everything matches, like so type a = A of (b -> unit) | B and b = < f : a -> unit > class c = object(this) method f = function A foo -> foo (this :> b) | _ -> () end -- Brian On Thu, 19 Jun 2003, Nick Name wrote: > Hi all, > > I wish to declare a type like > > type a = A of (b -> unit) | ... > > where b is a class like > > class b = > object (this) > method f : a -> unit = > function > A f -> f this > | _ -> unit > end > > or, alternatively: > > class b = > object > inherit [a] otherclass > ... > end > > How can I do such a thing, considering that I can't write an "and" > keyword between a type declaration and a class (or class type) > declaration? > > Thanks for help > > Vincenzo > > ------------------- > To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr > Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners