comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <jrcarter@acm.org>
Subject: Re: Newbie question: Implementing a callback mechanism with Ada 83
Date: Sun, 11 Feb 2007 02:46:16 GMT
Date: 2007-02-11T02:46:16+00:00	[thread overview]
Message-ID: <Yrvzh.268605$aJ.222221@attbi_s21> (raw)
In-Reply-To: <1171136299.920852.179650@v33g2000cwv.googlegroups.com>

benibilme@gmail.com wrote:
> 
> I need to develop an Ada application which must conform to Ada83. It
> will be part of legacy system. I am very much new in Ada. The
> application I have to develop is very much event driven. As an old
> time C programmer I wanted to implement an event handling module which
> you can subscribe callback functions and trigger the events when
> necessary and unfortunately I have realized that Ada 83 does not
> support pointer to subprograms. I have read about generics with which
> defining subprograms as parameters of subprograms seems possible. On
> the other hand, I could not figure out how to do it.

Why do you want to register callbacks for the events? Does the 
processing for a given event change during execution?

If not, there's no need for callbacks. The handling for a given event 
can know what subprogram to call.

If they do, you no doubt have a fixed set of subprograms that can be 
needed for a given event, under a fixed set of conditions. You could 
have the handling for a given event test the condition and call the 
appropriate subprogram for the current condition.

If you have a need to decouple the detection/generation of events from 
their handling, then the event package can add the events to a queue as 
they're detected, and the handling package can remove them from the 
queue and call the appropriate handling operation, which can test the 
condition and call the appropriate subprogram. If your system is 
concurrent, the queue can allow the caller to block when the queue is 
empty. This is often preferable to polling.

If none of these will work, then I don't understand enough to make a 
meaningful comment. More detail from you might help alleviate that.

-- 
Jeff Carter
"C's solution to this [variable-sized array parameters] has real 
problems, and people who are complaining about safety definitely have a 
point."
Dennis Ritchie
25



  parent reply	other threads:[~2007-02-11  2:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-10 19:38 Newbie question: Implementing a callback mechanism with Ada 83 benibilme
2007-02-10 20:40 ` Dmitry A. Kazakov
2007-02-11  2:46 ` Jeffrey R. Carter [this message]
2007-02-11 21:40   ` benibilme
2007-02-12  5:03     ` Jeffrey R. Carter
2007-02-12 19:32     ` Adam Beneschan
replies disabled

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