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 KAA08341; Sat, 1 Jun 2002 10:26:31 +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 KAA08828 for ; Sat, 1 Jun 2002 10:26:30 +0200 (MET DST) Received: from favie.faith.gr.jp (favie.faith.gr.jp [61.127.175.250]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g518QRn13330 for ; Sat, 1 Jun 2002 10:26:28 +0200 (MET DST) Received: from localhost (dhcp7.faith.gr.jp [192.168.1.17]) by favie.faith.gr.jp (8.9.3/8.9.3) with ESMTP id RAA01792; Sat, 1 Jun 2002 17:26:18 +0900 To: zhudp@cs.bu.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] recursive type declaration In-Reply-To: References: X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020601172611W.garrigue@kurims.kyoto-u.ac.jp> Date: Sat, 01 Jun 2002 17:26:11 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: dengping zhu > Now I want to define a type and a class, both of which are recursive > defined as follows: > ---------------- > type ty1 = > | Int of int > | String of string > | Class of typeClass > > class virtual typeClass = > object > method virtual typeCon : ty1 > end;; > ----------------- > However, it does not work. > I can use another way to solve it by define ty1 as 'a ty1. Besides this > way, is there any method to solve it? What's more, what's the common way > to define such types? I believe this is a FAQ. Just parameterize one one of the two. For instance: type 'tc ty1 = | Int of int | String of string | Class of 'tc class virtual typeClass = object method virtual typeCon : typeClass ty1 end;; Arguably, this is a misfeature of the language that you cannot define the two together, but then recursive class definitions and type definitions do not handle constraints in the same way, so this would be hard to mix them properly. Jacques Garrigue ------------------- 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