Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending Enum in Ada

Tags:

enums

ada

Is it possible to extend an Enum type in Ada? if I have for example:

type ABC_Type is (A, B, C);

Now I want new type ABCDE_Type that will include everything that ABC_Type has and Also (D, E). Is there a way to do that?

like image 961
Yony Avatar asked Jul 25 '12 14:07

Yony


1 Answers

No, you cannot extend an Enum type in Ada, you can only create derivations/subtypes that cover a subset of the original one.

You have to do it the other way round:

type ABCDE_Type is (A, B, C, D, E);
type ABC_Type is new ABCDE_Type range A .. C;
-- or
subtype ABC_Type is ABCDE_Type range A .. C;
like image 122
Rommudoh Avatar answered Oct 21 '22 23:10

Rommudoh