From: Alan E & Carmel J Brain <aebrain@dynamite.com.au>
Subject: Re: Are global or persistent variables in ADA?
Date: 1998/04/29
Date: 1998-04-29T00:00:00+00:00 [thread overview]
Message-ID: <35461630.4986@dynamite.com.au> (raw)
In-Reply-To: 35413389.46570978@news.gatech.edu
Brian Franklin wrote:
>
> I haven't found this in any of my books on ADA. Can I have a
> procedure retain it's variable value after it returns to it's calling
> routine? In C I can use STATIC in declaring such a variable.
Not quite, but you have a better alternative:
package SMALL_DATABASE is
AnInteger : Integer;
end SMALL_DATABASE;
anything that with's SMALL_DATABASE is able to do anything at all with
the variable AnInteger. Read it, write to it, whatever. It's static, and
won't go away.
But... this is not always a good idea. Maybe you should have
package SMALL_DATABASE is
function ReadInteger return Integer;
procedure WriteInteger(Item : in Integer);
end SMALL_DATABASE;
and an appropriate body.
Maybe, and this is safer still, you should have a guardian task, so
calls are stackable, and the thing is re-usable in a multi-threaded
environment.
But often, the first version is enough. Only those packages that need to
look at/manipulate the data "with" it.
--
aebrain@dynamite.com.au <> <> How doth the little Crocodile
| Alan & Carmel Brain| xxxxx Improve his shining tail?
| Canberra Australia | xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM
abrain@cs.adfa.oz.au o OO*O^^^^O*OO o oo oo oo oo
By pulling MAERKLIN Wagons, in 1/220 Scale
prev parent reply other threads:[~1998-04-29 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-25 0:00 Are global or persistent variables in ADA? Brian Franklin
1998-04-25 0:00 ` Brian Franklin
1998-04-25 0:00 ` Tom Moran
1998-04-25 0:00 ` Steve Doiel
1998-05-01 0:00 ` Matthew Heaney
1998-04-29 0:00 ` Alan E & Carmel J Brain [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox