caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* multiple inheritance, bug or feature ?
@ 2006-02-25 11:01 sejourne_kevin
  2006-02-25 11:44 ` [Caml-list] " Jacques Garrigue
  2006-02-25 11:48 ` Oliver Bandel
  0 siblings, 2 replies; 7+ messages in thread
From: sejourne_kevin @ 2006-02-25 11:01 UTC (permalink / raw)
  To: caml-list

Hello :


Consider the following sample :

class a =
object
   val mutable x = 0
   method set v = Printf.printf "%d\n" x;x <- v
end
;;
class a : object val mutable x : int method set : int -> unit end


class b =
object
   val mutable y = 0
   method set v = Printf.printf "%d\n" y;y <- v
end
;;

class b : object val mutable y : int method set : int -> unit end
class c =
object (self)
   inherit a as aa
   inherit a as bb
   inherit b as cc

   method set_x_a x = aa#set x
   method set_x_a' x = bb#set x
   method set_y x = cc#set x
end
;;

Warning M: the following methods are overriden by the inherited class: set
Warning V: this definition of an instance variable x hides a previously
defined instance variable of the same name.

Warning M: the following methods are overriden by the inherited class:
set

class c :
   object
     val mutable x : int
     val mutable y : int
     method set : int -> unit
     method set_x_a : int -> unit
     method set_x_a' : int -> unit
     method set_y : int -> unit
   end

let d = new c;;
val d : c = <obj>

d#set_x_a 3;;
0
- : unit = ()

d#set_x_a' 2;;
0
- : unit = ()


When I wrote this program I expect this behavior but
according to the warnings M the result should be 3. If methods are 
overriden, the same instance variable should be change (according to the 
type of class c too). If the variable isn't change the method are not 
overriden. So because methods are not overriden, I think there is a bug 
in the warning system. The warning V look also suspicious.




Kevin.

	

	
		
___________________________________________________________________________ 
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com


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

end of thread, other threads:[~2006-02-25 12:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-25 11:01 multiple inheritance, bug or feature ? sejourne_kevin
2006-02-25 11:44 ` [Caml-list] " Jacques Garrigue
2006-02-25 11:55   ` Oliver Bandel
2006-02-25 11:48 ` Oliver Bandel
2006-02-25 12:09   ` sejourne_kevin
2006-02-25 12:16     ` Oliver Bandel
2006-02-25 12:33       ` Oliver Bandel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).