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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,35b23727c41f3e62 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-30 11:18:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!news.tufts.edu!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!spool0900.news.uu.net!reader0902.news.uu.net!not-for-mail Date: Tue, 30 Jul 2002 14:20:30 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.1b) Gecko/20020721 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Multiple interface inheritance workaround in Ada 95 / Ada 0x to satisfy a Java language advocate? References: <1028042914.262359@master.nyc.kbcfp.com> <3D46CE25.5010102@worldnet.att.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1028053093.903476@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1028053095 reader2.ash.ops.us.uu.net 25322 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:27487 Date: 2002-07-30T14:20:30-04:00 List-Id: Jim Rogers wrote: > In Java all classes have an ultimate shared ancestor, the Object > class. True, but not really relevant since Object is above (below?) the interfaces. If I have Class C extends Object implements I1, I2 then if I know my I1 is a C then I know it's also an I2, but knowing that my I1 is an Object doesn't tell me anything. > procedure f(item : in I1_Access) > if item.all in I2'Class then > > Note that this performs a lookup similar to what you describe. But it's much simpler in Ada, since there is neither multiple inheritance nor interfaces. For the test to be potentially true, either I1 must be a subclass of I2, in which case the test succeeds immediately, or I2 is a subclass of I1, in which case we must actually examine item to see whether it inherits from an I2-derived class. If I1 and I2 are unrelated, the test will always be false, which is not true for C++ or Java. C++ (and maybe Java also) has additional issues because the base class might not be accessible due to non-public inheritance, or there may be more than one I2 in the inheritance graph.