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,5f5a48f21d7f7525 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object Date: Wed, 23 Jun 2010 23:39:56 +0300 Organization: Tidorum Ltd Message-ID: <88f9osFmcmU1@mid.individual.net> References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> <88ec2vF3uqU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Tmet2hBovh22Rr12wbzSTQfC6Qth0ePKf4B/YyXo8u8Xz1gn7v Cancel-Lock: sha1:D2iJdMeOb30NL3MTA8O1IHXfvTU= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:12874 Date: 2010-06-23T23:39:56+03:00 List-Id: 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). > I think the language (and its compiler) is probably complicated > enough for these types of additions. Don't forget each new feature > requires a "test suite" and validation, in addition to the > compiler itself. Yes, of course. But as time goes on, and as long as the extensions are backwards compatible, I think the compiler writers and validators could live with a growing test and validation suite. But then I am not one of those guys... On the other hand, I do worry about language and compiler complexity. If the creation and maintenance of Ada compilers is very costly and difficult, it creates a risk for the survival of Ada, as well as a brake on the evolution of Ada. When we talk about "the Ada way", it seems to me that we have in mind a simpler and more elegant and uniform thing than the current Ada language -- some "core of Ada" that perhaps could be defined and implemented in an easier way. I suspect that Dmitry has the same feeling, which is why he keeps suggesting (or dreaming about) such large and fundamental changes to Ada. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .