comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Upcasting
Date: Tue, 5 Nov 2002 12:49:25 +0000 (UTC)
Date: 2002-11-05T12:49:25+00:00	[thread overview]
Message-ID: <slrnasffii.pj.lutz@taranis.iks-jena.de> (raw)
In-Reply-To: pan.2002.11.05.11.43.31.117258@greenroom.com.au

* Matthew Baulch wrote:
> My question is: How would you do this 'upcasting' if varying
> types existed? Obviously the compiler could tell where each
> value must go based on their type if only one of their type
> was needed in the transition. How does this type of thing work?
> (or does the A95 compiler not allow it)

procedure t is
   type Base is tagged null record;
   type Derivated is new Base with null record;

   d  : Derivated;
   dc : Base'Class := d;
   b  : Base       := Base(d);
   bc : Base'Class := b;
begin
-- d := Base (b);       -- will not compile
   d := Derivated (dc);
   d := Derivated (bc); -- will raised CONSTRAINT_ERROR on run time
end t;



  reply	other threads:[~2002-11-05 12:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05 11:43 Upcasting Matthew Baulch
2002-11-05 12:49 ` Lutz Donnerhacke [this message]
2002-11-05 17:33 ` Upcasting Stephen Leake
2002-11-06  6:26   ` Upcasting Matthew Baulch
2002-11-06 15:18 ` Upcasting Georg Bauhaus
replies disabled

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