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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-10 12:47:47 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3F5F7FDC.30500@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc02 1063223266 24.34.139.183 (Wed, 10 Sep 2003 19:47:46 GMT) NNTP-Posting-Date: Wed, 10 Sep 2003 19:47:46 GMT Organization: Comcast Online Date: Wed, 10 Sep 2003 19:47:46 GMT Xref: archiver1.google.com comp.lang.ada:42358 Date: 2003-09-10T19:47:46+00:00 List-Id: Hyman Rosen wrote: > Thereby exhibiting the simple lack of courage to add multiple > inheritance. Why should we limit to inheriting from one type? > What is it about one that makes it better than two or more? Actually with interfaces added, Ada will have two ways of doing multiple inheritance, mix-ins and interfaces. This is fine because each is a solution for different design idioms. Why not add "full" multiple inheritance and be done with it? Sorry there is no such thing. Or if you prefer, deriving from several interface classes with no privileged parent does exactly that. What having a single parent allows is inheriting both an interface and an implementation. You can't inherit multiple implementations, at least not and have a single concrete implementation. Let me give an example so you can see the problems. Let's say I have two point types, one of which uses Cartesian coordinates, one of which uses polar coordinates. How do I implement multiple inheritance of both representations? It can't be done. A representation that stored both cartesian and polar coordinates would be possible. But the compiler can't automatically generate the code to insure that both representations agree. In fact if you think about the representable points in both representations, they are different sets! Some points are in both sets, for example those on the X and Y axis but almost all points in one representation do not have exact representations in the other. In addition, some of the points in the cartesian domain will be at least (Sqrt(2)-1) * Element'Last away from any point in the polar domain. Notice that if I do interface inheritance from the two concrete types, I can program the underlying routines to do something sensible when say adding a polar displacement to a cartesian point. By the way, notice that in Ada if I want I can provide a type with both cartesian and polar implementations. As a programmer, I can go further and add the "missing" operations like adding a cartesian point to a polar point. Do everything right and "+" will just work. That is a kind of multiple implementations of a type that I can live with, and I don't know of any other language where you can do such overloading. (It is tricky enough to get right in Ada...) Interface inheritance will make doing this sort of thing easier in Ada. But even now, Ada is providing more multiple inheritance than many languages which are accepted as having "full" multiple inheritance. Sorry if that doesn't satisfy you. -- Robert I. Eachus "As far as I'm concerned, war always means failure." -- Jacques Chirac, President of France "As far as France is concerned, you're right." -- Rush Limbaugh