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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,78f8f7e576439a69,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-14 12:11:59 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: "M. A. Alves" Newsgroups: comp.lang.ada Subject: Heterogenous_Array_Test Date: Tue, 14 Aug 2001 20:12:46 +0000 (GMT) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: avanie.enst.fr 997816314 7543 137.194.161.2 (14 Aug 2001 19:11:54 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 14 Aug 2001 19:11:54 +0000 (UTC) To: Return-Path: X-X-Sender: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:11931 Date: 2001-08-14T20:12:46+00:00 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). The problem is implementing an heterogenous array. Candidate code: 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; Item(2).Child_Component := 22; -- error: no selector "Child_Component" for type "Root'Class" end; Ehud Lamm confirmed that "the approach is ok". The code has an error near the end. Originally I asked for explanation of the error. That was done. But no working solution was given. Ted Dennison suggested changing the offending line to Child'(Item(2).all).Child_Component := 22; That is intuitive (as was the original to me), but also does not compile. Ehud Lamm posted an example for derivation and dispatching, but NOT for the original problem of an heterogenous array. Thanks all very much, -- , M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121 A M A D O Rua Campo Alegre, 823 fax 351+226003654 A L V E S P-4150 PORTO, Portugal mob 351+939354002