Article View: comp.lang.eiffel
Article #1287Multiple inheritance and dynamic binding.
From: Mikael Degermark
Date: Wed, 11 Jan 1989 13:09
Date: Wed, 11 Jan 1989 13:09
62 lines
2591 bytes
2591 bytes
<greeting phrase>
I have recently read the Book by Meyer, and found it very interesting.
Eiffel seems to be a language worth trying, and I hope to be able to do so
in the near future.
When reading about multiple inheritance, there was something which I
wasn`t able to understand at first, and after discussing it with my colleagues
(which didn`t have any solution either), I'm now asking You to help me.
The problem conserns the DRIVER, FRENCH_DRIVER, US_DRIVER, FRENCH_US_DRIVER
example given in the book (no, I haven't got the page reference),
here is a condensed version:
Assume there is a class A that declares and exports a feature f:INTEGER.
Assume there is two other classes B and C which each inherit A.
Assume a fourth class D that inherits both B and C and renames f:
class D export f_b, f_c
inherit B rename f as f_b;
inherit C rename f as f_c;
...
Now, an instance of D has two distinct integer features f_b, f_c.
Consider the following fragment of eiffel: (I hope it is eiffel ;->)
a:A;
b:B;
c:C;
d:D;
...
d.Create;
a := d; -- legal, A is an ancestor to D.
b := d; -- legal, B is an ancestor to D.
c := d; -- legal, C is an ancestor to D.
if b.f = ... -- this should be the same as d.f_b, right?
if c.f = ... -- this should be the same as d.f_c, right?
if a.f = ... -- here is the problem!
PROBLEM: Which of the features d.f_b and d.f_c is denoted by a.f?
The type-checking is supposed to prevent use of undefined features,
but there doesn't seem to be any sensible way to decide which of d.f_a and
d.f_b is denoted by a.f when the dynamic type of a is D.
So, is it d.f_a? or d.f_b? or neither? it couldn't be both, surely?
Actually, I suspect that there will be problems with b.f and c.f also,
consider the implementation.
Hopefully, those of You who have access to a compiler could try it and
tell me how it works. Would also like comments on how it *ought* to be.
Thanks!
Mikael Degermark email: micke@sm.luth.se
Dept. of CS
U. of LULE] (read ] as an A with a ring)
Sweden
Technical Details
Message-ID:
<203@my2.luth.se>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!luth!mickeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!enea!kth!luth!micke
From: micke@sm.luth.se (Mikael Degermark)
Newsgroups: comp.lang.eiffel
Subject: Multiple inheritance and dynamic binding.
Message-ID: <203@my2.luth.se>
Date: 11 Jan 89 13:09:38 GMT
Reply-To: Mikael Degermark <micke@my.sm.luth.se>
Organization: University of Lulea, Sweden
Lines: 62
UUCP-Path: {uunet,mcvax}!enea!my.sm.luth.se!micke