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 BAA25146; Wed, 24 Mar 2004 01:45:53 +0100 (MET) 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 BAA24039 for ; Wed, 24 Mar 2004 01:45:52 +0100 (MET) Received: from calmail-cl.berkeley.edu (mailfarm.Berkeley.EDU [128.32.61.106]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i2O0kQKW009648 for ; Wed, 24 Mar 2004 01:46:26 +0100 Received: from [64.162.212.212] (HELO tallman.kefka.frap.net) by calmail-cl.berkeley.edu (CommuniGate Pro SMTP 4.1.8) with SMTP id 8892976 for caml-list@inria.fr; Tue, 23 Mar 2004 16:45:49 -0800 Received: by tallman.kefka.frap.net (sSMTP sendmail emulation); Tue, 23 Mar 2004 16:45:48 -0800 Date: Tue, 23 Mar 2004 16:45:48 -0800 From: Kenneth Knowles To: caml-list@inria.fr Subject: Re: [Caml-list] Delegation based OO Message-ID: <20040324004548.GA19738@tallman.kefka.frap.net> References: <405EBD5D.1000406@baretta.com> <20040323.080154.71097954.yoriyuki@mbg.ocn.ne.jp> <20040323002926.GA30057@kefka.frap.net> <20040324.084300.18291498.yoriyuki@mbg.ocn.ne.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040324.084300.18291498.yoriyuki@mbg.ocn.ne.jp> User-Agent: Mutt/1.5.6i X-Miltered: at nez-perce by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; knowles:99 caml-list:01 2004:99 0900,:01 yamagata:01 yoriyuki:01 coerced:01 yamagata:01 yoriyuki:01 foo:01 val:01 foo:01 val:01 overriding:01 delegating:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 342 On Wed, Mar 24, 2004 at 08:43:00AM +0900, Yamagata Yoriyuki wrote: > There is a difference. You cannot hide the method "y" in the class > definition "x". An object can be coerced to a super type, so that it's > type would forget about the method "y", then you override it... > > -- > Yamagata Yoriyuki Good point, I think. Let's see if I understand; I think you mean the following imaginary situation: # class type delegate : object method b : int end;; ... # class x = object(self) method a = 3 method b = self # a end;; ... # class y (del : delegate) = object delegate del method a = "hello" end;; ... # let foo = new x;; val foo : # let bar = new y (x :> delegate) val bar : This is solved by treating delegation as object composition, rather than inheritance, making overriding irrelevant. The original methods of "del" all point to the same "self" object. This also solves the use of delegating only a subset of methods, since only the methods of the statically determined (or specified) type of "del" are delegated, minus the methods defined by "x." I'm not advocating adding this to the language, but it does seem pretty straightforward. Kenn ------------------- 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