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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f0b19a44b99ada68 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-25 18:40:52 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-pas-nf2!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3EFA4F13.7080603@spam.com> From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Type inference in loops with immediate constants References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 26 Jun 2003 01:40:53 GMT NNTP-Posting-Host: 63.184.33.102 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 1056591653 63.184.33.102 (Wed, 25 Jun 2003 18:40:53 PDT) NNTP-Posting-Date: Wed, 25 Jun 2003 18:40:53 PDT Xref: archiver1.google.com comp.lang.ada:39749 Date: 2003-06-26T01:40:53+00:00 List-Id: 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