comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Global Varibles!!
Date: 1997/02/23
Date: 1997-02-23T00:00:00+00:00	[thread overview]
Message-ID: <dewar.856748645@merv> (raw)
In-Reply-To: 330DD315.6562@watson.ibm.com


Norman said

<< package Serial_Numbers is
   procedure Get_Next (Number: out Natural);
end Serial_Numbers;

package body Serial_Numbers is
   Next: Natural := 0:
   procedure Get_Next (Number: out Natural) is
   begin
      Number := Next;
      if Number = Natural'Last then
         Number := 0;
      else
         Number := Number + 1;
      end if;
   end Get_Next;
end Serial_Numbers;
>>

Of course in general this kind of hiding is quite appropriate. Note however
a danger, here we have an unexposed global variable that is not protected
against task switches. If the global is in the spec, you are at least
clearly publishing a warning that you have an unprotected global.





  reply	other threads:[~1997-02-23  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-19  0:00 Global Varibles!! Richard Pearce
1997-02-20  0:00 ` Matthew Heaney
1997-02-21  0:00   ` Norman H. Cohen
1997-02-23  0:00     ` Robert Dewar [this message]
1997-02-25  0:00       ` Norman H. Cohen
1997-02-25  0:00         ` Robert Dewar
replies disabled

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