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 06:33:45 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_feed4!attbi.com!sccrnsc02.POSTED!not-for-mail Message-ID: <3F6079A9.6080108@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: <3F5F7FDC.30500@attbi.com> 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 1063287218 24.34.139.183 (Thu, 11 Sep 2003 13:33:38 GMT) NNTP-Posting-Date: Thu, 11 Sep 2003 13:33:38 GMT Organization: Comcast Online Date: Thu, 11 Sep 2003 13:33:43 GMT Xref: archiver1.google.com comp.lang.ada:42377 Date: 2003-09-11T13:33:43+00:00 List-Id: Hyman Rosen wrote: > Quite appropriately for an Ada newsgroup, you are setting up a > straw man argument. The most typical use for multiple inheritance > involves inheriting from unrelated classes. And in C++, combining > multiple inheritance and templates is extraordinarily powerful. I used a simple example to make my argument more concrete. But the argument doesn't depend on the example. If you have two completely non-interacting roles that you want to combine in a single type, Ada already supports that type of MI very well through mix-ins. But when you want to inherit from two types that have operations in common, it doesn't work without additional coding no matter what the language. > In any case, examples of cases where multiple inhertiance is not > appropriate are not arguments against multiple inheritance. If I > gave you an example where tasking was inappropriate, would that be > an argument to remove it from the language? But the case I gave is one where multiple inheritance is appropriate. It just has to be interface inheritance. In other words I can take an interface that assumes polar representation and an interface that assumes cartesian representation, and provide a type/class that supports both interfaces. The point it though, that there is work to be done to convert between polar and cartesian representation, and the compiler can't do that automatically. It takes work--and thought--by the programmer creating the class. Ada won't change that, nor will any language that supports multiple inheritance. What Ada 200Y is planning to do is to make it easier to do the makework part of that. You could directly inherit from a cartesian type and add the polar functions through an interface, or vice-versa. Or you could bring in both representations through interface inheritance and do more implementation work. What you can't do, in Ada or any language is inherit directly from two types/classes with different state and get other than junk. Let me follow through on that, since you didn't seem to get it. The Cartesian implementation might have a representation: type Cartesian is record X,Y: Float; end record; and the Polar type: type Polar is record R, Theta: Float; end record; we could even have a pair of procedures: procedure Set_Point(P: Cartesian; X,Y: Float) is begin P := (X,Y); end Set_Point; procedure Set_Point(P: Polar; R,Theta: Float) is begin P := (R, Theta); end Set_Point; But for the union type, at least one of those implementations has to be wrong. For example, if the ACTUAL representation is cartesian, we need: procedure Set_Point(P: Union; R, Theta: Float) is begin P := (R * sin (Theta), R * cos (Theta)); end Set_Point; (Of course, in an actual implementation I would have different derived types for X and Y, R, and Theta, and Theta would probably be a fixed-point type. But let's ignore that for now.) This is why the new interfaces in Ada will allow direct derivation from one type, and adding in as many interfaces as you wish. Or, if you prefer, no direct derivation and lots of interfaces. But you can only directly derive from one parent type, because that is the way the world works, not due to any limitations we are building into Ada. Notice that in my example, which was why I chose it, that the actual implementation of the two potential parent types may match. But the MEANINGS of the data fields are different. Of course, if you want to inherit from types A and B in Ada, and the contents of A can be expressed as a subset of the contents of B, you can already do that in Ada: type A is... ... type B is new A with...; ... type C is new B...; -- 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