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 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: Warren Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object Date: Mon, 28 Jun 2010 13:44:22 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> <88ec2vF3uqU1@mid.individual.net> <88f9osFmcmU1@mid.individual.net> Injection-Date: Mon, 28 Jun 2010 13:44:22 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="qtwthkrgwQVPvJFfslJIDQ"; logging-data="9609"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jGtDVImxHWpYRrUdcBZ9yRNLqnMLwWhg=" User-Agent: Xnews/5.04.25 X-Face: &6@]C2>ZS=NM|HE-^zWuryN#Z/2_.s9E|G&~DRi|sav9{E}XQJb*\_>=a5"q]\%A;5}LKP][1mA{gZ,Q!j Cancel-Lock: sha1:z1nOtS6JcYqUZaoAbjttRAH/01w= Xref: g2news1.google.com comp.lang.ada:11966 Date: 2010-06-28T13:44:22+00:00 List-Id: Niklas Holsti expounded in news:88f9osFmcmU1@mid.individual.net: > Warren wrote: >> Niklas Holsti expounded in news:88ec2vF3uqU1@mid.individual.net: >>> Dmitry A. Kazakov wrote: >>>> On Wed, 23 Jun 2010 00:30:23 -0700 (PDT), Maciej Sobczak wrote: >> .. >>>>> 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. >>> I don't think such large language changes would be necessary. The >>> expression S'Range gives the compiler all the information about the >>> type and its constraints, so I see no reason why Ada could not be >>> extended simply to allow S'Range in a variable declaration, as in the >>> above quoted "I : S'Range". The declared variable "I" would have the >>> same (sub)type as the loop counter in "for I in S'Range loop ...". >> >> I think most would agree that this is a "convenience" feature. > > Yes, but in other contexts, when we advocate Ada, we often make a big > point of the "convenience" of the 'Range attribute for arrays, such as > "No need to pass extra parameters for array index bounds, just use > 'Range". The suggestion to let variables be declared by the "type" > S'Range (or, if desired, a new attribute S'Index_Type) has a similar > advantage (but a weaker one, I admit). But how far down that road do you want to go? This is the crux of the issue. I'd find ++X or X += n convenient. But should that be implemented in Ada? I'm ok with leaving it out. At some point, you have to draw a line in the sand. Warren