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 KAA28570; Sun, 7 Sep 2003 10:03:09 +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 KAA22270 for ; Sun, 7 Sep 2003 10:03:08 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h87836f10297 for ; Sun, 7 Sep 2003 10:03:06 +0200 (MET DST) Received: from localhost (suiren.kurims.kyoto-u.ac.jp [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.9.3p2/3.7W) with ESMTP id RAA06693; Sun, 7 Sep 2003 17:03:01 +0900 (JST) To: newton@MIT.EDU Cc: caml-list@inria.fr Subject: Re: [Caml-list] Is there a compact syntax for masking methods in an inherit In-Reply-To: <1062887193.3773.2363.camel@ffh.ro> References: <1062887193.3773.2363.camel@ffh.ro> 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: <20030907170300B.garrigue@kurims.kyoto-u.ac.jp> Date: Sun, 07 Sep 2003 17:03:00 +0900 From: Jacques Garrigue X-Dispatcher: imput version 20000228(IM140) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 jacques:01 newton:99 newton:99 monolithic:01 overriden:01 ocamlc:01 jacques:01 mixin:01 semantics:01 semantics:01 ocaml:01 inherit:01 inherit:01 int:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk From: Ryan R Newton > I've developed a liking for using multiple inheritacnce heavily as > follows: > > When I'm working on a library (say, an evolutionary computation library, > or a distributed computing library), I'm real crazy about making > composable "plug-and-play" units of functionality rather than a > monolithic class hierarchy. That is, I like to make a base class along > with small virtual "layer" classes. I combine different features by > defining a new class which inherits from the base class and a subset of > the layer classes. > > Is there a name for this sort of pattern? Is it a horrible idea for > some reason? It looks like what most people call a mixin. Or is it different? > Anyway, the point of this post is: When inheriting the same method from > two sources, I quite reasonably get this message: > > "Warning: the following methods are overriden by the inherited class:" > > What's the best way to get rid of it? (Without turning off all > warnings.) If you just mean, turn off only this warning, this is easy ocamlc -w m Clearly what you are doing is legal and reasonable, but I see no way to avoid the warning for public methods without disabling it. For private methods, you can hide them when inheriting, but then you are changing the semantics (the methods will not be merged) class c = object inherit (a : object method f : int end) inherit b ... end is legal if g is private in a. The impossibility to hide public methods is fundamental to the ocaml type system. So "inherit g without a" is impossible. A possibility would be to disable the warning when a virtual method is declared after inheritance. > class c = > object > inherit a method virtual g : int > inherit b > method h = 99 > end This seems reasonable to have no warning in this case, the intention being explicit enough. Of course, if there is no definition of g in b, the definition from a would be kept (we don't change the semantics, just the warning). Would this avoid your problem? Other solutions would imply new syntax, for something that is no more than a warning. Jacques Garrigue ------------------- 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