Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Is there a compact syntax for masking methods in an inherit
@ 2003-09-06 22:26 Ryan R Newton
  2003-09-07  8:03 ` Jacques Garrigue
  0 siblings, 1 reply; 3+ messages in thread
From: Ryan R Newton @ 2003-09-06 22:26 UTC (permalink / raw)
  To: caml-list

Hello Camlers,

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?


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.)

Here's an example:

   class a =
   object (self)
     method f = 3
     method g = self#f * 3
   end

   class virtual b =
   object (self)
     method g = self#f * 4
   end

   class c =
   object
     inherit a
     inherit b  
     method h = 99
   end  

   Warning: the following methods are overriden by the inherited class: 
      g

Ideally, I'd like to make the overlap explicit and get rid of the
warning at the same time by typing something like:

      inherit a without g

Any ideas? 


--Ryan Newton




-------------------
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-10  1:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-06 22:26 [Caml-list] Is there a compact syntax for masking methods in an inherit Ryan R Newton
2003-09-07  8:03 ` Jacques Garrigue
     [not found]   ` <1063148703.27949.43.camel@moremischief>
2003-09-10  1:06     ` Jacques Garrigue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox