comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Iterable container as generic parameter
Date: Mon, 29 Jan 2018 17:00:17 -0600
Date: 2018-01-29T17:00:17-06:00	[thread overview]
Message-ID: <p4o922$6dn$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: d5ea6fa8-13db-4043-b0ab-6deac9e61b7e@googlegroups.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

The Cursor type you are getting from the formal interface package is an 
incomplete type. You can't do much with an incomplete type.

Now, I'd have to read the RM for hours to figure out for sure whether you 
are supposed to get the formal or the actual type in this case. It wouldn't 
surprise me if it is supposed to be the formal type, in which case, your 
original version was better. Otherwise, it could be a GNAT bug, but, again, 
I'm not sure. Practically, I'd assume that it is the formal and use your 
original formulation (which clearly doesn't have a problem).

                                            Randy.


"Lionel Draghi" <lionel.draghi@gmail.com> wrote in message 
news:d5ea6fa8-13db-4043-b0ab-6deac9e61b7e@googlegroups.com...
Le lundi 29 janvier 2018 14:34:07 UTC+1, briot.e...@gmail.com a écrit :
> >       function Id_Set_Image is new List_Image.Image
> >            (Cursor      => Cursor,
> >             Image       => Element,
> >             Iterator_If => Set_Iterator_Interfaces,
> >             Container   => Set,
> >             Iterator    => Iterate,
> >             Style       => List_Image.Bracketed_List_Style);
> > Any idea to simplify is welcome.
>
> Seems to me that you need not pass Cursor explicitly here, since you are 
> already
> gettng it from Set_Iterator_Interfaces.

Good point indeed.

This compile fine :

with Ada.Iterator_Interfaces;

package List_Image is

   generic
      with package Iterator_If is new Ada.Iterator_Interfaces (<>);
      use Iterator_If;

      with function Image (C : Cursor) return String is <>;

   function Image return String;

end List_Image;

But this :

package body List_Image is

   function Image return String is
      C1 : Cursor;
   begin
      return "";
   end Image;

end List_Image;

cause a :
        4:12 invalid use of type before its full declaration
        4:7 premature usage of incomplete type 
"Ada.Iterator_Interfaces.Cursor" from instance at list_image.ads:6

Am I missing something? 



  reply	other threads:[~2018-01-29 23:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-25  0:22 Iterable container as generic parameter Lionel Draghi
2018-01-25  3:36 ` Randy Brukardt
2018-01-25 14:58   ` Lionel Draghi
2018-01-25 18:26     ` briot.emmanuel
2018-01-26  4:50     ` Randy Brukardt
2018-01-26  9:09       ` briot.emmanuel
2018-01-26 22:32         ` Lionel Draghi
2018-01-27  7:03           ` Randy Brukardt
2018-01-27 11:38             ` Lionel Draghi
2018-01-27 14:31               ` Jere
2018-01-28 18:08         ` Lionel Draghi
2018-01-29 13:34           ` briot.emmanuel
2018-01-29 22:26             ` Lionel Draghi
2018-01-29 23:00               ` Randy Brukardt [this message]
2018-01-30 22:35                 ` Lionel Draghi
2018-01-30 23:32                   ` Lionel Draghi
2018-01-31  0:15                   ` Lionel Draghi
2018-01-30 15:13               ` Shark8
2018-01-26 23:07 ` Lionel Draghi
replies disabled

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