--  A call through a renaming, or through a generic formal subprogram, names and defaults its
--  parameters as the renaming or the formal does (RM 8.5.4(7), 12.6(9)).
with Ada.Text_IO;
procedure Main is
   procedure Scale (Value : in out Integer; By : Integer := 2)
     with Pre => Value in 0 .. 1000 and By in 0 .. 10, Post => Value = Value'Old * By;
   procedure Scale (Value : in out Integer; By : Integer := 2) is
   begin
      Value := Value * By;
   end Scale;
   procedure Grow (Amount : in out Integer; Factor : Integer := 3) renames Scale;
   function Sum (A, B : Integer) return Integer is (A + B)
     with Pre => A in 0 .. 1000 and B in 0 .. 1000;
   function Add (Left, Right : Integer) return Integer renames Sum;
   generic
      with procedure Change (First : in out Integer; Second : Integer);
      with function Combine (X : Integer; Y : Integer := 10) return Integer;
   procedure Apply (V : in out Integer)
     with Pre => V in 0 .. 100, Post => V = V'Old * 2 + 10;
   procedure Apply (V : in out Integer) is
   begin
      Change (First => V, Second => 2);
      V := Combine (X => V);
   end Apply;
   procedure Twice is new Apply (Scale, Sum);
   N : Integer := 5;
begin
   Grow (Amount => N);                        --  Factor's default: 3
   pragma Assert (N = 15);
   Grow (Amount => N, Factor => 2);
   pragma Assert (N = 30 and Add (Right => 1, Left => 2) = 3);
   Twice (N);
   pragma Assert (N = 70);
   Ada.Text_IO.Put_Line (Integer'Image (N));
end Main;
