While experimenting, I came across the “homograph clash issue”, which brought a question. An concrete example: first snippet works fine, the second give compile error.
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Vectors;
procedure Q_good is
package Int_Vectors is new Ada.Containers.Vectors (Positive, Integer);
use Int_Vectors;
V : Vector := 1 & 11 & 111;
begin
null;
end Q_good;
However, removing use Int_Vectors and using the dot notation produces compile error (below):
with Ada.Containers; use Ada.Containers;
with Ada.Containers.Vectors;
procedure Q_bad is
package Int_Vectors is new Ada.Containers.Vectors (Positive, Integer);
V : Int_Vectors.Vector := 1 & 11 & 111;
begin
null;
end Q_bad;
gcc -c q_bad.adb q_bad.adb:6:33: error: invalid operands for concatenation q_bad.adb:6:33: error: maybe "and" was meant gnatmake: "q_bad.adb" compilation error
In this example the compiler is interpreting the & as a homograph for and, which explains the need for “use” clause ,
But, this makes me wonder: How would one signify that the ampersand should be associated with the package Int_Vectors ? I tried variations on Int_Vectors.& etc. with no luck.