From: Frederic Tronel <Frederic.Tronel@inrialpes.fr>
To: caml-list@inria.fr
Subject: [Caml-list] A question about classes and multiple inheritance
Date: Thu, 23 May 2002 10:51:32 +0200 [thread overview]
Message-ID: <3CECAD94.69976221@inrialpes.fr> (raw)
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
next reply other threads:[~2002-05-23 8:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-23 8:51 Frederic Tronel [this message]
2002-05-23 9:52 ` Jacques Garrigue
2002-05-23 11:04 ` Frederic Tronel
2002-05-24 0:29 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CECAD94.69976221@inrialpes.fr \
--to=frederic.tronel@inrialpes.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox