If you declare A the way Georg described, then put(A'first(1)) should print 1.
I think you may have a fundamental misunderstanding about arrays in Ada; you seem to think that the language automatically "knows", in some way, that the first index of an array is 1. That isn't true. There is no default first index. (This is unlike some languages like C or Java, where the first index is always 0; I don't know what it is in MATLAB.) The first index is whatever you tell the compiler it is. And, as has been pointed out already, if an unconstrained array type is declared with "Integer range <>" as the index, and you set up an aggregate without specifying the first index, the first index will be Integer'first, which is -
2147483648 for some Ada compilers (the actual value is compiler-dependent).
So, if you declare
A : constant Real_Matrix :=
(( 1.0, 2.0, 3.0),
( 4.0, 5.0, 6.0),
( 7.0, 8.0, 9.0));
then the first element is at indexes
(-2147483648, -
2147483648). The last one is at
(-2147483646, -
2147483646). If you write A
(-2147483648, -
2147483648) you will get 1.0. If you write A(1,1) you will get a constraint error. A'First(1) and A'First(2) are both -2147483648. A'Last(1) and A'Last(2) are both -2147483646. A'Range(1) is a shorthand for A'First(1)..A'Last(1). If you want something that tells you that the "first index" is 1 and the "last index" is 3, you are not going to get it unless you do the math yourself. (But note that A'Length(1) and A'Length(2) are both 3.) That's also why you're getting the Constraint_Error in your other post. If you say
for I in A'Range(1) loop
then I will take the values -
2147483648, -
2147483647, -
2147483646; and if you use any of those values as an index into B, which has index ranges (1..3, 1..3), you'll get a Constraint_Error, because none of those big negative values is in the range 1..3.
My apologies if I'm hammering on stuff you already know. But it just looked to me that you had a misconception about how array index ranges work in Ada, since you seemed perplexed by some of the results you were getting.
-- Adam