comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: package body
Date: Tue, 07 Oct 2014 13:17:00 -0700
Date: 2014-10-07T13:17:00-07:00	[thread overview]
Message-ID: <m11hnr$kgt$1@dont-email.me> (raw)
In-Reply-To: <7c811e73-61e2-4c89-abb3-749d31461758@googlegroups.com>

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

      parent reply	other threads:[~2014-10-07 20:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-07 19:58 package body Stribor40
2014-10-07 20:05 ` sbelmont700
2014-10-07 20:05 ` Simon Wright
2014-10-07 20:17 ` Jeffrey Carter [this message]
replies disabled

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