From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec06888ca495a8ff X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!postnews.google.com!v33g2000cwv.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Newbie question: Implementing a callback mechanism with Ada 83 Date: 12 Feb 2007 11:32:41 -0800 Organization: http://groups.google.com Message-ID: <1171308761.841427.26290@v33g2000cwv.googlegroups.com> References: <1171136299.920852.179650@v33g2000cwv.googlegroups.com> <1171230053.064136.26460@v33g2000cwv.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1171308768 17642 127.0.0.1 (12 Feb 2007 19:32:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 12 Feb 2007 19:32:48 +0000 (UTC) In-Reply-To: <1171230053.064136.26460@v33g2000cwv.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: v33g2000cwv.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news2.google.com comp.lang.ada:9293 Date: 2007-02-12T11:32:41-08:00 List-Id: On Feb 11, 1:40 pm, "benibi...@gmail.com" wrote: > By the way, a friend of mine whose is more experienced in Ada send me > this mail which I wanted to share with you. > > =========================================================== > > "I can't claim to be an expert at Ada programming, and I usually use > Ada95, so I may suggest a solution that is cannot be implemented in > Ada83, but I have a few suggestions that you could try. > > 1. The solution to having no access-to-subprogram type in Ada83 is > usually passing the address of the function around and then in Ada a > function can be declared to 'use' that address as it's own like so: > > procedure Foo; > > procedure Install_Handler ( Event : Event_Type; Event_Handler : > System.Address ) is > begin > Event_Array(Event_Type) := Event_Handler; > end Install_Handler; > > procedure Call_Handler ( Event : Event_Type ) is > procedure Temp; > for Temp use at Event_Array(Event); > begin > Temp; > end Call_Handler; This may or may not work; as far as I know, it's going to depend on your particular compiler vendor. You might need to add an Interface pragma, which may be called something different in different Ada implementations (this was replaced by the Import pragma in Ada 95): procedure Call_Handler (Event : Event_Type) is procedure Temp; pragma Interface (Ada, Temp); for Temp use at Event_Array(Event); begin ... If you just use the "use at", an Ada compiler *should* complain that there's no body for Temp---the existence of a "for ... use at" isn't supposed to be enough to tell the compiler that Temp's body will exist somewhere else. The Interface pragma should tell the compiler not to expect a body. However, this is a non-standard feature so there's no telling what compilers may or may not allow that they technically shouldn't have. Basically, you'll probably have to check your compiler implementation documentation or contact them and ask. Or you can just experiment to see if you can get the compiler to do what you want. If it were me, I'd try to find out why Ada 83 is such a hard-and-fast requirement---there isn't much downside to switching to Ada 95, as far as I can tell, unless you're on one of those obsolete machines for which the manufacturer never bothered to upgrade their Ada compiler to Ada 95. -- Adam