package defining_program_unit_name is
new generic_package_name [generic_actual_part];
| procedure defining_program_unit_name is
new generic_procedure_name [generic_actual_part];
| function defining_designator is
new generic_function_name [generic_actual_part];
(generic_association {, generic_association})
[generic_formal_parameter_selector_name =>] explicit_generic_actual_parameter
| subprogram_name | entry_name | subtype_mark
| package_instance_name
type Parent is tagged private;
type Comp is limited private;
package G1 is
type Extension is new Parent with
record
C : Comp; --Illegal!
end record;
end G1;
type Parent is tagged limited private; --Parent is limited.
type Comp is limited private;
package G2 is
type Extension is new Parent with
record
C : Comp; --OK.
end record;
end G2;
type Non_Limited_Tagged is tagged null record;
type Non_Limited_Untagged is null record;
Comp => Limited_Untagged);
package Good_2 is new G2(Parent => Non_Limited_Tagged,
Comp => Non_Limited_Untagged);
package Bad is new G2(Parent => Non_Limited_Tagged,
Comp => Limited_Untagged); --Illegal!
type Formal is new T1;
package G is
type Derived_From_Formal is new Formal with record ... end record;
procedure Foo(X : in Derived_From_Formal); --Does not override anything.
end G;
procedure Foo(X : in T2);
type Formal is new Ancestor with private;
package G is
type T is new Formal with null record;
procedure P(X : in T); --(1)
private
procedure Q(X : in T); --(2)
end G;
procedure P(X : in Actual);
procedure Q(X : in Actual);
type A is (<>);
type B is private;
package G is
function Next(X : A) return A;
function Next(X : B) return B;
end G;
--All calls of P.Next are ambiguous.
type T1 is private;
--A predefined "=" operator is implicitly declared here:
--function "="(Left, Right : T1) return Boolean;
--Call this "="1.
package G is
subtype S1 is T1; --So we can get our hands on the type from
--outside an instance.
type T2 is new T1;
--An inherited "=" operator is implicitly declared here:
--function "="(Left, Right : T2) return Boolean;
--Call this "="2.
Bool_1 : Boolean := T1_Obj = T1_Obj;
Bool_2 : Boolean := T2_Obj = T2_Obj;
end G;
...
type My_Int is new Integer;
--A predefined "=" operator is implicitly declared here:
--function "="(Left, Right : My_Int) return Boolean;
--Call this "="3.
function "="(X, Y : My_Int) return Boolean;
--Call this "="4.
--"="3 is hidden from all visibility by "="4.
--Nonetheless, "="3 can "reemerge" in certain circumstances.
end P;
use P;
...
package I is new G(T1 => My_Int); --"="5 is declared in I (see below).
use I;
Bool_3 : Boolean := Another_T1_Obj = Another_T1_Obj;
Bool_4 : Boolean := Another_T2_Obj = Another_T2_Obj;
procedure Swap is new Exchange(Character); --Swap is overloaded
function Square is new Squaring(Integer); --"*" of Integer used by default
function Square is new Squaring(Item => Matrix, "*" => Matrix_Product);
function Square is new Squaring(Matrix, Matrix_Product); --same as previous
N : Integer := Int_Vectors.Sigma(T); --150 (see 12.2, "Generic Bodies" for the body of Sigma)
M : Integer := Sigma(T); --150