comp.lang.ada
 help / color / mirror / Atom feed
From: Britt <britt.snodgrass@gmail.com>
Subject: Why no abstract non-tagged types?
Date: Thu, 20 Feb 2014 19:04:08 -0800 (PST)
Date: 2014-02-20T19:04:08-08:00	[thread overview]
Message-ID: <90153ba2-ffe8-4696-8459-d81a0f703c9e@googlegroups.com> (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

             reply	other threads:[~2014-02-21  3:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-21  3:04 Britt [this message]
2014-02-21  8:33 ` Why no abstract non-tagged types? 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
replies disabled

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