comp.lang.ada
 help / color / mirror / Atom feed
* My bug or else regarding Visibility Rules
@ 2013-03-28 19:54 Anh Vo
  2013-03-28 20:58 ` Adam Beneschan
  0 siblings, 1 reply; 15+ messages in thread
From: Anh Vo @ 2013-03-28 19:54 UTC (permalink / raw)


For the codes below GNAT complains that In_Index, Buffer, and Out_Index are undefined. However, if I comment out private key word, GNAT is happy. Did I violate Ada syntax rules? Thanks.


generic
   type Element is private;
   Length : Positive := 1;

package Circular_Queue is

   -- Indicates incorrect usage
   Queue_Error : Exception;

   -- Places an item in the queue.
   procedure Put (Item : Element)
     with pre => not Queue_Full,
          Post => (In_Index = In_Index'Old mod Length + 1) and
                  (Buffer(In_Index'Old) = Item) and 
                  (for all I in 1 .. Queue_Length'Old =>
                                Buffer(I) = Buffer'Old (I)) and 
                  (not Queue_Empty);
  
   -- Takes an item from the queue.
   function Get return Element
      with pre => not Queue_Empty,
           Post => (Out_Index = Out_Index'Old mod Length + 1) and
                   (Buffer(Out_Index'Old) = Get'Result) and 
                   (for all I in 1 .. Queue_Length =>
                                 Buffer(I) = Buffer'Old (I)) and 
                   (not Queue_Full);

   -- Returns the depth of the queue
   function Queue_Length return Natural;

   -- Indicates if the queue is full or not
   function Queue_Full return Boolean;

   -- Indicates if the queue is empty or not
   function Queue_Empty return Boolean;

private
   subtype Index is Positive range 1 .. Length;
   type Element_Array is array (Index) of Element;

   Buffer : Element_Array;
   In_Index : Index := 1;
   Out_Index : Index := 1;
   Count: Natural range 0 .. Length := 0;
end Circular_Queue;



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

end of thread, other threads:[~2013-04-04 19:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 19:54 My bug or else regarding Visibility Rules Anh Vo
2013-03-28 20:58 ` Adam Beneschan
2013-03-28 22:03   ` Randy Brukardt
2013-03-30  6:05     ` Anh Vo
2013-04-02  0:56       ` Randy Brukardt
2013-04-02  1:52         ` Anh Vo
2013-04-02  8:26           ` Simon Wright
2013-04-02 18:17             ` Anh Vo
2013-04-02 20:16               ` Simon Wright
2013-04-03 23:21                 ` Anh Vo
2013-04-04  8:19                   ` Simon Wright
2013-04-04 19:21                     ` Anh Vo
2013-04-04 19:47                       ` Simon Wright
2013-04-02 22:04           ` Randy Brukardt
2013-03-28 22:06   ` Anh Vo

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