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 IAA31879; Mon, 21 Oct 2002 08:52:30 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA32168 for ; Mon, 21 Oct 2002 08:52:29 +0200 (MET DST) Received: from morgon.inria.fr (morgon.inria.fr [128.93.8.33]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9L6qR522472; Mon, 21 Oct 2002 08:52:28 +0200 (MET DST) Received: (from remy@localhost) by morgon.inria.fr (8.11.6/8.11.6) id g9L6t2J09594; Mon, 21 Oct 2002 08:55:02 +0200 Date: Mon, 21 Oct 2002 08:55:02 +0200 From: Didier Remy To: james woodyatt Cc: The Trade Subject: Re: [Caml-list] functional objects Message-ID: <20021021085502.A9551@morgon.inria.fr> Reply-To: Didier.Remy@inria.fr References: <20021019224823.A17599@morgon.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: ; from jhw@wetware.com on Sun, Oct 20, 2002 at 09:10:09PM -0700 Organization: INRIA, BP 105, F-78153 Le Chesnay Cedex Phone: (33) 1 3963 5317 -- Sec: (33) 1 3963 5207 -- Fax: (33) 1 3963 5193 Web: http://cristal.inria.fr/~remy Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > What would that look like in the multiple inheritance case? Why did you not ask this in the first place? (i.e. if you meant multiple inheritance, you should have provided an example with multiple inheritance). Have you really tried this exercise yourself before asking for help? The pattern seemed simple enough so that its generalization was obvious. Didier Rémy class ['a1] c1 (x1 : 'a1) = object val x1_ = x1 method m1 = () method c1 x1 = {< x1_ = x1 >} end;; class ['a2] c2 (x2 : 'a2) = object val x2_ = x2 method m2 = () method c2 x2 = {< x2_ = x2 >} end;; class ['a1,'a2, 'a3] c3 x1 x2 (x3 : 'a3) = object inherit ['a1] c1 x1 inherit ['a2] c2 x2 val x3_ = x3 method m3 = () method c3 x1 x2 x3 = ({< x3_ = x3 >} # c1 x1) # c2 x2 end;; (* Note that fields are overriden in the reverse order, which does not matter since they are all disjoint. Should method c1 and c2 both override the same parent field, then the order should be enforced, as follows: *) class ['a1,'a2, 'a3] c3 x1 x2 (x3 : 'a3) = object (self) inherit ['a1] c1 x1 inherit ['a2] c2 x2 val x3_ = x3 method m3 = () method private c3_ x3 = {< x3_ = x3 >} method c3 x1 x2 x3 = ((self # c1 x1) # c2 x2) # c3_ x3 end;; ------------------- 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