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,ed1009970959aab0,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-30 19:48:50 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!feed1.news.rcn.net!rcn!elnk-atl-nf1!newsfeed.earthlink.net!newshosting.com!news-xfer2.atl.newshosting.com!24.94.170.34.MISMATCH!news-west.rr.com!news.rr.com!cyclone.kc.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!twister.socal.rr.com.POSTED!53ab2750!not-for-mail From: Michael Lamarre User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.5) Gecko/20031007 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Help with a Remote Type / Iterator Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Mon, 01 Dec 2003 03:48:49 GMT NNTP-Posting-Host: 66.91.228.213 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1070250529 66.91.228.213 (Sun, 30 Nov 2003 19:48:49 PST) NNTP-Posting-Date: Sun, 30 Nov 2003 19:48:49 PST Organization: RoadRunner - West Xref: archiver1.google.com comp.lang.ada:3043 Date: 2003-12-01T03:48:49+00:00 List-Id: Hi there. This is my first post here, so please be gentle. I'm developing a distributed Ada program at work. I have a very skilled mentor helping me, but we're having a hell of a time with one particular problem. I've included simple mock-ups of the packages/types involved below, but let me give a high-level explanation first. I have a record type I've defined in package A. In package A.CHILD, I want to define a type that is a collection of these records. For stylistic reasons, we'd rather declare all of the types in the spec and not have any incomplete type declarations in the spec. Both A and A.CHILD are REMOTE_TYPES (RT) packages. What we need is some kind of iterator for the collection type declared in A.CHILD. We've tried a passive iterator, but some of the stuff we need to do while iterating just won't work given that the passive iterator needs to take an access-to-subprogram parameter, which, in a RT package must be a remote subprogram. We need the flexibility of an active iterator. Naturally, the standard way to do this is to have an iterator type that takes an access discriminant that points at the collection the iterator is associated with. However, this won't work, as the compiler informs us that a non-remote-access type must have user-defined READ and WRITE attributes. As an access discriminant is an anonymous type, this is impossible. I tried using a named access type as the discriminant, but the code in the body for the iterator subprograms wouldn't compile, saying something like "invalid dereference of a remote access to classwide type". Anyway, here's my sample code, simplified to drastic degrees. Can anyone help me figure out how to come up with an iterator for my COLLECTION_TYPE? Is there a standard way to iterate over a remote type? Thanks in advance. -- Mike L. ---[ File: a.ads ]------------------- package A is pragma REMOTE_TYPES(A); type RECORD_TYPE is tagged limited private; type RECORD_PTR_TYPE is access all RECORD_TYPE'CLASS; -- various operations on RECORD_TYPEs. private type RECORD_TYPE is tagged limited record -- Various record fields. end record; end A; ---[ File: a-child.ads ]------------- package A.CHILD pragma REMOTE_TYPES(CHILD); type COLLECTION_TYPE(CAPACITY : NATURAL) is tagged limited private; type COLLECTION_PTR_TYPE is access all COLLECTION_TYPE'CLASS; -- Various operations on COLLECTION_TYPEs. private type REC_ARRAY_TYPE is array (NATURAL range <>) of RECORD_PTR_TYPE; type COLLECTION_TYPE(CAPACITY : NATURAL) is tagged limited record RECORD_ARRAY : REC_ARRAY_TYPE(1..CAPACITY); -- Various other fields. end record; end A.CHILD;