comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Re: Q: Pointers to procedures/functions
Date: 1997/04/12
Date: 1997-04-12T00:00:00+00:00	[thread overview]
Message-ID: <860814408.18snx@jvdsys.nextjk.stuyts.nl> (raw)
In-Reply-To: 1997Apr11.143821.5866@news


>Is there a way to have pointers to procedures in Ada ?

Yes, see RM 3.10. Example:

   with Ada.Text_IO; use Ada.Text_IO;

   procedure Test is

      type Function_Call is access function (N : Integer) return Integer;

      function Double_It (N : Integer) return Integer is
      begin
         return 2 * N;
      end Double_It;

      function Triple_It (N : Integer) return Integer is
      begin
         return 3 * N;
      end Triple_It;

      procedure Display (N : in Integer; F : in Function_Call) is
      begin
         Put ("Calling function on value" & Integer'Image (N));
         Put (" results in" & Integer'Image (F (N)));
         New_Line;
      end Display;

   begin
      Display (4, Double_It'Access);
      Display (4, Triple_It'Access);
   end Test;

--

-- Jerry van Dijk       | Haarlem, Holland
-- Business Consultant  | Team Ada
-- Ordina Finance       | jdijk@acm.org




      parent reply	other threads:[~1997-04-12  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-11  0:00 Q: Pointers to procedures/functions Gautier
1997-04-11  0:00 ` Jon S Anthony
1997-04-13  0:00   ` Nick Roberts
1997-04-12  0:00 ` Jerry van Dijk [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox