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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8002154d2966e1a1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-04 05:47:15 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail From: martin.dowie@btopenworld.com (Martin Dowie) Newsgroups: comp.lang.ada Subject: Re: Local vs global variables in ADA Date: 4 Nov 2002 05:47:15 -0800 Organization: http://groups.google.com/ Message-ID: References: <5Ldx9.3695$151.38236@weber.videotron.net> NNTP-Posting-Host: 20.138.254.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1036417635 16869 127.0.0.1 (4 Nov 2002 13:47:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 4 Nov 2002 13:47:15 GMT Xref: archiver1.google.com comp.lang.ada:30340 Date: 2002-11-04T13:47:15+00:00 List-Id: "Roger" wrote in message news:<5Ldx9.3695$151.38236@weber.videotron.net>... > Yes I'm an Ada newbie and have a questions about local and global variables. > When exactly is a variable said to be global? I don't consider Ada to have global variables when used normally (at least not in the COBOL sense I was brought up with), as even a data item declared in a package specification, it is still local to that package - as in, you still have to reference the package name somewhere before using the data item. The exception to this is "pragma Export" and "pragma Import". With these you can do hideously dangerous things and completely remove the need for context clauses! :-) e.g. package body Foo is ... My_Local : Integer; pragma Export (Ada, My_Local, "My_Local"); ... end Foo; ... -- WITHOUT "with Foo;" -- package body Bar is ... -- No idea where "My_Local" is actual declared! -- My_Other_Local : Integer; pragma Import (Ada, My_Other_Local, "My_Local"); ... end Bar;