comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Array range type for Verdix Ada83 compiler question.
Date: 1999/09/09
Date: 1999-09-09T00:00:00+00:00	[thread overview]
Message-ID: <37D83563.51EE808A@averstar.com> (raw)
In-Reply-To: 37D8106C.3F17@pipeline.com

Michael wrote:
> 
> Hi,
> 
>   I have a bit a code:
> 
>    type ta is array (0 .. 8) of boolean;
>    type Request_Numbers_Array is array (-100 .. 100) of integer;
> 
>   The first line compiles just fine.
> The second line says: "index range is ambiguous" and then gives me a
> list of possible types (i.e. Short, Long, Integer . . .)
> 
>  I fixed the problem in this way:
> type Request_Numbers_Array is array (Integer range -100 .. 100) of
> integer;
> 
>   My question is: Why do I need to do this?

As pointed out by another respondant, there is ambiguity in the
choice of the "-" operator.  

This problem does not arise in Ada 95 because of a special rule 
that makes these "anonymous" integral ranges end up being treated as 
Standard.Integer.  This rule was added specifically because of the
surprise programmers had when they wrote what you wrote, or similarly,
   for I in -100 .. 100 loop

which also is ambiguous in Ada 83, but treated like

   for I in Integer(-100) .. Integer(100) loop

in Ada 95

> 
>   I would think it could pick a type most suitable for the range.

That could be trouble, because you would not have a name for the
type that was chosen.  I suppose you could use Request_Numbers_Array'Range,
but generally implicit definitions of types inside other type
definitions are not allowed in Ada.  

>   Thanks in advance,
> 
>   Michael

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~1999-09-09  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-09  0:00 Array range type for Verdix Ada83 compiler question Michael
1999-09-09  0:00 ` Tucker Taft [this message]
1999-09-09  0:00 ` Martin Dowie
replies disabled

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