comp.lang.ada
 help / color / mirror / Atom feed
* Local vs global variables in ADA
@ 2002-11-03 18:17 Roger
  2002-11-03 19:03 ` Per Sandbergs
                   ` (3 more replies)
  0 siblings, 4 replies; 37+ messages in thread
From: Roger @ 2002-11-03 18:17 UTC (permalink / raw)


Yes I'm an Ada newbie and have a questions about local and global variables.
When exactly is a variable said to be global?

for example I have this code
--main procedure
Procedure Main Is
--If I declare a variable here will it be considered as
--global to the sub procedures?


--sub procedure
Procedure Sub

Begin

End Sub;



Begin
--If I declare a variable here will it be considered as
--global to the sub procedure?
End Main;





any help is appreciated.





^ permalink raw reply	[flat|nested] 37+ messages in thread
* Re: Local vs global variables in ADA
@ 2002-11-05  6:42 Grein, Christoph
  2002-11-05 15:59 ` Martin Dowie
  0 siblings, 1 reply; 37+ messages in thread
From: Grein, Christoph @ 2002-11-05  6:42 UTC (permalink / raw)


Martin Dowie:
> The exception to this is "pragma Export" and "pragma Import". With these
> you can do  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;   <-- could be any type here (if the size
                                     matches; if not, you'll suffer from
                                     nasal demons...)
>    pragma Import (Ada, My_Other_Local, "My_Local");
>    ...
> end Bar;

and they need not even be of the same type. You can completely undermine the Ada 
type concept with this.

As Martin said: it's "hideous"



^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2002-11-10  1:36 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-03 18:17 Local vs global variables in ADA Roger
2002-11-03 19:03 ` Per Sandbergs
2002-11-03 19:31 ` Eric Jacoboni
2002-11-04  1:47 ` Jeffrey Carter
2002-11-04 13:27   ` Wes Groleau
2002-11-04 20:48     ` Jeffrey Carter
2002-11-05  8:43       ` Fraser Wilson
2002-11-05 13:53         ` Charles H. Sampson
2002-11-06  4:59           ` R. Tim Coslet
2002-11-05 17:28         ` Stephen Leake
2002-11-05 17:38           ` Jean-Pierre Rosen
2002-11-05 19:57             ` Jeffrey Carter
2002-11-06  9:11               ` Jean-Pierre Rosen
2002-11-05 20:26             ` Vinzent Hoefler
2002-11-05 23:14             ` Wes Groleau
2002-11-06  9:16               ` Jean-Pierre Rosen
2002-11-06 13:49                 ` Wes Groleau
2002-11-05 22:37           ` Robert A Duff
2002-11-05 23:46             ` Larry Hazel
2002-11-06  2:19               ` Dennis Lee Bieber
2002-11-06 13:45                 ` Dan Nagle
2002-11-07  0:30                   ` Dennis Lee Bieber
2002-11-06  2:15             ` Dennis Lee Bieber
2002-11-06  7:04               ` Martin Dowie
2002-11-06 14:40               ` john mann
2002-11-07  0:25                 ` Dennis Lee Bieber
2002-11-07 14:58                   ` Robert A Duff
2002-11-07 15:38                     ` Jean-Pierre Rosen
2002-11-08  1:43                   ` Jeffrey Carter
2002-11-06  7:18             ` Dale Stanbrough
2002-11-06 15:40             ` Rod Chapman
2002-11-06 17:34             ` Stephen Leake
2002-11-10  1:36               ` loop statements, was " David Thompson
2002-11-05 19:54         ` Jeffrey Carter
2002-11-04 13:47 ` Martin Dowie
  -- strict thread matches above, loose matches on Subject: below --
2002-11-05  6:42 Grein, Christoph
2002-11-05 15:59 ` Martin Dowie

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