comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Amey <peter.amey@praxis-cs.co.uk>
Subject: Re: Simplest way to protect a variable ?
Date: Fri, 07 Sep 2001 09:21:02 +0100
Date: 2001-09-07T09:21:02+01:00	[thread overview]
Message-ID: <3B98836E.CDA7CB74@praxis-cs.co.uk> (raw)
In-Reply-To: 9n9r4c$srt$1@snipp.uninett.no



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



  reply	other threads:[~2001-09-07  8:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-07  6:50 Simplest way to protect a variable ? Reinert Korsnes
2001-09-07  8:21 ` Peter Amey [this message]
2001-09-07  8:45 ` Wilhelm Spickermann
2001-09-07  9:13   ` Reinert Korsnes
2001-09-07  9:16     ` Reinert Korsnes
2001-09-07 13:15     ` Wilhelm Spickermann
2001-09-07 11:35   ` Reinert Korsnes
2001-09-07 13:26     ` Ted Dennison
2001-09-09 18:03       ` martin.m.dowie
2001-09-07 13:03 ` DuckE
2001-09-07 13:21 ` Ted Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox