From: sejourne_kevin <sejourne_kevin@yahoo.fr>
To: caml-list <caml-list@inria.fr>
Subject: multiple inheritance, bug or feature ?
Date: Sat, 25 Feb 2006 12:01:00 +0100 [thread overview]
Message-ID: <440038EC.5060302@yahoo.fr> (raw)
Hello :
Consider the following sample :
class a =
object
val mutable x = 0
method set v = Printf.printf "%d\n" x;x <- v
end
;;
class a : object val mutable x : int method set : int -> unit end
class b =
object
val mutable y = 0
method set v = Printf.printf "%d\n" y;y <- v
end
;;
class b : object val mutable y : int method set : int -> unit end
class c =
object (self)
inherit a as aa
inherit a as bb
inherit b as cc
method set_x_a x = aa#set x
method set_x_a' x = bb#set x
method set_y x = cc#set x
end
;;
Warning M: the following methods are overriden by the inherited class: set
Warning V: this definition of an instance variable x hides a previously
defined instance variable of the same name.
Warning M: the following methods are overriden by the inherited class:
set
class c :
object
val mutable x : int
val mutable y : int
method set : int -> unit
method set_x_a : int -> unit
method set_x_a' : int -> unit
method set_y : int -> unit
end
let d = new c;;
val d : c = <obj>
d#set_x_a 3;;
0
- : unit = ()
d#set_x_a' 2;;
0
- : unit = ()
When I wrote this program I expect this behavior but
according to the warnings M the result should be 3. If methods are
overriden, the same instance variable should be change (according to the
type of class c too). If the variable isn't change the method are not
overriden. So because methods are not overriden, I think there is a bug
in the warning system. The warning V look also suspicious.
Kevin.
___________________________________________________________________________
Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur http://fr.messenger.yahoo.com
next reply other threads:[~2006-02-25 10:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-02-25 11:01 sejourne_kevin [this message]
2006-02-25 11:44 ` [Caml-list] " Jacques Garrigue
2006-02-25 11:55 ` Oliver Bandel
2006-02-25 11:48 ` Oliver Bandel
2006-02-25 12:09 ` sejourne_kevin
2006-02-25 12:16 ` Oliver Bandel
2006-02-25 12:33 ` Oliver Bandel
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=440038EC.5060302@yahoo.fr \
--to=sejourne_kevin@yahoo.fr \
--cc=caml-list@inria.fr \
--cc=sejourne@limsi.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;
as well as URLs for NNTP newsgroup(s).