TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Programming Language Advocacy (83 & 95)" <[log in to unmask]>
X-To:
"Prichard, Jayson (Space Technology)" <[log in to unmask]>
Date:
Thu, 11 Nov 2004 07:13:59 -0500
MIME-version:
1.0
Reply-To:
Roger Racine <[log in to unmask]>
Content-type:
text/plain; format=flowed; charset=us-ascii
Subject:
From:
Roger Racine <[log in to unmask]>
In-Reply-To:
Content-transfer-encoding:
7BIT
Parts/Attachments:
text/plain (23 lines)
At 01:04 PM 11/10/2004 -0800, Prichard, Jayson (Space Technology) wrote:
>I am writing a subroutine that has one parameter, another subroutine that
>I want the second subroutine to execute.  Does anyone have any ideas how
>to do this?

Ada95 or Ada83?  With Ada95 it is quite straightforward (see section 3.10
of the Reference Manual).  You simply create an access type and use the
access type  as the parameter.

...
type procedure_access is access procedure (. . .);
procedure my_proc (proc_access : in procedure_access);
...
procedure real_proc (...)  -- same arguments as in the type declaration
...
my_proc (real_proc'access);

For Ada83, it could still be done for all the compilers I used, but was
implementation dependent.  As I recall, one used the 'address of the
procedure, and then used a representation clause to call the procedure.

Roger Racine

ATOM RSS1 RSS2