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,2308afbbe4ecec0b,start X-Google-Attributes: gid103376,public From: Anton Gibbs Subject: Subverting 'Access for Sub-programs Date: 1999/08/03 Message-ID: <37A71EF1.2201@dera.gov.uk>#1/1 X-Deja-AN: 508424613 Content-Transfer-Encoding: 7bit Organization: Eurocontrol Integration Team Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-03T00:00:00+00:00 List-Id: Dear Ada Community, Can someone please advise me on the best way to subvert the language rules that prevent the use of 'Access on a locally declared procedure ? For normal objects it is possible to use 'Unchecked_Access but for sub-programs this is not allowed. "Why does this idiot want to do this ?" I hear you ask. Well it seemed reasonable enough to me within a wider application, the essence of which I have distilled into a few lines below. package Database is type Action_Type is access procedure( I : in Integer ); -- Perform calls Action for every entry in the database procedure Perform( Action : in Action_Type ); end Database; with Database; with Text_IO; procedure Main is procedure Print_If_Even( I : in Integer ) is begin if I rem 2 = 0 then Text_IO.Put_Line( Integer'Image( I ) ); end if; end Print_If_Even; begin Database.Perform( Action => Print_If_Even'Access ); end Main; The offending statement is the one containing the 'Access because Print_If_Even is declared at deeper level than it. So how can I achieve what I need here (ie. visibility of parameter I) without either: a) using global data and making the whole thing unnecessarily non-reentrant; or b) recourse to the usual generic contortions which I thought Ada95's procedure access types had allowed us to escape from ? I am sure someone else must have run into this problem before and that there is an accepted way of tackling it. Thanks for any help you can offer. Best regards Anton Gibbs. Software Engineer -- Civil Air Traffic Management Group Defence Evaluation and Research Agency Bedford, UK "The Information contained in this E-Mail and any subsequent correspondence is private and is intended solely for the intended recipient(s). For those other than the intended recipient any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on such information is prohibited and may be unlawful."