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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f5a48f21d7f7525,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!d37g2000yqm.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Inferring array index type from array object Date: Wed, 23 Jun 2010 00:30:23 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1277278223 12474 127.0.0.1 (23 Jun 2010 07:30:23 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 23 Jun 2010 07:30:23 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d37g2000yqm.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:11878 Date: 2010-06-23T00:30:23-07:00 List-Id: Consider this: S : String := "Hello"; It is possible to iterate over all indices of this array with this construct: for I in S'Range loop ... I would like to declare I as a free variable instead and I would expect some symmetry in the language by doing this: I : S'Range := S'First; But it does not work. Of course, one can do: I : Positive := S'First; But it has the disadvantage of hardcoding the index type and introducing unnecessary coupling in the code. (hint: the problem is not really about Strings, it is a general array question) I have two questions: 1. What is the standard justification for this assymetry? What exactly makes S'Range "work" in a for loop? 2. Is it possible to declare the index variable without hardcoding the index type (that is, to infer it from the array object)? -- Maciej Sobczak * http://www.inspirel.com YAMI4 - Messaging Solution for Distributed Systems http://www.inspirel.com/yami4