comp.lang.ada
 help / color / mirror / Atom feed
From: Philip Anderson <phil.anderson@amsjv.com>
Subject: Re: array(enumeration)
Date: 2000/07/20
Date: 2000-07-20T00:00:00+00:00	[thread overview]
Message-ID: <3977160A.B0C6AD2E@amsjv.com> (raw)
In-Reply-To: Pine.LNX.4.10.10007191643160.863-100000@lexis.di.fct.unl.pt

Mario Amado Alves wrote:
> 
> How do I define an array type indexed by an enumeration type?
> 
>   type Array_Type is array(<>) of Some_Type;
>     --                    /|\
>     --                     |
>     -- compiler says identifier expected here

Yes, you need to fully define the type, including the type of the index.


>   type Enumeration_Type is (A, B, C);
>   type Another_Enumeration_Type is (X, Y, Z);
> 
>   A_Thing: Array_Type(Enumeration_Type) := (
>     A => ... ,
>     B => ... ,
>     C => ... );
> 
>   Another_Thing: Array_Type(Another_Emuneration_Type) := (
>     X => ... ,
>     Y => ... ,
>     Z => ... );
> 
> This makes sense to me, but does not compile. So how do I code the idea?


type Array_Type is array (Enumeration_Type) of Some_Type;

type Another_Array_Type is array (Another_Enumeration_Type) of
Some_Type;


A_Thing: Array_Type := (
   A => ... ,
   B => ... ,
   C => ... );

Another_Thing: Another_Array_Type := (
   X => ... ,
   Y => ... ,
   Z => ... );

Note that these objects are of different types, and cannot be assigned
to each other even though the item type is the same.


or simply:

  A_Thing : array (Enumeration_Type) of Some_Type := (


-- 
hwyl/cheers,
Philip Anderson
Alenia Marconi Systems
Cwmbr�n, Cymru/Wales




  reply	other threads:[~2000-07-20  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-19  0:00 array(enumeration) Mario Amado Alves
2000-07-20  0:00 ` Philip Anderson [this message]
2000-07-20  0:00 ` array(enumeration) Steve Folly
2000-07-20  0:00 ` array(enumeration) Frode Tenneboe
replies disabled

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