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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e64088334cf5790e,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-12 18:19:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst.fr!not-for-mail From: "Steven Deller" Newsgroups: comp.lang.ada Subject: Exchanging objects between programs with different inheritance hierarchies Date: Tue, 12 Nov 2002 20:19:52 -0600 Organization: Smooth Sailing LLC 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" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1037153943 5279 137.194.161.2 (13 Nov 2002 02:19:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 13 Nov 2002 02:19:03 +0000 (UTC) Return-Path: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-reply-to: <3DC93287.2EA290F0@myob.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Importance: Normal Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk X-Reply-To: List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:30789 Date: 2002-11-12T20:19:52-06:00 Ada experts, We are in the process of trying to convert some code to GNAT that worked on another Ada compiler. The code transmits tagged type objects between processes, and uses unchecked conversion at the receiving end to convert to the destination object type. The objects are various types derived from a "base" object with identical inheritance "path", but not identical inheritance hierarchies. Using unchecked_conversion depends on the tags being integral to the record structures. On GNAT they are not, so the code fails. The code is clearly incorrect Ada. My question is, what this a reliable, portable way to do that transfer. The "solution" should only involve reasoning from the Ada RM, not any detailed knowledge of any compiler, including GNAT. I believe streams and 'Class'Output and 'Class'Input may be the answer, but find myself unable to fully understand the RM's "contract" with regard to writing, and then reading, tagged type objects. I assume 'Class'Input will correctly work when the same *process* performed the 'Class'Output. What about the same *program* running as one *process* doing the 'Class'Output and as another *process* of the same program doing the 'Class'Input? (That is, is an Ada compiler allowed to build tag information at elaboration time, with possible variations from run to run?) What about different programs, but with the identical inheritance hierarchy for the types in question? (There might be other differing type hierarchies, but not for the types being transmitted.) Finally, the 64K question. What if the inheritance hierarchies differ, but transmission is limited to types that have the identical inheritance "path" within the hierarchy? For a specific example, assume the following hierarchy in program X Top ( A (aa,ab), B (ba,bb) ) and the following in program Y Top( A (aa,ac), B (bb), C(ca,cb) ) i.e. aa is derived from A and A from Top in both programs, using identical type names and identical type definitions (from the same sources, but not necessarily compiled on the same system.) If X uses Top'Class'Output to write an object of type Top.A.aa and Y uses Top'Class'Input to read the object, will Y have a valid Top.A.aa in Y with the same data values as were in X? If X outputs Top.A.ab, what happens in Y when it tries a 'Class'Input? (Constraint_Error?, erroneous program with bounded error? something else?). One last question, which does not affect this particular effort, but could affect future work. What if the inheritance hierarchies are identical in structure, but not in the particular names used for the various types and components. Is there anything in 'Class'Output/Input that would permit exchanging those structurally-equivalent and inheritance-equivalent types? Regards, Steven Deller