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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: package body Date: Tue, 07 Oct 2014 13:17:00 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <7c811e73-61e2-4c89-abb3-749d31461758@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Tue, 7 Oct 2014 20:17:00 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2cce0a40174b83136a5e3a34df5b5ee7"; logging-data="21021"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/fWYk9rnpgEAGPDwPnQWmxhqEwhOsvvbw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 In-Reply-To: <7c811e73-61e2-4c89-abb3-749d31461758@googlegroups.com> Cancel-Lock: sha1:+LIC7EGs3rBwvcieVz44ODxeGS4= Xref: news.eternal-september.org comp.lang.ada:22197 Date: 2014-10-07T13:17:00-07:00 List-Id: On 10/07/2014 12:58 PM, Stribor40 wrote: > > package spec file > package body which contains one function and one procedure and one global variable A pkg body with variables global to subprograms in the pkg is considered a pkg with state, and the variables represent that state. As such they are often referred to as state variables rather than global. > I would like to access this global variable(with its data) from client file. You can't access anything from a file. Do you mean from code that uses the pkg as a client? Things in pkg bodies cannot be accessed by anything outside the pkg body. > Is there anything wrong with doing g it this way and if there is better way to do this? I'm not clear what "this way" refers to. You could move the variable to the pkg spec and it could be accessed by clients there, but that would be A Very Bad Idea. Variables in pkg specs are the root of all evil (or at least the cause of horrible, impossible-to-understand code). -- Jeff Carter "C++ is like jamming a helicopter inside a Miata and expecting some sort of improvement." Drew Olbrich 51