comp.lang.ada
 help / color / mirror / Atom feed
From: Anh Vo <anhvofrcaus@gmail.com>
Subject: My bug or else regarding Visibility Rules
Date: Thu, 28 Mar 2013 12:54:26 -0700 (PDT)
Date: 2013-03-28T12:54:26-07:00	[thread overview]
Message-ID: <0c77e832-e12b-446d-af24-78d77c358f1e@googlegroups.com> (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;



             reply	other threads:[~2013-03-28 19:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 19:54 Anh Vo [this message]
2013-03-28 20:58 ` My bug or else regarding Visibility Rules 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
replies disabled

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