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 LAA21153; Wed, 24 Mar 2004 11:43:27 +0100 (MET) 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 LAA20609 for ; Wed, 24 Mar 2004 11:43:26 +0100 (MET) Received: from alex.baretta.com ([213.255.109.130]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i2OAhOHd031032 for ; Wed, 24 Mar 2004 11:43:25 +0100 Received: from baretta.com (localhost.localdomain [127.0.0.1]) by alex.baretta.com (8.12.8/8.12.8) with ESMTP id i2OAhmjx002362 for ; Wed, 24 Mar 2004 11:43:49 +0100 Message-ID: <40616664.4040500@baretta.com> Date: Wed, 24 Mar 2004 11:43:48 +0100 From: Alex Baretta User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: it, en-us, en MIME-Version: 1.0 To: Ocaml Subject: Re: [Caml-list] Delegation based OO 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> <20040324004548.GA19738@tallman.kefka.frap.net> In-Reply-To: <20040324004548.GA19738@tallman.kefka.frap.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; baretta:01 baretta:01 caml-list:01 knowles:99 2004:99 0900,:01 yamagata:01 yoriyuki:01 backend:01 backend:01 inherit:01 alex:01 alex:01 int:01 essentially:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk X-Status: X-Keywords: X-UID: 347 Kenneth Knowles wrote: > On Wed, Mar 24, 2004 at 08:43:00AM +0900, Yamagata Yoriyuki wrote: > 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;; > Delegation is no relative of inheritance. Inheritance is a syntactic property (essentially classes inherit code), whereas delegation is a semantic property: once one method is delegated by a proxy object to an executor object, the the visibility of the proxy is lost. The method is executed as if it were invoked directly on the executor. As far as I'm concerned delegation serves specifically to implement efficiently (loc-wise) the proxy object pattern. Consider a DB access library where you define classes to access different DBMSs. The proxy object is backend neutral and dispatches depending on a configuration string or equivalent data structure. This can be done now, but each method in the proxy must be delegated explicitly to the backend object. Delegation passes control from the proxy to the backend in one line of code. Alex ------------------- 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