comp.lang.ada
 help / color / mirror / Atom feed
From: Tom Moran <tmoran@bix.com>
Subject: Re: Static variables?
Date: 1997/03/18
Date: 1997-03-18T00:00:00+00:00	[thread overview]
Message-ID: <332EBFCD.650@bix.com> (raw)
In-Reply-To: qw6wwr54iby.fsf@esmeralda.enst.fr


If the variable should really be private to a single function, like a C
static variable inside a function, how about:

package lots_of_things is
  ...
  procedure p_with_state;
  ...
end lots_of_things;

package body lots_of_things is
  ...
  package state_p is
    procedure actual_p;
  end state_p;
  package body state_p is
    static_variable : integer := 0;
    procedure actual_p is ... -- has access to static_variable
  end state_p;
  ...
  procedure p_with_state is
  begin
    state_p.actual_p;  -- call the real p procedure to do its thing
  end p_with_state;
  ...




  reply	other threads:[~1997-03-18  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-17  0:00 Static variables? Viqar Abbasi
1997-03-17  0:00 ` Robert Dewar
1997-03-18  0:00   ` nasser
1997-03-18  0:00 ` Jon S Anthony
1997-03-18  0:00   ` Samuel Tardieu
1997-03-18  0:00     ` Tom Moran [this message]
1997-03-19  0:00   ` Robert Dewar
1997-03-25  0:00     ` Richard A. O'Keefe
1997-03-25  0:00       ` Larry Kilgallen
1997-03-27  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