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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,88e7ef9008757431 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Function Calls by Address Date: 1999/08/31 Message-ID: <37cbe514@news1.us.ibm.net>#1/1 X-Deja-AN: 519314851 Content-transfer-encoding: 7bit References: <37CADE68.6AF06F5D@escmail.orl.lmco.com> X-Trace: 31 Aug 1999 14:22:12 GMT, 129.37.213.28 Organization: Global Network Services - Remote Access Mail & News Services X-Notice: should be reported to postmaster@ibm.net Content-Type: text/plain; charset="US-ASCII" Mime-version: 1.0 Newsgroups: comp.lang.ada X-Complaints-To: postmaster@ibm.net Date: 1999-08-31T00:00:00+00:00 List-Id: In article <37CADE68.6AF06F5D@escmail.orl.lmco.com> , Craig Jameson wrote: > Does any one know how to make dynamic function calls in Ada83. > I am writing an application using AIX Motif bindings and I > need to create a dynamic list of functions to be called when > a particular X event is dispatched. Any ideas on how to > create and use such a list? We always used to use 'Address. For example: package P is procedure CB (W : Widget; Client_Data : Addr_T; Call_Data : Addr_T); pragma Interface (C, CB); pragma Interface_Name (CB, "pcb"); pragma Export (CB, Name => "pcb"); (Or something like that. You might not even need the pragma Export, because you're referring to the subprogram by its address, not its name. But I don't remember. Look in the vendor's compiler manuals about being able to call Ada subprograms from another language.) You can then say CB'Address, which you pass to the C side. Make the subprogram is at library-level (though the compiler will probably tell if it isn't). Yes, this is vendor-specific, but I did X/Motif stuff in Ada83 for many years (on VMS and SUN boxes), and never had a problem. As others have pointed out, support for callbacks was added to the language for Ada95. The current debate is over support for some form of downward closures.