From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Half Constrained Array Types and Slices
Date: Wed, 8 Mar 2006 15:29:07 +0100
Date: 2006-03-08T15:29:08+01:00 [thread overview]
Message-ID: <2f9u4hapikva$.12yh8b4eimcb8$.dlg@40tude.net> (raw)
In-Reply-To: 1141758169.075214.235400@j52g2000cwj.googlegroups.com
On 7 Mar 2006 11:02:49 -0800, Jeff Carter wrote:
> Dmitry A. Kazakov wrote:
>>
>> BTW, in the second case there is an interesting possibility, I didn't think
>> much about. If the language had supertyping, then the compiler could create
>> an anonymous supertype of the index type with one or two more values. These
>> imaginary values could then be returned as 'First and 'Last. The idea is
>> same as in IEEE's positive and negative infinities. Of course these values
>> could have different representation than natural index. Yet the following
>> will be illegal:
>>
>> I : Index := A'First; -- This may cause C_E while type conversion
>
> I suppose this could be handled much as we handle integer types, with a
> base type that is different from the 1st-named subtype. So a
> declaration such as
>
> type Single is (One);
>
> would be implemented as
>
> type Single'Base is (First, One);
>
> subtype Single is Single'Base range One .. One;
>
> Then, given
>
> type Degenerate is array (Single range <>) of Whatever;
>
> V : Degenerate (null range);
>
> we can say that V'Last is of type Single'Base. V'First = One, V'Last =
> First.
>
> Probably we'd do this for all enumeration types; that would allow ""
> for all string types. Since we define Single'Pos (One) to be zero,
> Single'Base'Pos (First) would have to be -1. Would that work? Or would
> it be better for position numbers to start at 1?
Maybe it will work. At least it looks consistent.
An interesting related question is:
type Single is (One);
for Single'Size use 0; -- Can I have it really 0?
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2006-03-08 14:29 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-02 5:00 Half Constrained Array Types and Slices Jeffrey R. Carter
2006-03-02 8:34 ` Dmitry A. Kazakov
2006-03-02 15:34 ` Georg Bauhaus
2006-03-02 19:37 ` Dmitry A. Kazakov
2006-03-02 20:06 ` Jeffrey R. Carter
2006-03-02 20:37 ` Dmitry A. Kazakov
2006-03-02 21:01 ` Robert A Duff
2006-03-02 20:40 ` Robert A Duff
2006-03-02 14:32 ` Larry Kilgallen
2006-03-02 20:08 ` Jeffrey R. Carter
2006-03-02 20:48 ` Robert A Duff
2006-03-06 2:16 ` Larry Kilgallen
2006-03-06 18:50 ` Martin Krischik
2006-03-02 20:38 ` Robert A Duff
2006-03-03 5:15 ` Jeffrey R. Carter
2006-03-03 8:57 ` Dmitry A. Kazakov
2006-03-03 23:41 ` Robert A Duff
2006-03-06 17:50 ` Jeff Carter
2006-03-06 18:31 ` Dmitry A. Kazakov
2006-03-07 19:02 ` Jeff Carter
2006-03-08 14:29 ` Dmitry A. Kazakov [this message]
2006-03-09 22:44 ` Robert A Duff
2006-03-10 8:46 ` Dmitry A. Kazakov
2006-03-06 19:49 ` Stefan Lucks
2006-03-08 17:36 ` brian.b.mcguinness
2006-03-08 17:56 ` Jeff Carter
2006-03-09 22:36 ` Robert A Duff
2006-03-10 4:28 ` Jeffrey R. Carter
2006-03-10 8:46 ` Dmitry A. Kazakov
2006-03-10 17:33 ` Robert A Duff
2006-03-10 21:24 ` Dmitry A. Kazakov
2006-03-10 17:38 ` Robert A Duff
2006-03-11 0:19 ` Randy Brukardt
2006-03-11 1:43 ` Jeffrey R. Carter
2006-03-11 8:38 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox