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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,73f097f1e2686cf5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-09-07 01:20:41 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!213.155.153.242!not-for-mail From: Peter Amey Newsgroups: comp.lang.ada Subject: Re: Simplest way to protect a variable ? Date: Fri, 07 Sep 2001 09:21:02 +0100 Organization: Praxis Critical Systems Message-ID: <3B98836E.CDA7CB74@praxis-cs.co.uk> References: <9n9r4c$srt$1@snipp.uninett.no> NNTP-Posting-Host: 213.155.153.242 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 999850840 6834683 213.155.153.242 (16 [69815]) X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:12868 Date: 2001-09-07T09:21:02+01:00 List-Id: Reinert Korsnes wrote: > > Hi, > > Let's say I initiate a "global" variable, A (for example an array), by > calling a procedure (which may read data from a file). And I want to be > sure that the content (value) of this variable is not changed by > another procedure. The variable is "global" in the sense that it is > available in many many other routines. > > I may have several co-programmers I do not trust :-) > > What is the simplest way to do this (in Ada) ? > I don't know if it is the easiest way, but you could have a Boolean "Already_Initialised" flag in the package that owns the array. This would be set to False during elaboration of the package body. Your Initialise procedure would refuse to do anything if Already_Initialised is set to True and would set it to True after performing the first and only update of the array. The array would, of course, also have to be in the package body (allowing read access via exported subprograms) in order to prevent any direct updating of it. Peter