Print

Print


Hi -

[asked Stephane]
>
> Hello everyone,
>
> I have a quick questions that I couldn't directly find the answer to
> quickly.
>
> Let's say I have 5 different packages performign distinct tasks.  How
> would I go about declaring an array that I could make global to all these
> packages say either from another package that would use these 5 existing one,
> and/or from a main program.  if I have an array of 100 elements, and I want to
> make that array available to these packages, does the fact that I declare
> this variable in the calling package render this array available to any package
> being called by the calling package or program?

If I understand your question, you simply want to declare a variable
(in this case, an array) that is globally visible to your other packages
and to main.

(Instinctively I'd usually ask "why would you want to do this?" But
let's leave aside any design questions about the possible debugging
nightmares in having so many different units reading and writing this
global data, and just treat it as a language issue.)

The standard Ada approach to this is simply to create a package that
contains your global data. Often this is just a package spec with no body;
that seems to be the case here. Let's call this package (what else?)
Globals. Then your main, and your other packages, just 'with Globals;'.
>
> If not, is there a way to do this?

This is the way, if I understand your question correctly.
>
> Thank you all for your help.
>
> Stephane Richard
> Software Developer

Yours truly,

Michael Feldman
------------------------------------------------------------------------
Michael B. Feldman -  chair, ACM SIGAda Education Working Group
Professor, Department of Computer Science
The George Washington University -  Washington, DC 20052 USA
[log in to unmask] - 202-994-5919 (voice) - 202-994-4875 (fax)
http://www.seas.gwu.edu/~mfeldman
------------------------------------------------------------------------
"Teach me to be an engineer. I don't care if it takes all day."
from a Dilbert comic strip
------------------------------------------------------------------------
Visit http://www.acm.org/sigada/education or http://www.adapower.com
------------------------------------------------------------------------