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-11 01:45:38 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? Date: Thu, 11 Sep 2003 10:53:12 +0200 Message-ID: References: <3F5F7FDC.30500@attbi.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1063269937 22563275 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:42374 Date: 2003-09-11T10:53:12+02:00 List-Id: On Wed, 10 Sep 2003 19:47:46 GMT, "Robert I. Eachus" wrote: >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. Ada is not PL/1, if the compiler finds a problem it should not invent a work-around, but just spit an error message. (:-)) > 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...) It is a good example and it shows that there should be both implementation and interface inheritance. Then for interface inheritance, it should be possible to inherit from concrete (non-abstract) types. In the case of multiple views on the SAME point object, it is clear that implementation x 2 inheritance would be a wrong solution, because it would define a 4D point! A right solution is either: 1. implementation inheritance from either Cartesian or Polar point and interface inheritance from another. 2. interface inheritance from both. But this does not prove that multiple implementation inheritance has no place. >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. Absolutely. Interface inheritance opens a way to true ADT. Just allow to inherit from an access type and you will have the user-defined ones. Allow to inherit from an array and you will have array-looking containers, user-defined unbounded strings etc. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de