comp.lang.ada
 help / color / mirror / Atom feed
* STATIC types in ADA?
@ 2002-03-01 14:27 jhuber
  2002-03-01 15:06 ` Jim Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: jhuber @ 2002-03-01 14:27 UTC (permalink / raw)


Do STATIC data types (like C++ has) exist in ADA?

By this I mean, is there a way I can define a variable so that
when I call a procedure and set a value (say 5.0) and then
exit the procedure and come back into it at a later time, the
variable would still have the same value (i.e., 5.0)?

I think private is the closest thing I've found that will do it.



^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: STATIC types in ADA?
@ 2002-03-01 20:42 Gautier Write-only-address
  0 siblings, 0 replies; 5+ messages in thread
From: Gautier Write-only-address @ 2002-03-01 20:42 UTC (permalink / raw)


>Do STATIC data types (like C++ has) exist in ADA?
...
>I think private is the closest thing I've found that will do it.

It's much simpler. Ada is a block-structured language.
A variable declared outside of procedure or package P is
"static" relatively to P. Inside of P, it is a local variable
just to be used by P. Where a variable is visible, it is alife
and keep its value.

Ex:

package body P is
  i: Integer;

  procedure Q is
    j: integer;
    function R(...) return ... is
      k: integer;
    begin
      -- here i,j,k are visible
      ...
    end R;
  begin
    j:= ...
    i:= i+j;
  end Q;

begin
  i:= 0;
  Q;
  -- i has changed
  Q;
  -- again...
end P;

________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, address on the Web site!



_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




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

end of thread, other threads:[~2002-03-01 20:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-01 14:27 STATIC types in ADA? jhuber
2002-03-01 15:06 ` Jim Rogers
2002-03-01 15:33 ` Matthew Heaney
2002-03-01 17:51 ` Jeffrey Carter
  -- strict thread matches above, loose matches on Subject: below --
2002-03-01 20:42 Gautier Write-only-address

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