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 PAA12532; Tue, 16 Jul 2002 15:25:28 +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 PAA12510 for ; Tue, 16 Jul 2002 15:25:27 +0200 (MET DST) Received: from laurelin.dementia.org ([208.167.88.73]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6GDPPb10342; Tue, 16 Jul 2002 15:25:26 +0200 (MET DST) Received: by laurelin.dementia.org (Postfix, from userid 1001) id 36D6270C7; Tue, 16 Jul 2002 09:32:08 -0400 (EDT) To: Alessandro Baretta Cc: Johan =?iso-8859-1?q?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> <3D33FE98.6000001@baretta.com> From: John Prevost Date: 16 Jul 2002 09:32:08 -0400 (56.398 UMT) In-Reply-To: <3D33FE98.6000001@baretta.com> Message-ID: <86u1mzu7c7.fsf@laurelin.dementia.org> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk >>>>> "ab" == Alessandro Baretta writes: ab> In my code, class a = object method m = ... end Provides basic ab> functionality common to all my inheritance hiearchy. Class a ab> *also* defines the actual type of all my inheritance ab> hieararchy, so I do not use subtyping at all; I use type ab> *identity*. That's because I'm building a graph of objects of ab> different classes, so all the objects in the graph need to ab> have the same type. I only use inheritance because of code ab> sharing. Now, class b = object inherit a ... end performs ab> extensive personalizations to the functionality provided by ab> class a, while always retaining the functionality of the ab> parent, which is accessed by sending messages to ab> super_a. Class var_b needs most of the functionality provided ab> by b, with the sole exception of one method, which I call here ab> m, which needs to be identical to the one defined in the root ab> of the hierarchy. Okay--let me rephrase what you just said to make sure I understand correctly: You have a class "a" which has a lot of common methods. You have a class "b" which reuses and changes those. You have a class "var_b" which is identical to "b" except that method "m" is the same as "a". If that is correct, I have no idea why you want to inherit the way you've been talking about! Why in heaven's name wouldn't you just write: class a = object method m = ... method m1 = ... method m2 = ... ... end class var_b = object inherit a method m1 = ... method m2 = ... ... end class b = object inherit b method m = ... end You've simply got the wrong ordering in your inheritance. There's absolutely no need for more functionality to support accessing "older" methods in this case. (I'd argue there's no need in any case.) And again, even if method m had to be different in var_b, it would be better to use an inherited class which has the features common to b and var_b. In this case, that class is identical to b. John. ------------------- 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