with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
   function Id (X : Integer) return Integer is (X);
   S : String (1 .. 5) := "abcde";
   T : String (1 .. Id (6)) := "uvwxyz";
   procedure Set (C : out Character) with Post => C = 'z' is
   begin
      C := 'z';
   end Set;
   procedure Swap (P : in out String) with Pre => P'Length = 2, Post => P (P'First) = P'Old (P'Last) and P (P'Last) = P'Old (P'First) is
      X : constant Character := P (P'First);
   begin
      P (P'First) := P (P'Last);
      P (P'Last) := X;
   end Swap;
begin
   S (1 .. 4) (2 .. 3) := "XY";      --  a slice of a slice as a target
   Set (S (1 .. 4) (2));             --  a component of a slice as an `out` actual
   pragma Assert (S = "azYde");
   S (2 .. 5) (3 .. 5) (4) := 'Q';   --  a component of a slice of a slice
   pragma Assert (S = "azYQe");
   T (Id (2) .. 5) (3 .. 4) := "12";
   Swap (T (2 .. 6) (5 .. 6));       --  a slice of a slice as an `in out` actual
   pragma Assert (T = "uv12zy");
   Put_Line (S & " " & T);
end Main;
