Inspirel banner

Programming Distributed Systems with YAMI4

10.2.2 Packages

Packages are top-level entities, which means that they enclose all other definitions. Packares are defined in the following way:

package My_System is

   --  package content goes here

end My_System;

Packages can import other packages, which allows their definitions to use qualified names (that is, names prefixed with the originating package name) from imported packages.

For example, the Common package might define the Text record type:

package Common is   

   type Text is
      Content : String;
   end Text;

end Common;

while the Hello package might import the Common package and refer to the Text type defined there:

import Common;

package Hello is

   interface Greetings is
      oneway message Say_Hello (T : in Common.Text);
   end Greetings;

end Hello;

Names from imported packages are qualified with the originating package name - in the above example the Common.Text name refers to the Text name from the Common package.

Packages can also have child packages:

package Parent.Child is

   --  ...

end Parent.Child;

The child package in many aspects acts as a nested scope with regard to the parent package and can use names from the parent package without qualification.