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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f5a48f21d7f7525 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Inferring array index type from array object Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> Date: Wed, 23 Jun 2010 10:01:46 +0200 Message-ID: <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> NNTP-Posting-Date: 23 Jun 2010 10:01:46 CEST NNTP-Posting-Host: 93a4eef2.newsspool4.arcor-online.net X-Trace: DXC=EJKNK3\VQEUI?44J>Z[:RQ4IUK On Wed, 23 Jun 2010 00:30:23 -0700 (PDT), Maciej Sobczak wrote: > 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; subtype Index_Span is Integer range S'Range; I : Index_Span := S'First; > I have two questions: > > 1. What is the standard justification for this assymetry? "We don't want to do anything [useful]." (:-)) > What exactly > makes S'Range "work" in a for loop? It is hard wired, since ranges are not first class citizens. > 2. Is it possible to declare the index variable without hardcoding the > index type (that is, to infer it from the array object)? No, without improving the type system. E.g. introducing abstract index types, and abstract range types (or more general sets of index types), and abstract composite types like arrays. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de