comp.lang.ada
 help / color / mirror / Atom feed
From: Anton Gibbs <agibbs@dera.gov.uk>
Subject: Re: Subverting 'Access for Sub-programs
Date: 1999/08/04
Date: 1999-08-04T00:00:00+00:00	[thread overview]
Message-ID: <37A7FDE8.4F5@dera.gov.uk> (raw)
In-Reply-To: 37A71EF1.2201@dera.gov.uk

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."




  parent reply	other threads:[~1999-08-04  0:00 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-03  0:00 Subverting 'Access for Sub-programs Anton Gibbs
1999-08-03  0:00 ` Brian Rogoff
1999-08-03  0:00 ` Michael F. Yoder
1999-08-03  0:00 ` David C. Hoos, Sr.
1999-08-05  0:00   ` Robert A Duff
1999-08-03  0:00 ` Ted Dennison
1999-08-03  0:00 ` Steve Doiel
1999-08-03  0:00 ` tmoran
1999-08-04  0:00 ` Anton Gibbs [this message]
1999-08-04  0:00   ` Jean-Pierre Rosen
1999-08-04  0:00     ` Brian Rogoff
1999-08-05  0:00       ` Jean-Pierre Rosen
1999-08-05  0:00         ` adam
1999-08-05  0:00           ` adam
1999-08-06  0:00             ` Robert A Duff
1999-08-06  0:00               ` adam
1999-08-09  0:00                 ` Robert A Duff
1999-08-09  0:00                 ` Mark Biggar
1999-08-05  0:00           ` Robert Dewar
1999-08-05  0:00             ` What is a Display ? (was: Subverting 'Access for Sub-programs) Larry Kilgallen
1999-08-05  0:00               ` Hyman Rosen
1999-08-06  0:00                 ` Robert Dewar
1999-08-06  0:00               ` Robert Dewar
1999-08-05  0:00         ` Subverting 'Access for Sub-programs Robert A Duff
1999-08-05  0:00           ` Robert Dewar
1999-08-05  0:00           ` Brian Rogoff
1999-08-06  0:00             ` Robert Dewar
1999-08-09  0:00               ` Tucker Taft
1999-08-10  0:00                 ` Robert Dewar
1999-08-11  0:00                   ` Dmitry A. Kazakov
1999-08-11  0:00                     ` Robert Dewar
1999-08-12  0:00                       ` Dmitry A. Kazakov
1999-08-14  0:00                         ` Robert Dewar
1999-08-16  0:00                           ` Dmitry A. Kazakov
1999-08-11  0:00                     ` Richard D Riehle
1999-08-11  0:00                   ` Robert A Duff
1999-08-11  0:00                     ` Robert Dewar
1999-08-11  0:00                   ` Tucker Taft
1999-08-13  0:00                     ` Robert Dewar
1999-08-13  0:00                     ` Robert Dewar
1999-08-13  0:00                       ` Brian Rogoff
1999-08-05  0:00           ` tmoran
1999-08-06  0:00             ` Robert A Duff
1999-08-06  0:00         ` Brian Rogoff
1999-08-07  0:00           ` Gautier
1999-08-05  0:00     ` Robert A Duff
1999-08-05  0:00       ` Robert Dewar
1999-08-05  0:00         ` Brian Rogoff
1999-08-04  0:00   ` Robert A Duff
1999-08-04  0:00     ` Brian Rogoff
1999-08-05  0:00       ` tmoran
1999-08-05  0:00         ` Aidan Skinner
1999-08-05  0:00         ` Robert Dewar
1999-08-05  0:00           ` Ray Blaak
1999-08-06  0:00             ` Jean-Pierre Rosen
1999-08-06  0:00               ` Hyman Rosen
1999-08-07  0:00                 ` Florian Weimer
1999-08-06  0:00             ` Robert Dewar
1999-08-06  0:00               ` Robert A Duff
1999-08-08  0:00                 ` Brian Rogoff
1999-08-09  0:00                   ` Robert A Duff
1999-08-10  0:00                     ` Brian Rogoff
1999-08-09  0:00                 ` Tucker Taft
1999-08-05  0:00     ` Anton Gibbs
1999-08-05  0:00   ` Steve Quinlan
1999-08-04  0:00 ` Robert Dewar
1999-08-04  0:00   ` Robert A Duff
1999-08-04  0:00     ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox