comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Inferring array index type from array object
Date: Wed, 23 Jun 2010 17:17:49 +0200
Date: 2010-06-23T17:17:49+02:00	[thread overview]
Message-ID: <hvt8jb$v7g$1@news.eternal-september.org> (raw)
In-Reply-To: <wcc63194xvu.fsf@shell01.TheWorld.com>

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 "<type> 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



  reply	other threads:[~2010-06-23 15:17 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-23  7:30 Inferring array index type from array object Maciej Sobczak
2010-06-23  8:01 ` Dmitry A. Kazakov
2010-06-23  9:03   ` J-P. Rosen
2010-06-23 12:24     ` Georg Bauhaus
2010-06-23 12:52       ` J-P. Rosen
2010-06-23 19:09         ` Simon Wright
2010-06-24  7:25           ` Georg Bauhaus
2010-06-23 14:38     ` Robert A Duff
2010-06-23 15:17       ` J-P. Rosen [this message]
2010-06-23 17:17         ` Robert A Duff
2010-06-24  6:16           ` J-P. Rosen
2010-06-23 12:13   ` Niklas Holsti
2010-06-23 14:27     ` Peter C. Chapin
2010-06-23 20:24       ` Niklas Holsti
2010-06-23 16:33     ` Warren
2010-06-23 17:49       ` Dmitry A. Kazakov
2010-06-23 18:45         ` Warren
2010-06-23 20:39       ` Niklas Holsti
2010-06-28 13:44         ` Warren
2010-06-28 22:18           ` Niklas Holsti
2010-06-29  1:49             ` Adam Beneschan
2010-06-29  2:10               ` (see below)
2010-06-29 16:56             ` Warren
2010-06-29 17:50               ` John B. Matthews
2010-06-29 19:31                 ` Warren
2010-06-29 20:06                   ` Jeffrey R. Carter
2010-06-29 20:16                     ` Warren
2010-06-29 20:22                   ` Adam Beneschan
2010-06-29 20:39                     ` Dmitry A. Kazakov
2010-06-29 20:55                     ` Warren
2010-06-29 21:00                       ` Warren
2010-06-29 21:47                         ` John B. Matthews
2010-06-29 21:52                         ` Damien Carbonne
2010-06-29 22:22                         ` Adam Beneschan
2010-06-30 16:43                           ` Warren
2010-06-29 21:18                       ` Jeffrey R. Carter
2010-06-30  5:01                     ` Simon Wright
2010-06-30 14:29                       ` Adam Beneschan
2010-06-29 20:28                   ` Damien Carbonne
2010-06-29 21:20                   ` John B. Matthews
2010-06-23 13:12 ` Gautier write-only
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox