comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent <daemon2@internet.lu>
Subject: Problem implementing Iterators
Date: Tue, 27 Jan 2015 05:54:35 -0800 (PST)
Date: 2015-01-27T05:54:35-08:00	[thread overview]
Message-ID: <9ceb847e-d064-47e7-aa11-7707b63d4308@googlegroups.com> (raw)

Hi

I tried to add an iterator to my double linked list using the example from John Barnes Ada 2005 book, chapter about iterators.

For the moment the only procedure using the iterator is the Display one.

In my test app I get this error when I compile it:

   package GL_String is
     new Double_Linked_Lists_Generic (Element_Type    => Name_Type,
                                      Display_Element => Display_String );
L1 : GL_String.List ;

   GL_String.Display (L1); <-- error

expected an access type with designated private type "List" defined at double_linked_lists_generic.ads:7, instance at line 23 
found private type "List" defined at double_linked_lists_generic.ads:7, instance at line 23 

List and Iterator are defined as: 

 type List is limited private;
 type Iterator (L : access List) is limited private;

(...)
private

   type List_Node;
   type List_Ptr is access List_Node;
   type List_Node is record
      Element : Element_Type;
      Next    : List_Ptr;
      Previous:List_Ptr;
   end record;

   type List is record <-- example in the book is a list without head/tail
      Head : List_Ptr;
      Tail : List_Ptr;
   end record;

   type Iterator (L : access List) is limited
      record
         This :  List_Ptr;
      end record;

So how do I get this to work?

Thanks


             reply	other threads:[~2015-01-27 13:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-27 13:54 Laurent [this message]
2015-01-27 16:24 ` Problem implementing Iterators AdaMagica
2015-01-27 17:26   ` Laurent
2015-01-27 17:55     ` Björn Lundin
2015-01-27 18:06       ` Laurent
2015-01-27 18:43         ` Björn Lundin
2015-01-27 20:58           ` Jeffrey Carter
2015-01-28 12:20             ` Björn Lundin
2015-01-28 16:42     ` AdaMagica
2015-01-28 20:14       ` Laurent
replies disabled

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