From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4066f0f220a75baf X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Loop parameter type References: <20060925105627.GA14409@ws.max.zp.ua> In-Reply-To: <20060925105627.GA14409@ws.max.zp.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1159211282 12.201.97.213 (Mon, 25 Sep 2006 19:08:02 GMT) NNTP-Posting-Date: Mon, 25 Sep 2006 19:08:02 GMT Date: Mon, 25 Sep 2006 19:08:02 GMT Xref: g2news2.google.com comp.lang.ada:6729 Date: 2006-09-25T19:08:02+00:00 List-Id: 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