From: Robert A Duff on
"Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:

> On Wed, 18 Jun 2008 14:32:28 +0000, S�bastien Morand wrote:
>
>>> (Newbie qiestion, coming from VHDL, halfway through the Barnes book)
>>>
>>> Can you not create a subtype of Positive to reflect that, and declare
>>> both the array and index using that subtype?
>>
>> I can't create a subtype using a parameter.
>
> No, no, you mean a *type*.
>
>> generic
>> Order: Positive;
>> package Test is
>> -- Can't work since Order is not defined at compile time
>> type MyType is range 1 .. Order;
>
> This would be a type. But you do can create a subtype:
>
> subtype Index is range 1..Order; -- This is OK
>
> Subtypes can be dynamically constrained.

Yes. You can also create a new type:

type Index is new Positive range 1..Order;

- Bob
From: Dmitry A. Kazakov on
On Wed, 18 Jun 2008 11:10:29 -0400, Robert A Duff wrote:

> You can also create a new type:
>
> type Index is new Positive range 1..Order;

You are right. But this type is not enough "new". It is merely

type P is new Positive;
subtype Index is P range 1..Order;

The hidden idea of

type Index is range 1..Order;

is to let the compiler choose the base according to the actual value of
Order. That would not work. Alas.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Ed Falis on
On Wed, 18 Jun 2008 11:25:24 -0400, Dmitry A. Kazakov
<mailbox(a)dmitry-kazakov.de> wrote:

> The hidden idea of
> type Index is range 1..Order;
> is to let the compiler choose the base according to the actual value of
> Order. That would not work. Alas.


But do you figure that was the intent of the original poster? I don't.
From: Dmitry A. Kazakov on
On Wed, 18 Jun 2008 15:38:01 GMT, Ed Falis wrote:

> On Wed, 18 Jun 2008 11:25:24 -0400, Dmitry A. Kazakov
> <mailbox(a)dmitry-kazakov.de> wrote:
>
>> The hidden idea of
>> type Index is range 1..Order;
>> is to let the compiler choose the base according to the actual value of
>> Order. That would not work. Alas.
>
> But do you figure that was the intent of the original poster?

Of course no. It is the choice of one language construct over another, that
makes an Ada reader suggest something about the intent.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de