English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] A question about classes and multiple inheritance
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frederic Tronel <Frederic.Tronel@i...>
Subject: [Caml-list] A question about classes and multiple inheritance

I have the following problem.
If I define two classes like this:

class virtual behaviorSpecElement = object (this) 

    /* To be refined by subclasses */
    method virtual localPreBehavior : (string,string) Hashtbl.t  ->
    /* Defined by  specElement */	
    method virtual preBehavior  : (string,string) Hashtbl.t stack ->
virtual ['a] specElement =

  inherit behaviorSpecElement as super
  fun (synchroAccounting : 'a) ->
  object (this)  
	<snip> ....
	method preBehavior bindings =
      		let binding = bindings#top in
      		let myPre = this#localPreBehavior binding in
      		bindings#popSP ;
      		let superPre = super#preBehavior bindings in
      		bindings#pushSP ;
	<snip> ...

The problem is the compiler complains about the fact that 
super has no preBehavior defined. Of course this is the case 
because super is statically resolved and virtual here. 
Instead if I give a dummy definition for method preBehavior in 
behaviorSpecElement like this one:

method localPreBehavior (binding : (string,string) Hashtbl.t) = Null (*
a constructor
of the type specBehavior *)

it seems that super is statically resolved and when I overload
localPreBehavior in subclasses
of specElement, the dummy localPreBehavior is called instead of the
"right" one.

Is there a way to solve this problem ?
"super" must be dynamically resolved at run-time, is it compatible with
multiple inheritance ?


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