caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] A question about classes and multiple inheritance
@ 2002-05-23  8:51 Frederic Tronel
  2002-05-23  9:52 ` Jacques Garrigue
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Tronel @ 2002-05-23  8:51 UTC (permalink / raw)
  To: caml-list

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


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

end of thread, other threads:[~2002-05-24  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-23  8:51 [Caml-list] A question about classes and multiple inheritance Frederic Tronel
2002-05-23  9:52 ` Jacques Garrigue
2002-05-23 11:04   ` Frederic Tronel
2002-05-24  0:29     ` Jacques Garrigue

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).