comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Ada.Numerics.Long_Real_Arrays
Date: Wed, 25 Jan 2017 13:50:36 +0000
Date: 2017-01-25T13:50:36+00:00	[thread overview]
Message-ID: <ly7f5jw8nn.fsf@pushface.org> (raw)
In-Reply-To: 5a19787c-a11c-470e-8cef-2c5dc4897bf7@googlegroups.com

hnptz@yahoo.de writes:

> with Ada.Numerics.Long_Real_Arrays; use Ada.Numerics.Long_Real_Arrays;
> package nm is
>
> Np : Positive;

So what value does Np have at this point?

> Type R_Vector is new Real_Vector (1..Np);

Np here will have whatever value it has been assigned by the compiler;
on my system, it was 0 (which isn't valid for Positive, but I expect the
compiler is allowed to make an undefined value whatver is convenient for
it).

> Type R_Matrix is array (Positive range <>) of R_Vector;
>
> procedure nm1 (P : in out R_Matrix);
>
> end nm;

> now in procedure test_nm.adb (only definitions):
>
> Np : Positive := 2;

This is a local declaration which hides Nm.Np (even if you "use Nm;");
setting a value here has no effect on Nm.Np.

> Mp : Positive := Np+1;
>
> 24  P : R_Matrix(1..Mp) := ((x,x),(y,y),(z,z));
>
> no "build all" error or warning

Because it's quite legal to have an array with index range 1 .. 0 -- it
just means it's empty (zero length).

> result when running:
>
> raised CONSTRAINT_ERROR : test_nm.adb: 24 length check failed.

Why not use Ada.Numerics.Long_Real_Arrays.Real_Matrix?

  reply	other threads:[~2017-01-25 13:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 12:25 Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 13:50 ` Simon Wright [this message]
2017-01-25 14:11 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 16:17   ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-25 18:35 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-25 21:29 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-26  7:47   ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26 11:54     ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-26 14:52       ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26 15:03         ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26  7:49   ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-26  7:55     ` Ada.Numerics.Long_Real_Arrays Simon Wright
2017-01-27 16:51 ` Ada.Numerics.Long_Real_Arrays hnptz
2017-01-27 18:39   ` Ada.Numerics.Long_Real_Arrays Simon Wright
replies disabled

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