with Ada.Unchecked_Deallocation;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   --  an incomplete type with known discriminants, completed by a record that repeats them
   type Inc (D : Integer);
   type Acc is access Inc;
   type Inc (D : Integer) is record
      C : Integer := 0;
   end record;
   P : Acc := new Inc'(D => 1, C => 2);
   --  a private type with unknown discriminants: its objects take initial values
   package Q is
      type T (<>) is private;
      function Make (N : Integer) return T;
      function Value (X : T) return Integer;
   private
      type T is record
         C : Integer;
      end record;
   end Q;
   package body Q is
      function Make (N : Integer) return T is (C => N);
      function Value (X : T) return Integer is (X.C);
   end Q;
   X : constant Q.T := Q.Make (5);
   procedure Free is new Ada.Unchecked_Deallocation (Inc, Acc);
begin
   pragma Assert (P.D = 1 and P.C = 2 and Q.Value (X) = 5);
   Put_Line (Integer'Image (P.D) & Integer'Image (P.C) & Integer'Image (Q.Value (X)));
   Free (P);
end Main;
