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,78f8f7e576439a69 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-14 13:43:57 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn1feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc04-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3B798E23.8D5B7C03@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Heterogenous_Array_Test References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 14 Aug 2001 20:43:56 GMT NNTP-Posting-Host: 12.86.36.118 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 997821836 12.86.36.118 (Tue, 14 Aug 2001 20:43:56 GMT) NNTP-Posting-Date: Tue, 14 Aug 2001 20:43:56 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:11939 Date: 2001-08-14T20:43:56+00:00 List-Id: "M. A. Alves" wrote: > > I am resuming an old thread (June 2001). I was the original poster. > Here I repost the problem with a summary review of the answers (to consult > the entire old thread you may go to "http://groups.google.com/groups", > search for "comp.lang.ada", then for "Heterogenous_Array_Test"). I do > this because *** I found the answers inconclusive *** (I do this only now > because of a conjugation of factors: I took some time trying to solve the > problem by myself; I was changing offices then and my mail reading was out > of order; the recent thread "Ambiguous reference - What is wrong with > this?" seems to deal with similar issues). > Note that you can create a heterogeneous array using access to base'class. The problem is that this creates a limited view of the array elements. They are all viewed as being type Root. You must coerce the child component back into its actual type to see the additional fields. A heterogeneous array of this sort is most easily used when calling overridden subprograms. This allows the subprogram calls to be dynamically dispatched. procedure Heterogenous_Array_Test is type Root is tagged record Root_Component: Integer := 0; end record; type Child is new Root with record Child_Component: Integer := 0; end record; type Class_Ptr is access Root'Class; Item: array(1 .. 2) of Class_Ptr := ( 1 => new Root, 2 => new Child); begin Item(1).Root_Component := 11; Item(2).Root_Component := 21; child(Item(2).all).Child_Component := 22; -- error fixed end; Jim Rogers Colorado Springs, Colorado USA