comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: Extensible Enummerated types FW: When will next Ada revision be? (83, 95, ?)
Date: Thu, 1 Feb 2001 22:03:01 -0000
Date: 2001-02-01T22:03:01+00:00	[thread overview]
Message-ID: <95ctlj$ff437$1@ID-25716.news.dfncis.de> (raw)
In-Reply-To: 3A76E923.318F7C1E@averstar.com

Following the lead from another poster to this thread, my proposal (and I
think this is what the other poster intended) involves no tagging, but is
simply as follows. I believe this proposal would be doable and valuable.

Let's start with a normal enumeration type declaration, in unit PC_Keyboard:

   type Key_Value is (A_Key, B_Key, ..., Scroll_Lock);

My proposal is that you can make an 'enumeration extension declaration' in
any declarative region (AT_Keyboard, say) that has visibility of
PC_Keyboard.Key_Value, perhaps like this:

   type Key_Value is new PC_Keyboard.Key_Value with (F11, F12, ...);

Type AT_Keyboard.Key_Value would be in essence an ordinary enumerated type,
with all the values of PC_Keyboard.Key_Value plus the extra ones specified
(positionally appended). There would be no tag or special indexing. Any
representation clause could be applied to it (e.g. changing its size or
internal codes). It may need to be made a bigger size (by the compiler if
not explicitly) as a result of having more values.

One extra rule would be that if PC_Keyboard.Key_Value had an enumeration
representation clause (defining its internal codes), then the compiler would
demand that AT_Keyboard.Key_Value had one as well (which would have to be
comprehensive). I believe the rule (in RM95 13.4(6)) which forces the
internal codes to obey the predefined ordering relation should be removed
(the compiler would, again, have to use a lookup table if necessary, tough).

Some operations would be redefined or added.

Conversion from PC_Keyboard.Key_Value to AT_Keyboard.Key_Value would pose no
problems (a change of representation may require actual conversion, but this
is something Ada already supports).

Conversion the other way would also be supported, and would include a check
that the value being converted lay within the set of values defined for
PC_Keyboard.Key_Value (which would raise Constraint_Error if it failed).

There would be overloadings of the "in" operator which allowed a test for a
value of one type against a range of the other type, or any subtype thereof.

The other operations would all be exactly the same.

Plainly, this example declares some extra keys for an AT keyboard, implying
that an AT keyboard has at least all the same keys as a PC keyboard. It is
better than explicitly redefining all the many PC keys, since there is
clearly room for an error creeping in there. It's a better model against the
real world. It also simplifies the conversion from one type to another,
possibly eliminating another source of error. The implementation would be
exactly the same as if one had defined all the values for
AT_Keyboard.Key_Value explicitly, apart from the new and different
operations (whose implementations are straightforward), and the extra simple
rule. QED.

PS: Yes I realise that there's not going to be a revision so this kind of
idle speculation is pointless, and yes I realise people with nohing better
to do ;-) will have a field day picking it apart. Sigh.

--
Nick Roberts
http://www.AdaOS.org






  parent reply	other threads:[~2001-02-01 22:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-20  7:26 Extensible Enummerated types FW: When will next Ada revision be? (83, 95, ?) Robert C. Leif, Ph.D.
2001-01-20 14:06 ` Robert Dewar
2001-01-20 16:19   ` Jeff Creem
2001-01-20 16:23     ` Mark Carroll
2001-01-20 19:18       ` Robert Dewar
2001-01-20 22:27         ` Brian Rogoff
2001-01-21 16:06           ` Robert Dewar
2001-01-21 23:08             ` Brian Rogoff
2001-01-22  2:02               ` Robert Dewar
2001-01-22 16:02                 ` Brian Rogoff
2001-01-22 16:50                   ` Robert Dewar
2001-01-22 21:12                     ` Brian Rogoff
2001-01-22 21:26                       ` Jean-Pierre Rosen
     [not found]                         ` <Pine.BSF.4.21.0101230839000.15065-100000@shell5.ba.best.com>
     [not found]                           ` <94rbdo$vf$1@wanadoo.fr>
2001-01-26 16:41                             ` LOF4 (Was Re: Extensible Enummerated types) Brian Rogoff
2001-01-20 22:34         ` Extensible Enummerated types FW: When will next Ada revision be? (83, 95, ?) Mark Carroll
2001-01-21 16:09           ` Robert Dewar
2001-01-21 19:04             ` Mark Carroll
2001-01-21 19:26               ` Robert Dewar
2001-01-21 21:12                 ` Mark Carroll
2001-01-21 17:47     ` Nick Roberts
2001-01-21 19:37       ` Robert Dewar
2001-01-22 17:26         ` Mark Lundquist
2001-01-22 20:47           ` Randy Brukardt
2001-01-22 21:41             ` Matthew Woodcraft
2001-01-30 16:17           ` Tucker Taft
2001-01-31  8:05             ` Extensible Enumerated " Robert C. Leif, Ph.D.
2001-02-10 20:34               ` Vincent Marciante
2001-01-31  8:05             ` Supertypes RE: Extensible Enumerated types Robert C. Leif, Ph.D.
2001-01-31 15:15               ` Marin David Condic
2001-02-01 22:03             ` Nick Roberts [this message]
2001-02-02  3:48               ` Extensible Enummerated types FW: When will next Ada revision be? (83, 95, ?) Robert Dewar
2001-02-02  4:41                 ` Jeffrey Carter
2001-02-02  7:26                   ` Robert C. Leif, Ph.D.
2001-02-02 16:38                     ` Robert Dewar
2001-02-02 20:39                     ` (Private message. Sorry) Nick Roberts
2001-01-22 15:02 ` Extensible Enummerated types FW: When will next Ada revision be? (83, 95, ?) Ted Dennison
2001-01-28  8:10   ` Robert C. Leif, Ph.D.
2001-02-02 21:54     ` Nick Roberts
replies disabled

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