From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!ucbvax!IBM.COM!NCOHEN From: NCOHEN@IBM.COM ("Norman H. Cohen") Newsgroups: comp.lang.ada Subject: Does Ada really need MULTIPLE inheritance? Message-ID: <8910161521.AA27039@ajpo.sei.cmu.edu> Date: 16 Oct 89 13:57:09 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: Two recent workshops focused on adding support for object-oriented programming to Ada. One, sponsored by MITRE Corporation, was held September 11-13 at Woburn, Massachusetts. The Workshop on Language Issues for Reuse: Ada for the 90's, sponsored by University of Maine was held at Deer Isle, Maine, September 25-29. Specific proposals for supporting object-oriented programming in Ada were discussed at each workshop. I'll leave discussion of the details to the final workshop reports, which are now in preparation, but I do want to mention two areas of consensus reached at both workshops: (1) Ada should support inheritance. (2) There is no convincing need for MULTIPLE inheritance. Since nobody at either workshop was a strenuous advocate of multiple inheritance, I would like to see the argument for multiple inheritance presented here. Among the thoughts that contributed to the consensus AGAINST multiple inheritance were: (1) In many cases, the effect of multiple inheritance could be achieved also by instantiating a generic unit defining a subclass of a class given by a generic parameter. This allows different classes to be extended in a uniform way. (2) Multiple inheritance may seem essential in some object-oriented languages because inheritance is the only importation mechanism. Ada can get by with a WITH clause in many contexts where other languages use multiple inheritance. In Eiffel, for example, one inherits from class MATH, which has operations but no state data, to achieve the effect of WITHing a math package in Ada. (3) In some language proposals, multiple inheritance is a natural generalization of single inheritance. In other proposals, however, multiple inheritance is difficult to accommodate. For example, the view that subclasses should be treated as Ada subtypes has much going for it (for details, see my proposal "Ada Subtypes as Subclasses," Research Report RC14912, which can be obtained by writing to IBM Thomas J. Watson Research Center, Distribution Services F-11 Stormytown, P.O. Box 218, Yorktown Heights, NY 10598), but it is incompatible with multiple inheritance in a strongly typed language like Ada. (4) Many (including Bertrand Meyer) hold that the inheritance hierarchy should reflect an "is-a" relationship. That is, each instance of a subclass should be an instance of its immediate superclass(es) as well. There are a few well-known examples where the "is-a" relationship holds with multiple parents (a text window is both a text file and a window, e.g.) but such examples are rare, too rare to justify further complication of the language. (5) Multiple inheritance makes it difficult to determine the source of a subclass's features, or to determine the impact of changing the interface of a superclass. It tends to lead to undisciplined software composition that may be fine for exploratory programming but is unacceptable for the huge projects in which Ada is used, projects that require strict configuration management. Norman Cohen