From: Simon Wright <simon@pushface.org>
Subject: Re: Declaring constants for a abstract tagged type and concrete sub classes
Date: Mon, 06 Jul 2015 16:42:17 +0100
Date: 2015-07-06T16:42:17+01:00 [thread overview]
Message-ID: <lypp45xpgm.fsf@pushface.org> (raw)
In-Reply-To: 0ade6abf-34c0-46e2-8bd9-d60a00056321@googlegroups.com
Serge Robyns <serge.robyns@gmail.com> writes:
> package Abstract_Root is
> type T_Root is abstract tagged with private;
> procedure Set_XYZ (Self: in out T_Root; ABC : in Integer);
> function Get_XYZ (Self: in T_Root) return Integer;
> private
> type T_Root is abstract tagged record
> XYZ : Integer;
> end record;
> end Abstract_Root;
> package Concrete is
> type T_Concrete is new T_Root with private;
> No_Element : constant T_Concrete;
> ....
> private
> type T_Concrete is new T_Root with record
> ...
> end record;
> No_Element : constant T_Concrete := (Abstract_Root.No_Element, ...);
> end Concrete;
You could write
with Abstract_Root;
package Concrete is
type T_Concrete is new Abstract_Root.T_Root with private;
No_Element : constant T_Concrete;
private
type T_Concrete is new Abstract_Root.T_Root with record
ABC : Integer;
end record;
No_Element : constant T_Concrete
:= (Abstract_Root.T_Root with ABC => -42);
end Concrete;
(or whatever will suit you)
but I think you'll have to give T_Root.XYZ an equivalent default value,
or equality won't work.
next prev parent reply other threads:[~2015-07-06 15:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-06 10:10 Declaring constants for a abstract tagged type and concrete sub classes Serge Robyns
2015-07-06 11:55 ` G.B.
2015-07-06 13:49 ` Serge Robyns
2015-07-06 17:36 ` G.B.
2015-07-07 16:27 ` Serge Robyns
2015-07-07 17:21 ` G.B.
2015-07-07 19:51 ` Serge Robyns
2015-07-07 20:14 ` Simon Wright
2015-07-07 20:18 ` Jeffrey R. Carter
2015-07-06 15:42 ` Simon Wright [this message]
2015-07-06 16:35 ` Serge Robyns
2015-07-06 17:02 ` Bob Duff
2015-07-06 21:16 ` Serge Robyns
2015-07-06 17:30 ` gautier_niouzes
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox