comp.lang.ada
 help / color / mirror / Atom feed
From: Samuel Tardieu <sam@ada.eu.org>
Subject: Re: Static variables?
Date: 1997/03/18
Date: 1997-03-18T00:00:00+00:00	[thread overview]
Message-ID: <qw6wwr54iby.fsf@esmeralda.enst.fr> (raw)
In-Reply-To: JSA.97Mar17193855@alexandria


>>>>> "Jon" == Jon S Anthony <jsa@alexandria> writes:

Jon> In article <332D71FF.4773@cae.ca> Viqar Abbasi <viqar@cae.ca>
Jon> writes:
>> Is there a way to declare local variables in ADA subprograms to be
>> STATIC?  That is, they retain the value that they had when the
>> subprogram was last exited.

Jon> Just put the variable at the same or lower scope than the
Jon> subprogram that is to use it.  Typically this is at package
Jon> level.

This is of course the way to do it, but your answer corresponds to the
case of a C toplevel static variable, not to the case of a C static
variable located in a function. In the first case, your variable may
be accessed by several subprograms, in the second one, it can only be
accessed by *one* C function.

This is not possible in Ada to have the equivalent of a C static
variable located in a function, you have to put it at the module
(package) level, let's say in the package body as Jon said.

  Sam
--
Samuel Tardieu -- sam@ada.eu.org




  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 [this message]
1997-03-18  0:00     ` Tom Moran
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