comp.lang.ada
 help / color / mirror / Atom feed
From: Ken Garlington <GarlingtonKE@lmtas.lmco.com>
Subject: Re: What's wrong with this syntax?
Date: 1996/12/05
Date: 1996-12-05T00:00:00+00:00	[thread overview]
Message-ID: <32A6FE0F.7902@lmtas.lmco.com> (raw)
In-Reply-To: 584kr9$84s@hacgate2.hac.com


John Gluth wrote:
> 
> Howdy,
> 
> Someone on my team asked me if I knew why Rational's Apex doesn't
> seem to like the following excerpts.  I don't see what's wrong with it
> either.
> 
> Some_Limit : Constant := 1024;
> 
> for i in 1..(Some_Limit - 2) loop
> 
> It doesn't seem to want to evaluate the (Some_Limit - 2) expression.
> It seems to me that Some_Limit, a named number is of type Universal
> Integer.
> The literal, 2, should also be of type Universal Integer.
> 
> What are we missing?

Here's what DEC Ada V3.2-12 says about your loop:

"Type {universal_integer} is not allowed for the discrete range of a constrained
array definition, an iteration rule, or an index of an entry family [LRM 3.6.1(2)].
Default resolution to the type INTEGER does not apply because one or both expressions
is not a literal, named number, or attribute; however, the type INTEGER is assumed
[LRM 3.6.1(2)]."

Note that both references are to the Ada 83 LRM.

There are several approaches to fixing the problem; one is

"for I in Integer'(1) .. (Some_Limit - 2) loop"

Your code does compile correctly on an Ada 95 compiler (GNAT).

> 
> Thx,
> 
> John
> jpgluth@ccgate.hac.com

-- 
LMTAS - The Fighter Enterprise - "Our Brand Means Quality"
See http://www.lmtas.com for more information (job listings now available)




  parent reply	other threads:[~1996-12-05  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-04  0:00 What's wrong with this syntax? John Gluth
1996-12-05  0:00 ` johnherro
1996-12-05  0:00 ` Ken Garlington [this message]
1996-12-05  0:00   ` Bob Gilbert
1996-12-10  0:00     ` Robert Dewar
1996-12-15  0:00     ` Gene Ouye
1996-12-15  0:00       ` Matthew Heaney
replies disabled

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