comp.lang.ada
 help / color / mirror / Atom feed
* Array range type for Verdix Ada83 compiler question.
@ 1999-09-09  0:00 Michael
  1999-09-09  0:00 ` Tucker Taft
  1999-09-09  0:00 ` Martin Dowie
  0 siblings, 2 replies; 3+ messages in thread
From: Michael @ 1999-09-09  0:00 UTC (permalink / raw)


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?

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

  Thanks in advance,

  Michael




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Array range type for Verdix Ada83 compiler question.
  1999-09-09  0:00 Array range type for Verdix Ada83 compiler question Michael
  1999-09-09  0:00 ` Tucker Taft
@ 1999-09-09  0:00 ` Martin Dowie
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Dowie @ 1999-09-09  0:00 UTC (permalink / raw)


is your compiler getting confused about which unary minus operator to
use for the '-' in '-100'?

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?
>
>   I would think it could pick a type most suitable for the range.
>
>   Thanks in advance,
>
>   Michael





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Array range type for Verdix Ada83 compiler question.
  1999-09-09  0:00 Array range type for Verdix Ada83 compiler question Michael
@ 1999-09-09  0:00 ` Tucker Taft
  1999-09-09  0:00 ` Martin Dowie
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1999-09-09  0:00 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-09-09  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-09-09  0:00 Array range type for Verdix Ada83 compiler question Michael
1999-09-09  0:00 ` Tucker Taft
1999-09-09  0:00 ` Martin Dowie

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