I work with mechanical engineers, but I'm interested in learning good software development practices with Ada. I have a few requests.
Q1. If I understand correctly, someone can simply write a package specification file (declarations), compile it, and then compile the main program that uses the package. Later, when someone knows what to include in the package body, the latter can be written and compiled. After that, you can run the main program. I tried this and I would like to confirm that this is a good practice.
Q2. My second question is about stubs (subsections) and the use of SEPARATE. Let's say I have a main program:
WITH Ada.Float_Text_IO;
WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
PROCEDURE TEST2 IS
A,B : FLOAT;
N : INTEGER;
PROCEDURE INPUT(A,B: OUT FLOAT; N: OUT INTEGER) IS SEPARATE;
BEGIN -- main program
INPUT(A,B,N);
Ada.Float_Text_IO.Put(Item => A);
Ada.Text_IO.New_line;
Ada.Integer_Text_IO.Put(Item => N);
END TEST2;
Then I have the INPUT procedure in a separate file:
separate(TEST2)
PROCEDURE INPUT(A,B: OUT FLOAT; N: OUT INTEGER) IS
BEGIN
Ada.Float_Text_IO.Get(Item => A);
Ada.Text_IO.New_line;
Ada.Float_Text_IO.Get(Item => B);
Ada.Text_IO.New_line;
Ada.Integer_Text_IO.Get(Item => N);
END INPUT;
:
a) AdaGIDE INPUT input.adb. 2 :
warning: subunit "TEST2.INPUT" in file "test2-input.adb" not found
cannot generate code for file test2.adb (missing subunits)
AdaGIDE , :
Compiling...
Done
, input.adb test2-input.adb, AdaGIDE . . ,
PROCEDURE INPUT(A,B: OUT FLOAT; N: OUT INTEGER) IS
sub-unit test2-input.adb, ,
PROCEDURE TEST2-INPUT(A,B: OUT FLOAT; N: OUT INTEGER) IS
, test2? AdaGIDE, test2-input.adb, .
b) :
, test2.adb, test2-input.adb. :
cannot generate code for file test2-input.adb (subunit)
Done--error detected
test2.adb .
, , stub test2-input.adb ?
Q3. ? ? , , BEGIN END . , , . - , NULL BEGIN END . , ?
...