The following program (main.adb) will not compile, giving the error:
main.adb:10:15: expected private type "ThreadName" defined at config.ads:5
main.adb:10:15: found private type "Ada.Strings.Unbounded.Unbounded_String"
main.adb:11:45: expected private type "Ada.Strings.Unbounded.Unbounded_String"
main.adb:11:45: found private type "ThreadName" defined at config.ads:5
Yet, when I add a "use Config;" clause and remove the Config. prefix to the declaration of MyName in main.adb, it compiles cleanly and works correctly. I had understood that the use of the "use" clause was simply to allow me to avoid the namespace prefixes, but it appears to do a lot more. Could anyone explain?
The file config.ads contains
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Config is
type ThreadName is new Unbounded_String;
end Config;
and my main.adb contains:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Config;
procedure Main is
MyName : Config.ThreadName;
begin
MyName := To_Unbounded_String ("Chris");
Put_Line ( "The name is: " & To_String (MyName));
end Main;