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 20:31:14 GMT From: seas.gwu.edu!mfeldman@uunet.uu.net (Michael Feldman) Subject: Re: Using Global Variables Message-ID: <1992Sep21.203114.17199@seas.gwu.edu> List-Id: In article <1992Sep21.165108.11129@software.org> smithd@software.org (Doug Smit h) writes: > [heavily edited] >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: > (1) > package Contains_Global is > Global_Variable : Integer; > end Contains_Global; > (2) > 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? This thread has been referring, I think, to the example in (1). The "locally global" variable in (2) is almost unavoidable in Ada, for reasons having nothing to do with efficiency. State information must either be kept "locally global", where it is visible to a group of operations but nobody else, or passed in parameters, which is a rather foolish violation of abstraction principles. C, following PL/1's example, and Algol 60's, allows _static_ data structures to be declared within a subprogram. Ada does not. Let's stick to case (1) if this thread is going to continue. Mike Feldman