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 Path: g2news2.google.com!news3.google.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Inferring array index type from array object Date: Wed, 23 Jun 2010 17:17:49 +0200 Organization: Adalog Message-ID: References: <6b20ed09-efc1-4df7-90f9-5e141482e8d0@d37g2000yqm.googlegroups.com> <1305oqccr1h2t$.x33x4oxwd84d$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 23 Jun 2010 15:18:06 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="Dn22F68J9CHYFQQlT81DGA"; logging-data="31984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sZDA/MAHy8NxWOYE2xhIq" User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) In-Reply-To: Cancel-Lock: sha1:9lcXp+nRK/HkuuKYBwfVfNfj/P0= Xref: g2news2.google.com comp.lang.ada:12861 Date: 2010-06-23T17:17:49+02:00 List-Id: Robert A Duff a �crit : >> for I in positive range 1..10 loop ... >> for I in positive range S'Range loop ... > [...] > > But in the second example, I'm perfectly happy with leaving > the type implicit: > > for I in S'Range loop > ... S(I) ... > > because this code really doesn't care what the index type is. Yes, but OTOH it is nice to say that werever an object is declared, its type appears on the same line. And if you want to make a rule, it is always simpler to say "do that" than "do that, except when..." > Can AdaControl check my style rule -- complain if I depend > on the default-to-integer rule, but not complain if the > type of the loop index is properly deducible from the > stuff between "in" and "loop"? Not yet, although it would be a very simple addition. The hardest part would be to find an acceptable name for the rule. The current one is: check declarations (anonymous_subtype_for); and I wouldn't like: check declarations (anonymous_subtype_except_range_for); ;-) >> So it is really symetrical, except that in the case of a loop, you are >> allowed to "simplify" by omitting the " range" part - forcing the >> compiler to deduce the type from the range, which is not a good idea IMHO. > > Why is that a bad idea (in the second case)? > As noted before, it would be so simpler to say "no type inference". In general, in the rare cases where Ada tried to save some typing, it was a bad idea... -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr