comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to extract range from array
Date: Mon, 20 Mar 2006 15:20:26 +0100
Date: 2006-03-20T15:20:26+01:00	[thread overview]
Message-ID: <1u0kl7a0z3apw$.1jajgn9bqfrkl.dlg@40tude.net> (raw)
In-Reply-To: dvm9rt$i6a$1@sunnews.cern.ch

On Mon, 20 Mar 2006 14:14:37 +0100, Maciej Sobczak wrote:

> subtype My_Range is Integer range My_Array'Range;
> 
> This suggests that arrays cannot have more elements than Integer'Last.
> Which cannot be true.
> 
> What am I missing?

A'Range is not a [sub]type, it is a value of some anonymous "range-type."
What you need is:

subtype My_Range is My_Array'Index range My_Array'Range;
   -- This is not Ada!

alas. This is also why you cannot:

generic
   type My_Array is array (<>) of Something; -- Not Ada!

Ada does not have array interfaces. So you have to specify the index type
instead of asking it from the array's instance:

generic
   type My_Index is ...;
   type My_Array is array (My_Index range <>) of Something;

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



  parent reply	other threads:[~2006-03-20 14:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-17 11:23 How to extract range from array Maciej Sobczak
2006-03-17 12:29 ` Ed Falis
2006-03-17 15:12 ` Martin Krischik
2006-03-20 10:04   ` Maciej Sobczak
2006-03-20 13:14   ` Maciej Sobczak
2006-03-20 13:58     ` Ed Falis
2006-03-20 14:20     ` Dmitry A. Kazakov [this message]
2006-03-20 15:31     ` Robert A Duff
2006-03-20 19:01     ` Martin Krischik
2006-03-20 20:20       ` Georg Bauhaus
2006-03-20 21:51       ` Jeffrey R. Carter
2006-03-21 19:12         ` Martin Krischik
replies disabled

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