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 X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-22 08:34:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-server.caltech.edu!attla2!ip.att.net!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail Message-ID: <3F6F1688.9030903@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> <3F6079A9.6080108@attbi.com> <3F60E380.4020307@attbi.com> <3F694186.5060709@crs4.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc53 1064244861 24.34.139.183 (Mon, 22 Sep 2003 15:34:21 GMT) NNTP-Posting-Date: Mon, 22 Sep 2003 15:34:21 GMT Organization: Comcast Online Date: Mon, 22 Sep 2003 15:34:21 GMT Xref: archiver1.google.com comp.lang.ada:42750 Date: 2003-09-22T15:34:21+00:00 List-Id: Ole-Hjalmar Kristensen wrote: >>>>>>"JSA" == Jacob Sparre Andersen writes: >>>>> > > JSA> Olehjalmar Kristensen wrote: > >>>>>>> "RIE" == Robert I Eachus writes: > > RIE> interfaces and mix-ins. But type inheritance cannot be from two > RIE> concrete parents, no matter what the language--one parent has to be > RIE> abstract. So anyone who condemns Ada for not adding what cannot be > RIE> done needs to get a life. > >> What do you mean by "concrete parents"? > > > JSA> Although I agree that "non-abstract parents" is the most obvious > JSA> interpretation of "concrete parents", I understood it as > JSA> "data-containing non-abstract parents". I would say that two non-abstract parents without data is a special case I was ignoring. You have a potential problem if two concrete types have different state data, or identical states with different meanings. > I understand now, by see below. Exactly. The Ada "workarounds" for this issue are the same. If you want to inherit from two parents which both access the same state data, you can push the state to a common parent. If the states are independent, you can use mix-ins that add state, but only see their own state variables. Or if you need for one class to see the other's state but not vice-versa, you can import the methods of one parent class into the min-in for the other. But if you want to inherit from two classes with state, and adjust the state of each based on changes to the other, the na�ve implementation isn't possible in Ada, and causes indefinite recursion in C++. In C++ you can compile it, but unless you break the recursion, you can't run it. In Ada you can't compile some versions without breaking the recursion. That doesn't say you can't write indefinite recursion or infinite loops to implement this "abstraction" in Ada. It is just that there are some implicit cases that are not allowed. Back to the example of polar and cartesian co-ordinates. It is possible to do things so that the Get operations are all inherited from the respective classes, but the Set operations have to be overridden for the child class--and carefully so you don't do unintended recursion. (To do it without adding additional operations or state is possible, but left as an exercise for the reader, in Ada or C++ whichever you prefer. And please, don't post it. The practical solution does add extra state and uses lazy evaluation of the conversions between types.) So as usual, the IDEA of multiple inheritance is powerful. But in any case where you try to take advantage of "true" MI, there are implementation specific issues to be resolved. So why is MI theory so common? Because it is such a nice formalism for use in preliminary design. I can say that this dataset is a list and it is a indexed array. During detailed design, I can choose the actual abstraction used to implement the dataset for performance reasons, which could be an indexed file, or a B-tree. -- Robert I. Eachus Ryan gunned down the last of his third white wine and told himself it would all be over in a few minutes. One thing he'd learned from Operation Beatrix: This field work wasn't for him. --from Red Rabbit by Tom Clancy.