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 KAA19395; Fri, 12 Jul 2002 10:54:30 +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 KAA19351 for ; Fri, 12 Jul 2002 10:54:29 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6C8sRj22750 for ; Fri, 12 Jul 2002 10:54:28 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3/3.7W) with ESMTP id RAA18372; Fri, 12 Jul 2002 17:54:16 +0900 (JST) To: brian-l-smith@uiowa.edu Cc: caml-list@inria.fr Subject: Re: [Caml-list] Syntax for multiple subtyping constraints? In-Reply-To: <3D2E6A3F.70001@uiowa.edu> References: <3D2E6A3F.70001@uiowa.edu> X-Mailer: Mew version 1.94.2 on Emacs 20.7 / Mule 4.0 (HANANOEN) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020712175416Y.garrigue@kurims.kyoto-u.ac.jp> Date: Fri, 12 Jul 2002 17:54:16 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Brian Smith > Please consider the following: > > # class virtual x = object method virtual foo : int end > class virtual y = object method virtual bar : string end > class z = > object > method foo = 2 > method bar = "there" > end;; > > How can I assert that class "z" is supposed to be a subtype of class x > and class y? In other words, how can I assert that (some_z : z :> x) and > (some_z : z :> y) will always be valid? You have many ways to force (self : #x) and (self : #y). class z = object ((self : #x) : #y) method foo = 2 method bar = "there" end class z = object (self : 'a) constraint 'a = #x constraint 'a = #y method foo = 2 method bar = "there" end class z = object inherit x inherit y method foo = 2 method bar = "there" end The last one uses the fact x and y are virtual classes, rather than class types. Note that none of these guarantee a subtyping relation, only a matching one. Fortunately, as long as the type of self does not appear in a contravariant position in x or y, this relation is included in subtyping. 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