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 DAA27445; Tue, 16 Jul 2002 03:15:48 +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 DAA27416 for ; Tue, 16 Jul 2002 03:15:47 +0200 (MET DST) Received: from favie.faith.gr.jp (favie.faith.gr.jp [61.127.175.250]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g6G1Fjj18010 for ; Tue, 16 Jul 2002 03:15:45 +0200 (MET DST) Received: from localhost (dhcp7.faith.gr.jp [192.168.1.17]) by favie.faith.gr.jp (8.9.3/8.9.3) with ESMTP id KAA02733; Tue, 16 Jul 2002 10:15:26 +0900 To: alex@baretta.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Recovering masked methods In-Reply-To: <3D335729.3020307@baretta.com> References: <3D335729.3020307@baretta.com> X-Mailer: Mew version 1.94.2 on Emacs 21.2 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: <20020716101520Q.garrigue@kurims.kyoto-u.ac.jp> Date: Tue, 16 Jul 2002 10:15:20 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Alessandro Baretta > I have code similar to the following > > class a = > object (self) > method m = 1 > method n = "Hello!" > end > > class b = > object (self) > inherit a as super_a > method m = 2 > end > > Now I would like to define a third class, inheriting from b. > I need this class to be able to access the definition of > method m from class a, otherwise I would have to use "copy & > paste", which is contrary to my programmer's ethics. You don't need to be too ethical about that. What's so great about strong typing, is that it makes copy-paste work! And you can always write let a_m = 1 class a = ... method m = a_m .. This way you can still share the code (but you need to pass private methods by hand). If you want to stay indide the object, you can also save the old method to a private one: class b = ... method private a_m = super_a#m ... > Ideally, I would like to write > > class c = > object (self) > inherit b as super_b > > method m = > (* some_stuff *) > super_b # super_a # m > end > > Presently, this is not allowed. Is there any specific reason > for this? Could such a feature be implemented in the future? OK, you want something like C++'s qualified calls? There's no project to do that. Methods do not exist independently of their class. Another approach would be to provide views, as described by Jerome Vouillon. That is, an object could keep some extra sets of methods in an abstract way. But there's not project to implement that either. Yet, it's not even clear such an ancestor call would make sense in general. Could you give some more compelling example requiring such a feature? Jacques ------------------- 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