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-23 00:56:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!yellow.newsread.com!netaxs.com!newsread.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!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: Tue, 23 Sep 2003 10:04:41 +0200 Message-ID: References: <568ede3c.0309160929.1d0d3d95@posting.google.com> <3F67AFB9.7040001@attbi.com> <3F6F0841.60607@attbi.com> <1064244399.683441@master.nyc.kbcfp.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 1064303779 4262334 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:42778 Date: 2003-09-23T10:04:41+02:00 List-Id: On Mon, 22 Sep 2003 11:26:39 -0400, Hyman Rosen wrote: >Robert I. Eachus wrote: >> No, it is not a moot point in Ada. > >I still don't think we're talking about the same thing. > >Suppose we have the following C++ situation: I have two >class types, IFoo and IBar, that are not under my control >(they come from two separate libraries, perhaps). > >I am given a container of pointers to IFoo. Since C++ has >MI, it's possible that some of these IFoo pointers are >actually pointers to objects of a class which inherit both >from IFoo and IBar. Such a class can be created independently >of the definitions of IFoo and IBar. In any case, I do not >have access to the definitions or names of such classes, and >at the time I am given the following task, such classes may >not even exist yet. > >I am tasked with finding such IFoo+IBar pointers in the >container and handing them off to a procedure which expects >to get IBar pointers. In C++, the solution is simple - given >an IFoo pointer, I call dynamic_cast on the pointer. >If the result is non-null, then I have a valid IBar pointer, >and I know that the underlying object inherits from both. > >So, does Ada have an equivalent to this? Remember, you do not >control IFoo, IBar, the container type, or the implementation >of the type which is trying to be the combination of an IFoo >and an IBar. I think it is a good example of bad design. (:-)) It does not prove a necessity of MI (*) Returning to the topic, the container of access IFoo'Class (an equivalent to C++ &IFoo) has the contract to keep objects of IFoo. It is a bad design if casting to IBar is required. There should be either a specialized container (**). Alternatively, the design of the container should provide some identification methods, i.e. the container should know something about IBar. What I wished to say is that your example is bad, because MI is not supposed to remedy one's design faults. --- (*) MI need not to be advocated. It is like to prove whether negative numbers are necessary. Opponents might provide you with a plethora of work-agounds, they will tell you how unsafe are negative numbers are (when used to count crows), how difficult to a compiler to support them (because you need '-' and '+' in the character set), etc (:-)) You will never win this game! --- (**) BTW a great unsolvable problem in both Ada and C++, both with MI or without, is to make a container of a subtype a subtype of the container of the base type. Which highlights present problems with ADT and *helpless* attempts to solve this using templates. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de