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: Anton Gibbs Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/04 Message-ID: <37A7FDE8.4F5@dera.gov.uk>#1/1 X-Deja-AN: 508701466 Content-Transfer-Encoding: 7bit References: <37A71EF1.2201@dera.gov.uk> Organization: Eurocontrol Integration Team Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-04T00:00:00+00:00 List-Id: Dear Ada Community, Thank you, everyone, for all the very helpful responses to my question on 'Access. Unfortunately, in my eagerness to provide a simplified statement of my problem, I had omitted an important detail: in fact, the procedure which I called Main is really not the main program and, more importantly, it has a parameter which I need to access. What I mean is:- 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; package body Something is procedure Not_Main( F : in Integer ) is procedure Print_If_Multiple( I : in Integer ) is begin if I rem F = 0 then Text_IO.Put_Line( Integer'Image( I ) ); end if; end Print_If_Multiple; begin Database.Perform( Action => Print_If_Multiple'Access ); end Not_Main; end Something; Here, the problem is retaining visibility of the parameter F within the procedure whose 'Access I am trying to pass to the Perform operation. If I move Print_If_Multiple out to its own package (ie. out of the scope of Not_Main) then the only way I can see F is by using global data. I know this will work but I am reluctant to adopt this approach because I have often found that non-re-entrant code bites back in years to come when it gets re-used (usually by me) in a way the author never originally intended. I am attracted by Robert Dewar's 'Unrestricted_Access: it is obviously there for a reason. Thank you too for the candid explanation of why 'Unchecked_Access is prohibited on sub-programs. As someone who is often baffled by some of the language restrictions it is nice to get an explanation one can understand. I just wish I could understand the Ada95 LRM as well as I could the Ada83 one. Many thanks everyone. 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."