type defining_identifier [discriminant_part] is [[abstract] tagged] [limited] private;
type defining_identifier [discriminant_part] is
[abstract] new ancestor_subtype_indication with private;
type T1 is tagged limited private;
procedure Foo(X : in T1'Class);
private
type T1 is tagged null record; --Illegal!
--This should say "tagged limited null record".
end P1;
type A is access T1'Class;
Global : A;
procedure Foo(X : in T1'Class) is
begin
Global := new T1'Class'(X);
--This would be illegal if the full view of
--T1 were limited, like it's supposed to be.
end A;
end P1;
package P2 is
type T2(D : access Integer) --Trouble!
is new P1.T1 with
record
My_Task : Some_Task_Type; --More trouble!
end record;
end P2;
with P2;
procedure Main is
Local : aliased Integer;
Y : P2.T2(A => Local'Access);
begin
P1.Foo(Y);
end Main;
type Parent is private;
private
type Parent is tagged
record
X: Integer;
end record;
end P;
type T is new Parent;
end Q;
package body P is
... T'Class ... --Illegal!
Object: T;
... Object.X ... --Illegal!
... Parent(Object).X ... --OK.
end P;
type T(D : Integer) is private;
private
type T is new Some_Other_Type; --Illegal!
end P;
type T2 is new T1(Discrim => 3) with private;
private
type T2 is new T1(Discrim => 999) --Illegal!
with record ...;
end P;
...
package P is
type Two_Discrims(B: Boolean; C: Integer) is new One_Discrim with private;
private
type Two_Discrims(B: Boolean; C: Integer) is new One_Discrim(A => C) with
record
...
end record;
end P;
type File_Name is limited private;
type Root is tagged null record;
procedure Op1(X : Root);
private
procedure Op2(X : Root);
procedure Int_Op(X : My_Int);
end Parent;
package Unrelated is
type T2 is new Root with null record;
procedure Op2(X : T2);
end Unrelated;
type T3 is new Root with null record;
--Op1(T3) implicitly declared here.
type T4 is new Root with null record;
private
...
end Nested;
private
--Op2(T3) implicitly declared here.
...
end Parent.Child;
package body Parent.Child is
package body Nested is
--Op2(T4) implicitly declared here.
end Nested;
end Parent.Child;
type Comp1 is private;
private
type Comp1 is new Boolean;
end P;
package R is
type Comp2 is limited private;
type A is array(Integer range <>) of Comp2;
private
type Comp2 is new Comp1;
--A becomes nonlimited here.
--"="(A, A) return Boolean is implicitly declared here.
...
end R;
private
--Now we find out what Comp1 really is, which reveals
--more information about Comp2, but we're not within
--the immediate scope of Comp2, so we don't do anything
--about it yet.
end P.Q;
package body R is
--Things like "xor"(A, A) return A are implicitly
--declared here.
end R;
end P.Q;
type Key is private;
Null_Key : constant Key; --a deferred constant declaration (see 7.4)
procedure Get_Key(K : out Key);
function "<" (X, Y : Key) return Boolean;
private
type Key is new Natural;
Null_Key : constant Key := Key'First;
end Key_Manager;
Last_Key : Key := Null_Key;
procedure Get_Key(K : out Key) is
begin
Last_Key := Last_Key + 1;
K := Last_Key;
end Get_Key;
begin
return Natural(X) < Natural(Y);
end "<";
end Key_Manager;