From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 21 Sep 92 18:32:39 GMT From: agate!linus!linus.mitre.org!mwvm.mitre.org!M19481@ucbvax.Berkeley.EDU Subject: Re: Using Global Variables Message-ID: <16869CC93.M19481@mwvm.mitre.org> List-Id: >OK. Let's get specific. Assuming that having to `with' a package does >not violate the definition of global, the following is definitely the >declaration of a global variable: > > package Contains_Global is > Global_Variable : Integer; > end Contains_Global; > >Now I can effectively convert this to declare the variable inside the >package body, but instead of assignment (a predefined procedure with >special semantics), I must provide my own procedures to access it: > > package Convert_Global is > procedure Put (Value : in Integer); > procedure Get (Value : out Integer); > > pragma Inline (Put, Get); > end Convert_Global; > > package body Convert_Global is > Is_This_A_Global_Variable : Integer; ----------- What do you say? > > procedure Put (Value : in Integer) is > begin > Is_This_A_Global_Variable := Value; > end Put; > > procedure Get (Value : out Integer) is > begin > Value := Is_This_A_Global_Variable; > end Get; > > end Convert_Global; > >In an attempt to limit the potential explosion of discussion about >why one is better than the other--let's try to define the term `Global' >first! What is the Integer declared inside the package body? > >Doug >smithd@software.org Yes, I'd call Is_This_A_Global_Variable global, because it can be used by anyone for any purpose. The only way to know how it's being used and whether one procedure may be clobbering the value entered by another procedure would be to look at every instance of Get and Put in the system and to understand the relationships between the procedures that they appear in. David