comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Exchanging objects between programs with different inheritance hierarchies
Date: Wed, 13 Nov 2002 18:12:16 GMT
Date: 2002-11-13T18:12:16+00:00	[thread overview]
Message-ID: <wccsmy5fif3.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: mailman.1037208122.11836.comp.lang.ada@ada.eu.org

"Steven Deller" <deller@smsail.com> writes:

>    type Top is tagged ...  -- our "prime" type
>    type X <derived from Top>
>    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



  reply	other threads:[~2002-11-13 18:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200211131218.NAA13957@bulgaria.otn.eurocopter.de>
2002-11-13 17:22 ` Exchanging objects between programs with different inheritance hierarchies Steven Deller
2002-11-13 18:12   ` Robert A Duff [this message]
2002-11-13 12:18 Grein, Christoph
     [not found] <3DC93287.2EA290F0@myob.com>
2002-11-13  2:19 ` Steven Deller
2002-11-13  6:05   ` Jim Rogers
2002-11-13 15:54     ` Simon Wright
2002-11-13 17:44       ` tmoran
2002-11-14  6:29         ` Simon Wright
2002-11-13 17:59   ` Jeffrey Carter
2002-11-13 18:23     ` Robert A Duff
2002-11-13 23:17       ` Steven Deller
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox