3.3. Privacy - JulTob/Ada GitHub Wiki
Private types are useful for preventing the users of a package’s types from depending on the types’ implementation details.
The private
keyword splits the package spec into “public” and “private” parts.
That is somewhat analogous to C++’s partitioning of the class construct into different sections with different visibility properties. In Java, the encapsulation has to be done field by field.
In Ada the entire definition of a type can be hidden.
package Types is
type Type_1 is private;
type Type_2 is private;
type Type_3 is private;
procedure P (X : Type_1);
...
private
procedure Q (Y : Type_1);
type Type_1 is new Integer range 1 .. 1000;
type Type_2 is array (Integer range 1 .. 1000) of Integer;
type Type_3 is record
A, B : Integer;
end record;
end Types;
Remember you still may need a body file that implements the processes and functions, and some hidden types.