* basic question on Ada programming
@ 2019-01-24 3:59 Nasser M. Abbasi
2019-01-24 7:58 ` Niklas Holsti
0 siblings, 1 reply; 2+ messages in thread
From: Nasser M. Abbasi @ 2019-01-24 3:59 UTC (permalink / raw)
I forgot these since I did not program in Ada for long time.
Very basic question. In this
---------------------------
with Ada.Text_Io;
with Ada.Numerics.Real_Arrays;
procedure main is
A : constant Ada.Numerics.Real_Arrays.Real_Matrix :=
(( 1.0, 2.0, 3.0),
( 4.0, 5.0, 6.0),
( 7.0, 8.0, 9.0));
v : constant Ada.Numerics.Real_Arrays.Real_Vector := (1.0,2.0,3.0);
procedure put (x : Ada.Numerics.Real_Arrays.Real_Vector) is
begin
FOR e of x LOOP
Ada.Text_Io.put_line(float'image(e));
END LOOP;
end put;
--use Ada.Numerics.Real_Arrays;
begin
put(A*v); -- error here, since it does not see *
end main;
------------------
How can I write put(A*v) above, without having to do
use Ada.Numerics.Real_Arrays;
above it?
I am trying to see if I can avoid doing use Ada.Numerics.Real_Arrays
so that I can explicitly add Ada.Numerics.Real_Arrays.something every
where, so I know where the something is coming from when looking at
the code.
But what about the *? How to tell Ada it is coming from
Ada.Numerics.Real_Arrays without doing an explicit use? What
would the syntax be?
Using gnat community 2018.
Thanks
--Nasser
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: basic question on Ada programming
2019-01-24 3:59 basic question on Ada programming Nasser M. Abbasi
@ 2019-01-24 7:58 ` Niklas Holsti
0 siblings, 0 replies; 2+ messages in thread
From: Niklas Holsti @ 2019-01-24 7:58 UTC (permalink / raw)
On 19-01-24 05:59 , Nasser M. Abbasi wrote:
> I forgot these since I did not program in Ada for long time.
>
> Very basic question. In this
>
> ---------------------------
> with Ada.Text_Io;
> with Ada.Numerics.Real_Arrays;
>
> procedure main is
> A : constant Ada.Numerics.Real_Arrays.Real_Matrix :=
> (( 1.0, 2.0, 3.0),
> ( 4.0, 5.0, 6.0),
> ( 7.0, 8.0, 9.0));
>
> v : constant Ada.Numerics.Real_Arrays.Real_Vector := (1.0,2.0,3.0);
> procedure put (x : Ada.Numerics.Real_Arrays.Real_Vector) is
> begin
> FOR e of x LOOP
> Ada.Text_Io.put_line(float'image(e));
> END LOOP;
> end put;
> --use Ada.Numerics.Real_Arrays;
> begin
> put(A*v); -- error here, since it does not see *
> end main;
> ------------------
>
> How can I write put(A*v) above, without having to do
>
> use Ada.Numerics.Real_Arrays;
>
> above it?
Ada.Numerics.Real_Arrays."*" (A,v)
Or do "use type Ada.Numerics.Real_Arrays.Real_Matrix".
Or rename the operator "*" locally. But "use type" is better.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-24 7:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 3:59 basic question on Ada programming Nasser M. Abbasi
2019-01-24 7:58 ` Niklas Holsti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox