The Ada Program: up.adb

  1 -- up.adb:  Passing subprograms up
  2 
  3 procedure Up is
  4    type F is access procedure (X: Integer);
  5    procedure P (X: Integer) is begin null; end P;
  6    function R return F is
  7       procedure T (X: Integer) is begin null; end T;
  8    begin
  9       if xxxx then
 10          return P'Access;  -- no problem
 11       else
 12          return T'Access;  -- subprogram "T" deeper than access type
 13       end if;
 14    end R;
 15 begin
 16    R.all (3);
 17 end Up;