From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA28957; Thu, 23 May 2002 10:53:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA29090 for ; Thu, 23 May 2002 10:53:21 +0200 (MET DST) Received: from ebene.inrialpes.fr (ebene.inrialpes.fr [194.199.18.70]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g4N8rLT08105 for ; Thu, 23 May 2002 10:53:21 +0200 (MET DST) Received: from pop-serv.inrialpes.fr (pop-serv.inrialpes.fr [194.199.18.66]) by ebene.inrialpes.fr (8.11.6/8.11.6) with ESMTP id g4N8pX418290 for ; Thu, 23 May 2002 10:51:33 +0200 (MEST) Received: from inrialpes.fr (cime.inrialpes.fr [194.199.23.76]) by pop-serv.inrialpes.fr (8.11.3/8.11.3/ImagV2) with ESMTP id g4N8pXG26080 for ; Thu, 23 May 2002 10:51:33 +0200 (MEST) Message-ID: <3CECAD94.69976221@inrialpes.fr> Date: Thu, 23 May 2002 10:51:32 +0200 From: Frederic Tronel X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.8 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: caml-list@inria.fr Subject: [Caml-list] A question about classes and multiple inheritance Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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) .... method preBehavior bindings = let binding = bindings#top in let myPre = this#localPreBehavior binding in bindings#popSP ; let superPre = super#preBehavior bindings in bindings#pushSP ; ... 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