Software Development Using Ada: Stubs; separate and compilation units

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--error detected

, 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 . , ?

...

+3
3

Q1: .

, , , , .

Q2: , AdaGIDE GNAT , GNAT . ( , , GNAT/AdaGIDE.) , , . . Q3...

Q3: Ada-Ada 83 - , . Ada , ///etc . - , , , . . .

+7

, (), . Ada, , (, ), , . , , , - , C.

, , , .

- ( ) , , . ( , ), , UML; . (, Windows vs Unix), ( ).

, . GNAT

procedure Foo is
   procedure Bar is separate;

Foo foo.adb, foo-bar.adb ( , , - gnatmake package Naming), , , ), ;

separate (Foo)
procedure Bar is

.

foo-bar.adb, ; GNAT . , foo.adb, . , .

GNAT , . gnatmake !

+4

, , , , - . , , :

begin
   null;
end;

- :

begin
   return The_Return_Type'first; --'
end;

... . , . , - , . , .

, gnat, Ada. , , . , , , , 30 .

+1

Source: https://habr.com/ru/post/1754101/


All Articles