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: 25 Sep 92 17:50:35 GMT From: sampson@cod.nosc.mil (Charles H. Sampson) Subject: Re: Using Global Variables Message-ID: <1992Sep25.175035.209@nosc.mil> List-Id: In article <1992Sep21.165108.11129@software.org> smithd@software.org (Doug Smit h) writes: ->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? As an early poster to this thread pointed out, the concept of global is relative. Nonetheless, I think it best to reserve the term for its classical usage: Something is global if it is visible throughout the en- tire system. Of course, in Ada nothing is automatically visible other than the things in package Standard, so we have to bend the classical usage a little to acknowledge the with clause. Thus that variable inside the package is not global. The term "regional", suggested by a recent poster, is a good one. As that early poster was implying, you have to be careful with regional data. If their namescopes become large most of the classical problems of global data arise. Charlie