Browse thread
[Caml-list] A question about classes and multiple inheritance
- Frederic Tronel
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2002-05-23 (08:53) |
From: | Frederic Tronel <Frederic.Tronel@i...> |
Subject: | [Caml-list] A question about classes and multiple inheritance |
Hello, 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 -> specBehavior /* Defined by specElement */ method virtual preBehavior : (string,string) Hashtbl.t stack -> specBehavior end and 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> ... end 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 ? Thanks, Frederic. ------------------- 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