comp.lang.ada
 help / color / mirror / Atom feed
From: "Steven Deller" <deller@smsail.com>
Subject: RE: Exchanging objects between programs with different inheritance hierarchies
Date: Wed, 13 Nov 2002 11:22:55 -0600
Date: 2002-11-13T11:22:55-06:00	[thread overview]
Message-ID: <mailman.1037208122.11836.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <200211131218.NAA13957@bulgaria.otn.eurocopter.de>

> -----Original Message-----
> From: comp.lang.ada-admin@ada.eu.org
> [mailto:comp.lang.ada-admin@ada.eu.org] On Behalf Of Grein, Christoph
> You should have a look at the attribute 'External_Tag. ...

Christoph,
Thanks.  As I thought about the problem last night without an RM handy,
I wondered if one could rep spec the external tag.  Lo and behold, one
can!!!  Just rep spec the derived types, use 'Class'Output/Input on the
"prime" type and we are cooking :-).  Don't even have to override the
default type outputs as long as the same compiler is used on machines
with the same endian-ness.

Love that Ada.

One other question.  Suppose I have
   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?

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'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 :-) ).

Oh -- does C++ have anything similar for easy exchange of different
class objects across a single stream (without knowing ahead of time
which object is to be read)?  If not, this is another big win for Ada
:-).

Regards,
Steve



   








       reply	other threads:[~2002-11-13 17:22 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 ` Steven Deller [this message]
2002-11-13 18:12   ` Exchanging objects between programs with different inheritance hierarchies Robert A Duff
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