comp.lang.ada
 help / color / mirror / Atom feed
From: Guillaume Foliard <guifo@wanadoo.fr>
Subject: Type inference in loops with immediate constants
Date: Wed, 25 Jun 2003 22:54:02 +0200
Date: 2003-06-25T20:54:03+00:00	[thread overview]
Message-ID: <bdd25b$6iv$1@news-reader1.wanadoo.fr> (raw)

Hi,

I'm currently chasing down a Constraint_Error exception and while I was
reading one loop statement I wondered about the type inference in such a
place. Here is the snippet :

---

Length : Positive; -- reminder : subtype Integer range 1 .. Integer'Last

for Index in 0 .. Length - 1 loop

---

Then what type Index should be ?

Positive ?

Obviously not, because of the 0, which is not a Positive, as a starting
value.

Integer ?

Is the compiler using the fact that a positive is derived from an universal
integer and thus decides to give the base type to the loop variable ?

-- 
Guillaume



             reply	other threads:[~2003-06-25 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-25 20:54 Guillaume Foliard [this message]
2003-06-26  1:40 ` Type inference in loops with immediate constants Jeffrey Carter
  -- 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