comp.lang.ada
 help / color / mirror / Atom feed
* Inferring array index type from array object
@ 2010-06-23  7:30 Maciej Sobczak
  2010-06-23  8:01 ` Dmitry A. Kazakov
  2010-06-23 13:12 ` Gautier write-only
  0 siblings, 2 replies; 41+ messages in thread
From: Maciej Sobczak @ 2010-06-23  7:30 UTC (permalink / raw)


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;

But it does not work. Of course, one can do:

I : Positive := S'First;

But it has the disadvantage of hardcoding the index type and
introducing unnecessary coupling in the code.
(hint: the problem is not really about Strings, it is a general array
question)

I have two questions:

1. What is the standard justification for this assymetry? What exactly
makes S'Range "work" in a for loop?

2. Is it possible to declare the index variable without hardcoding the
index type (that is, to infer it from the array object)?

--
Maciej Sobczak * http://www.inspirel.com

YAMI4 - Messaging Solution for Distributed Systems
http://www.inspirel.com/yami4



^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2010-06-30 16:43 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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