comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: How to extract range from array
Date: Mon, 20 Mar 2006 20:01:03 +0100
Date: 2006-03-20T20:01:03+01:00	[thread overview]
Message-ID: <2901131.Fq1M6N3cKt@linux1.krischik.com> (raw)
In-Reply-To: dvm9rt$i6a$1@sunnews.cern.ch

Maciej Sobczak wrote:

> Martin Krischik wrote:
> 
>> Read:
>> 
>> http://en.wikibooks.org/wiki/Ada_Programming/Types/array#Array_Attributes
> 
> subtype My_Range is Integer range My_Array'Range;
> 
> This suggests that arrays cannot have more elements than Integer'Last.
> Which cannot be true.

You should have copied the original example: 

Hello_World  : const String := "Hello World!";
subtype Hello_World_Index is Integer range Hello_World'Range;

> What am I missing?

You are missing the definition of String which is part of Standard:

http://en.wikibooks.org/wiki/Ada_Programming/Libraries/Standard

and reads something like this (on GNAT):

 type Integer is range -(2 ** 31) .. +(2 ** 31 - 1);
 subtype Positive is Integer range 1 .. +(2 ** 31 - 1);

 type String is array (Positive range <>) of Character;
 pragma Pack (String);

And indeed the array in the example can not be larger then Integer'Last
because Strings are not larger then Integer'Last.

Of corse you could define:

 type Long_Long_Integer   is range -(2 ** 63) .. +(2 ** 63 - 1);
 subtype Long_Long_Positive is Integer range 1 .. +(2 ** 63 - 1);

 type Long_Long_String is array (Long_Long_Positive range <>) of Character;
 pragma Pack (Long_Long_String);

And then order additional memory for your computer to store
Long_Long_String's in  ;-)

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



  parent reply	other threads:[~2006-03-20 19:01 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
2006-03-20 15:31     ` Robert A Duff
2006-03-20 19:01     ` Martin Krischik [this message]
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