Version française
Home     About     Download     Resources     Contact us    
Browse thread
multiple inheritance, bug or feature ?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: sejourne_kevin <sejourne_kevin@y...>
Subject: multiple inheritance, bug or feature ?
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