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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c3cec4fb2011babb X-Google-Attributes: gid103376,public From: Alan E & Carmel J Brain Subject: Re: Are global or persistent variables in ADA? Date: 1998/04/29 Message-ID: <35461630.4986@dynamite.com.au>#1/1 X-Deja-AN: 349423826 Content-Transfer-Encoding: 7bit References: <35413389.46570978@news.gatech.edu> Mime-Version: 1.0 Reply-To: aebrain@dynamite.com.au Content-Type: text/plain; charset=us-ascii Organization: @home Newsgroups: comp.lang.ada Date: 1998-04-29T00:00:00+00:00 List-Id: 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