comp.lang.ada
 help / color / mirror / Atom feed
* Why no abstract non-tagged types?
@ 2014-02-21  3:04 Britt
  2014-02-21  8:33 ` Dmitry A. Kazakov
  2014-02-24 23:12 ` Shark8
  0 siblings, 2 replies; 6+ messages in thread
From: Britt @ 2014-02-21  3:04 UTC (permalink / raw)


Recently I've been wishing I could declare some otherwise conventional enumeration types as "abstract" so they could only be used as a template for derived types.
Such abstract types couldn't be used directly for object declarations.  For example:

   type Valve_State_Base_Type is abstract (Unknown, Open, Closed);  -- in Ada 202X

   Valve_State : Valve_State_Base_Type;  -- illegal, type is abstract

   type Vent_Valve_State_Type is new Valve_State_Base_Type;  -- a legal derivation

   Vent_Valve_State : Vent_Valve_State_Type;  -- a legal object declaration

I think subtypes of such an abstract type should be implicitly abstract as well:

   subtype Valve_Cmd_Base_Type is Valve_State_Base_Type range Open .. Closed;

   Valve_Cmd : Valve_Cmd_Base_Type;  -- illegal,  base type is abstract

   subtype Vent_Valve_Cmd_Type is Vent_Valve_State_Type range Open .. Closed;

   Vent_Valve_Cmd : Vent_Valve_Cmd_Type;  -- legal

Perhaps this has been asked before but I couldn't find an earlier discussion. Is there any reason why the "abstract" concept couldn't be extended to enumeration and other non-tagged types in Ada 202X?

- Britt

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-02-26 21:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-21  3:04 Why no abstract non-tagged types? Britt
2014-02-21  8:33 ` Dmitry A. Kazakov
2014-02-26 18:52   ` Dan'l Miller
2014-02-26 20:55     ` Dmitry A. Kazakov
2014-02-26 21:40     ` Eryndlia Mavourneen
2014-02-24 23:12 ` Shark8

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