comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org>
Subject: Re: Loop parameter type
Date: Mon, 25 Sep 2006 19:08:02 GMT
Date: 2006-09-25T19:08:02+00:00	[thread overview]
Message-ID: <mOVRg.68857$aJ.43144@attbi_s21> (raw)
In-Reply-To: <20060925105627.GA14409@ws.max.zp.ua>

Maxim Reznik wrote:
> 
> Please help me understand Ada name resolution rules for
> loop parameter specification.
> 
> Consider follow code:
> 
>  1: procedure Test is
>  2:    type Int is range 0 .. 1000;
>  3:    C     : Integer := 0;
>  4:    C_Int : Int := 0;
>  5: begin
>  6:    for J in 1 .. 10 loop
>  7:       C := C + J;
>  8:    end loop;
>  9:   
> 10:    for K in 1 .. 10 loop
> 11:       C_Int := C_Int + K;
> 12:    end loop;
> 13: end Test;

When the subtype in a for loop is an explicit range, with the parent 
subtype not specified, and the values are universal integers (literals 
or named numbers), the parent type is Standard.Integer. See ARM 3.6. 
That's sort of an odd place for it to be defined, but that's the way it is.

You can specify the parent subtype in a for loop:

for I in Int range 1 .. 10 loop

-- 
Jeff Carter
"Don't knock masturbation. It's sex with someone I love."
Annie Hall
45



  parent reply	other threads:[~2006-09-25 19:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 10:56 Loop parameter type Maxim Reznik
2006-09-25 11:50 ` Stuart
2006-09-25 16:32 ` Robert A Duff
2006-09-25 19:08 ` Jeffrey R. Carter [this message]
2006-09-26  0:12 ` Adam Beneschan
replies disabled

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