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,e64088334cf5790e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-13 10:12:48 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp4.savvis.net!uunet!dfw.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Exchanging objects between programs with different inheritance hierarchies User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Wed, 13 Nov 2002 18:12:16 GMT Content-Type: text/plain; charset=us-ascii References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:30824 Date: 2002-11-13T18:12:16+00:00 List-Id: "Steven Deller" writes: > type Top is tagged ... -- our "prime" type > type X > type A_Top is access Top'Class ; -- Only allocated objects are used > type A_X is access X ; > > Obj : A_Top ; > > X : A_X ; > > Obj := function_returning_A_top ; > > X := A_X ( Obj) ; -- This is allowed, right? No, to convert to an access type, it has to be a general access type ("access all", usually). (I'm ignoring the uninteresting case of derived access types.) > Does the conversion of an A_Top class access type to a specific A_X > access type have any code associated with it, besides a tag check? > (That is, in general does an Ada compiler have to do anything except > check the tag and copy the "pointer"?) A specific answer for GNAT would > suffice. I can't think of any reason why a compiler would have to generate any code other than the Tag check. An access value is usually represented as a machine address, and converting a machine address to a machine address is easy. ;-) > I'm guessing there is nothing except the tag check, since "all" was not > used for defining the access types, but I feel a little like I'm > tiptoeing through land mines here (I'd prefer tulips :-) ). I don't understand what you're getting at here. In most compilers, "all" has no effect on the representation of access types. Anyway, even on compilers that do funny things with *some* access types, I suspect that a whole bunch of "access all" types pointing to various places in a tagged type hierarchy will all be represented the same (whether class-wide or not). - Bob