comp.lang.ada
 help / color / mirror / Atom feed
* Why can't you create a out of order subtype?
@ 2005-02-01 23:51 brett_gengler
  2005-02-02  0:24 ` Jeffrey Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: brett_gengler @ 2005-02-01 23:51 UTC (permalink / raw)


I created a type whose order can not be rearranged and I want to create
a subtype of that type.  So,

type msg is ( msg_a, msg_b, msg_c, msg_d, msg_e);

subtype vowel_msg is msg (msg_a, msg_e); --wrong, but why?


Is it true that I can't define a a subtype that's not a ordered
subrange of a type?  My issue is that I want to enforce the subtype at
compile time instead of creating an array of booleans and doing a run
time check. (This is for an interface and I don't trust people to send
me the right types).

vowel_filter is array(msg) of Boolean := (msg_a => True, msg_e => True,
others => False);  --yuck.

Another option that I think is much, much worse then the boolean array
would be create an overloaded type...

type msg is ( msg_a, msg_b, msg_c, msg_d, msg_e);
type vowelmsg ( msg_a, msg_e);

But as you know, msg.msg_e = 4 and vowelmsg.msg_e = 1 so an unchecked
conversion is wrong on so many levels.

Am I screwed?  Should I just implement a boolean array and shut up
about it?




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

end of thread, other threads:[~2005-02-04  6:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-01 23:51 Why can't you create a out of order subtype? brett_gengler
2005-02-02  0:24 ` Jeffrey Carter
2005-02-02 17:55   ` Marius Amado Alves
2005-02-02 18:50     ` Pascal Obry
2005-02-02 20:22       ` Marius Amado Alves
2005-02-03  4:36       ` Wes Groleau
2005-02-03 12:59         ` Marius Amado Alves
2005-02-04  3:42           ` Wes Groleau
2005-02-02 19:35     ` Martin Dowie
2005-02-02 20:35       ` Marius Amado Alves
2005-02-02 21:18         ` Martin Dowie
2005-02-03 19:40       ` Robert A Duff
2005-02-03 20:22         ` Marius Amado Alves
2005-02-03 22:05           ` Robert A Duff
2005-02-04  6:49           ` Martin Dowie
2005-02-02 22:26 ` Georg Bauhaus
2005-02-03 23:09 ` Robert A Duff

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