comp.lang.ada
 help / color / mirror / Atom feed
* Passing a function "pointer"
@ 1998-05-24  0:00 Brendan Reville
  1998-05-24  0:00 ` Matthew Heaney
  0 siblings, 1 reply; 3+ messages in thread
From: Brendan Reville @ 1998-05-24  0:00 UTC (permalink / raw)



hi there,

I need to pass a "pointer" (access type?) to a procedure, to another
procedure.  The second procedure will then call the first using this
pointer.  How exactly can I do this?  Do I need to create an access type
to a procedure??  (I'm mainly not sure about the syntax...)

Actually, I also need to do this, not for a normal procedure, but for a
task's entry point.  Can I pass a "pointer" to a task's entry point? 
Again, exactly how?

Thanks heaps.  I'm doing Ada for an honours course, and just wasn't sure
how to do these things.

Much appreciated.

- Brendan Reville




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Passing a function "pointer"
  1998-05-24  0:00 Passing a function "pointer" Brendan Reville
@ 1998-05-24  0:00 ` Matthew Heaney
  1998-05-26  0:00   ` Fabrizio Castrotorres
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Heaney @ 1998-05-24  0:00 UTC (permalink / raw)



In article <3567CBEB.3098@mpce.mq.edu.au>, Brendan Reville
<breville@mpce.mq.edu.au> wrote:

>I need to pass a "pointer" (access type?) to a procedure, to another
>procedure.  The second procedure will then call the first using this
>pointer.  How exactly can I do this?  Do I need to create an access type
>to a procedure??  (I'm mainly not sure about the syntax...)

Ada is described in terms in BNF in the RM; you may have learned how to
learn BNF in your compiler class or something.

Follow the syntax as it appears in the RM.  The description of access types
is in section 3.10.

Here are a couple of examples:

type Procedure_Access is access procedure (I : in Integer);

type Function_Access is access function (I : Integer) return Float;

>Actually, I also need to do this, not for a normal procedure, but for a
>task's entry point.  Can I pass a "pointer" to a task's entry point? 
>Again, exactly how?

I'm not sure you can do that.  You may have to call a wrapper procedure,
that in turn calls the task entry.

>Thanks heaps.  I'm doing Ada for an honours course, and just wasn't sure
>how to do these things.

You need to read the RM.  Copies are available on-line if you don't have a
hard-copy.

<http://www.adahome.com/>




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Passing a function "pointer"
  1998-05-24  0:00 ` Matthew Heaney
@ 1998-05-26  0:00   ` Fabrizio Castrotorres
  0 siblings, 0 replies; 3+ messages in thread
From: Fabrizio Castrotorres @ 1998-05-26  0:00 UTC (permalink / raw)



Could you not use a function that takes as an argument a generic function ?
If this is all you need to do a generic function argument should do the trick.

matthew_heaney@acm.org (Matthew Heaney) writes:

>In article <3567CBEB.3098@mpce.mq.edu.au>, Brendan Reville
><breville@mpce.mq.edu.au> wrote:

>>I need to pass a "pointer" (access type?) to a procedure, to another
>>procedure.  The second procedure will then call the first using this
>>pointer.  How exactly can I do this?  Do I need to create an access type
>>to a procedure??  (I'm mainly not sure about the syntax...)

>Ada is described in terms in BNF in the RM; you may have learned how to
>learn BNF in your compiler class or something.

>Follow the syntax as it appears in the RM.  The description of access types
>is in section 3.10.

>Here are a couple of examples:

>type Procedure_Access is access procedure (I : in Integer);

>type Function_Access is access function (I : Integer) return Float;

>>Actually, I also need to do this, not for a normal procedure, but for a
>>task's entry point.  Can I pass a "pointer" to a task's entry point? 
>>Again, exactly how?

>I'm not sure you can do that.  You may have to call a wrapper procedure,
>that in turn calls the task entry.

>>Thanks heaps.  I'm doing Ada for an honours course, and just wasn't sure
>>how to do these things.

>You need to read the RM.  Copies are available on-line if you don't have a
>hard-copy.

><http://www.adahome.com/>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-05-26  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-24  0:00 Passing a function "pointer" Brendan Reville
1998-05-24  0:00 ` Matthew Heaney
1998-05-26  0:00   ` Fabrizio Castrotorres

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