comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Why this error, value not in range of subtype of "Standard.Integer"?
Date: Tue, 26 Jun 2012 17:39:42 -0400
Date: 2012-06-26T17:39:42-04:00	[thread overview]
Message-ID: <wccr4t1wy5d.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: jsclls$3bv$1@speranza.aioe.org

"Nasser M. Abbasi" <nma@12000.org> writes:

> If I write this, I get an error as show: (notice the B
> matrix declaration, that is where the problem is)
>
> -------------- this does not work ------
> with Ada.Numerics.Real_Arrays;  use Ada.Numerics.Real_Arrays;
>
> procedure foo2 is
>     A : constant Real_Matrix :=
>              (( 1.0,  2.0,  3.0),
>               ( 4.0,  5.0,  6.0),
>               ( 7.0,  8.0,  9.0));
>     B : Real_Matrix(1 .. 3,1 .. 3);  -- this is the problem

Others answered your question, but:  You might find it convenient
to declare a subtype:

    subtype My_Real_Matrix is Real_Matrix(1..3, 1..3);
    A: constant My_Real_Matrix := ((1.0, ....
    B: My_Real_Matrix;

Also look into the "for ... of" syntax of Ada 2012.

- Bob



      parent reply	other threads:[~2012-06-26 21:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-26 15:49 Why this error, value not in range of subtype of "Standard.Integer"? Nasser M. Abbasi
2012-06-26 17:20 ` Adam Beneschan
2012-06-26 18:00 ` Niklas Holsti
2012-06-26 21:39 ` Robert A Duff [this message]
replies disabled

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