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 X-Google-Attributes: gid103376,public From: "Michael F. Yoder" Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/03 Message-ID: <37A6F747.39318757@decada.zko.dec.com>#1/1 X-Deja-AN: 508452710 Content-Transfer-Encoding: 7bit References: <37A71EF1.2201@dera.gov.uk> Organization: Compaq 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: Anton Gibbs wrote: > > 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? > ... Is the following rearranged version, which compiled and ran using GNAT, sufficient? If not, is there something missing from your example that shows your problem more exactly? 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; package body Database is procedure Perform( Action : in Action_Type ) is begin for I in 1 .. 10 loop Action.all(I); end loop; end Perform; end Database; package p is procedure Print_If_Even( I : in Integer ); end p; with Ada.Text_IO; package body p is procedure Print_If_Even( I : in Integer ) is begin if I rem 2 = 0 then Ada.Text_IO.Put_Line( Integer'Image( I ) ); end if; end Print_If_Even; end p; with Database; with p; procedure Main is begin Database.Perform( Action => p.Print_If_Even'Access ); end Main; -- Michael F. Yoder Unscientific man is beset by a deplorable desire to have been right. The scientist is distinguished by a desire to *be* right. -- W.V. Quine