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 NAA09423; Tue, 16 Jul 2002 13:01:06 +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 NAA09424 for ; Tue, 16 Jul 2002 13:01:06 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (r-mi214-6a44.tin.it [62.211.4.44]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6GB14b04288; Tue, 16 Jul 2002 13:01:04 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id A98D12724F; Tue, 16 Jul 2002 13:08:08 +0200 (CEST) Message-ID: <3D33FE98.6000001@baretta.com> Date: Tue, 16 Jul 2002 13:08:08 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 X-Accept-Language: it, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Johan_Balti=E9?= , Ocaml , Daniel de Rauglaudre Subject: Re: [Caml-list] Recovering masked methods (with CamlP4?) References: <3D335729.3020307@baretta.com> <20020716101520Q.garrigue@kurims.kyoto-u.ac.jp> <3D33E74C.6050307@baretta.com> <20020716095939.M27616@wanadoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Johan Baltié wrote: > > I do not agree with you on the usefullness of this kind of stuff. > Basic OO theory says that the inheritance relation can be seen as a "is a" operator. > > If your "is a" means "is a with some variants", for me your modelization is not > good. > > You should have: > > B' inherits A > B inherits B' > small_b_variant inherits B' > > Like this code factorisation seems to be easy to do. > > IMHO it's a good modelization constraint to forbid such stuff. I strongly disagree. Inheritance, as pointed out previously by someone on this list (I can't remember whom), is a syntactic property of classes, whereas subtyping is a semantic property of instances. Just now I have received a post by John Prevost clarifying this. In my code, class a = object method m = ... end Provides basic functionality common to all my inheritance hiearchy. Class a *also* defines the actual type of all my inheritance hieararchy, so I do not use subtyping at all; I use type *identity*. That's because I'm building a graph of objects of different classes, so all the objects in the graph need to have the same type. I only use inheritance because of code sharing. Now, class b = object inherit a ... end performs extensive personalizations to the functionality provided by class a, while always retaining the functionality of the parent, which is accessed by sending messages to super_a. Class var_b needs most of the functionality provided by b, with the sole exception of one method, which I call here m, which needs to be identical to the one defined in the root of the hierarchy. Hence, for the sake of code reuse, since var_b shares most of its code with b, it must inherit from b; however, for the sake of not having multiple copies of the same lines of code--a maintainance issue--I *also* need var_b to inherit, albeit indirectly, form a. This is my reason for requesting and "explicit inheritance hierarchy" construct. I think it should pose no semantic issues with the OO system of Caml. It should simply allow explicit scoping of inherited methods. Please, note that it is merely a bit of syntactic sugar. To think of it, it might even be implemented with CamlP4. CamlP4 could perform the following code transformation: class a = object method m = end to class a = object private method __class_a__m = method m = self # __class_a__m end and class var_b = object inherit a as super_a through b as super_b method m = super_a # m end to class var_b = object inherit b as super_b method m = __class_a__m end Daniel, I'm no CamlP4 guru. Would this scheme work? 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