Newsgroups: comp.object,comp.lang.eiffel,comp.lang.c++,comp.lang.beta,comp.lang.ada Path: news.daimi.aau.dk!news.uni-c.dk!sunic!sunic.sunet.se!trane.uninett.no!Norway.EU.net!EU.net!howland.reston.ans.net!math.ohio-state.edu!newsfeed.acns.nwu.edu!ftpbox!mothost!schbbs!news From: shang@corp.mot.com (David L. Shang) Subject: Re: Multiple Inheritance (was Re: Has C++ had its day?) Reply-To: shang@corp.mot.com Organization: MOTOROLA Date: Fri, 7 Jul 1995 15:14:08 GMT Message-ID: <1995Jul7.151408.11136@schbbs.mot.com> References: <3ti7hd$6hu@steel.interlog.com> Sender: news@schbbs.mot.com (SCHBBS News Account) Nntp-Posting-Host: 129.188.128.126 Lines: 73 Xref: news.daimi.aau.dk comp.object:33062 comp.lang.eiffel:8988 comp.lang.c++:127726 comp.lang.beta:440 comp.lang.ada:30196 In article <3ti7hd$6hu@steel.interlog.com> herbs@interlog.com (Herb Sutter) writes: > I'd be happy to hear how other languages support mixins (mixing in both > interface and behaviour) without MI... do we have any examples? I'll cross post this subject into some language groups in order to get more suggestions and opinions from different language people. Consider what features should be inherited, there are three kinds of multiple inheritance: W1. MI on interface W2. MI on interface and behavior W3. MI on interface, behavior, and instance variable Consider how features should be inherited, there are three kinds of multiple inheritance too: H1. Base is duplicated n times if it is inherited n times H2. Base is duplicated exactly once H3. Base is shared, never duplicated H3 is dynamic inheritance, which is usually used by dynamic languages that do not use the concept of class or do not use class as an abstraction type. We do not consider H3 here. C++ supports W1, W2, W3, H1, and H2. For H2, virtual base is used, should the base be inherited repeatedly. Thus C++ chose H1 as default MI rule. Eiffel supports W1, W2, W3, H1 and H2. For H1, renaming should be used, should the base be inherited repeatedly. Thus Eiffel chose H2 as default MI rule. Java supports W1 and H2. Since methods defined in interface are abstract (or pure virtual, i.e. no implementation), there is no need to have multiple copies of an interface (note that two interface with a same name but different signatures are considered different interfaces). H1 can always be simulated by composition as shown in Beta. H1 can also be simulated by parameterization. But H2 cannot be simulated. That is why H2 is the real value of MI. Therefore, Eiffel's choice of H2 as default is clever than C++. However, chosing H2 (with W2 and W3) as default has penalty. It might need indirect linking to the base (super) part even MI is not used. I don't know how Effel's implementation solves this problem. Can any people from Eiffel group address this question? Using H2 with only W1 as in Java has no penalty on SI. So, the question is, are W2 and W3 really required? Or, is W1 and H2 sufficient to support all the requirement of multiple inheritance? If so, Java's decision is correct. The major purpose of W2 and W3 is for reuse of implementation; while the major purpose of W1 is for polymorphism. I think we should have a way to use SI, composition and parameterization, together with W1, to achieve the effects of W2 and W3. Any examples are apprieciated. David Shang