From: Jeffrey Carter <spam@spam.com>
Subject: Re: Type inference in loops with immediate constants
Date: Thu, 26 Jun 2003 01:40:53 GMT
Date: 2003-06-26T01:40:53+00:00 [thread overview]
Message-ID: <3EFA4F13.7080603@spam.com> (raw)
In-Reply-To: bdd25b$6iv$1@news-reader1.wanadoo.fr
Guillaume Foliard wrote:
>
> Length : Positive; -- reminder : subtype Integer range 1 .. Integer'Last
>
> for Index in 0 .. Length - 1 loop
>
> Then what type Index should be ?
Positive is a subtype of Integer, so any expressions including Length
have type Integer, so Index has type Integer. A discrete range can be
considered (informally; language lawyers will get more specific if you
like, and sometimes even if you don't like :) an expression, so in
for Index in 0 .. Length loop
Index will also have type Integer. Finally, in a for loop, a numeric
range with a universal type yields a loop constant with type Integer. In
other words, given something like
for Index in 1 .. A'Length loop
Index has type Integer.
--
Jeff Carter
"When Roman engineers built a bridge, they had to stand under it
while the first legion marched across. If programmers today
worked under similar ground rules, they might well find
themselves getting much more interested in Ada!"
Robert Dewar
next prev parent reply other threads:[~2003-06-26 1:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-25 20:54 Type inference in loops with immediate constants Guillaume Foliard
2003-06-26 1:40 ` Jeffrey Carter [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-06-26 6:18 christoph.grein
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox