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 HAA15722; Fri, 12 Jul 2002 07:33:55 +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 HAA15715 for ; Fri, 12 Jul 2002 07:33:54 +0200 (MET DST) Received: from day.its.uiowa.edu (day.its.uiowa.edu [128.255.56.107]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g6C5Xrf17985 for ; Fri, 12 Jul 2002 07:33:53 +0200 (MET DST) Received: from uiowa.edu (host38-92.uihc.uiowa.edu [129.255.38.92]) by day.its.uiowa.edu (8.11.6/8.11.6/ns-mx-1.14) with ESMTP id g6C5Xp519846 for ; Fri, 12 Jul 2002 00:33:52 -0500 Message-ID: <3D2E6A3F.70001@uiowa.edu> Date: Fri, 12 Jul 2002 00:33:51 -0500 From: Brian Smith User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1a) Gecko/20020611 X-Accept-Language: en-us, en MIME-Version: 1.0 To: OCaml Mailing list Subject: [Caml-list] Syntax for multiple subtyping constraints? Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello everbody, 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? I tried: # class z = object (self : #x, self : #y) method foo = 2 method bar = "there" end;; Characters 29-30: object (self : #x, self : #y) ^ Syntax error But, it only works for one supertype, e.g.: class z = object (self : #x) (* or (self : #y) *) method foo = 2 method bar = "there" end;; I know that I could just leave it out and everything would work, but I want to specify that z is supposed to be a subtype of both x and y so that, if I screw up the definition of class z, the compiler will give me an error. For example, if I didn't define the method "bar" in class "z", I want to get the error: This class type should be virtual The following methods are undefined : bar Thanks, Brian ------------------- 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