comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Use of abstract tagged types without access types -- again and complete
Date: Thu, 09 Jun 2011 22:41:57 +0200
Date: 2011-06-09T22:41:58+02:00	[thread overview]
Message-ID: <4df13015$0$7616$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <53347692-e182-4f2f-8598-453af64e16fc@w36g2000vbi.googlegroups.com>

On 6/9/11 7:50 PM, Prof. Dr. Carl Weierstrass wrote:
> This doesn't work, because:
> class-wide subtype with unknown discriminants in component declaration
>
> Of course I could use an access type to avoid the error but is there a
> way to
> do something like this without access types.

You can defer access types if this helps. An outline is below.
Maybe the SPARK people know how one may add polymorphic types
without pointers, or not.


with Test;
package Test_Test is

     generic
         type Expanded_Child_Type is new Test.Child_Type with private;
     package Child_Pick is
         type Some_Parent is new Test.Parent_Type with record
             Child : Expanded_Child_Type;
         end record;
     end Child_Pick;

     package Pick_1 is new Child_Pick (Test.Child_Type_1);

     package Pick_N is new Child_Pick (Test.Child_Type_N);

end Test_Test;


with Test, Test_Test;
procedure Test_Test_Test is
     type Ref is access Test.Parent_Type'Class;

     X : Ref := new Test_Test.Pick_1.Some_Parent;
     Y : Ref := new Test_Test.Pick_N.Some_Parent;
begin
     X := Y;
end Test_Test_Test;





      parent reply	other threads:[~2011-06-09 20:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 17:50 Use of abstract tagged types without access types -- again and complete Prof. Dr. Carl Weierstrass
2011-06-09 20:19 ` Ludovic Brenta
2011-06-09 21:06   ` Randy Brukardt
2011-06-10 15:43     ` Prof. Dr. Carl Weierstrass
2011-06-12 12:05       ` Alex R. Mosteo
2011-06-09 20:41 ` Georg Bauhaus [this message]
replies disabled

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