From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Iterable container as generic parameter Date: Thu, 25 Jan 2018 22:50:50 -0600 Organization: JSA Research & Innovation Message-ID: References: <61ba3677-0041-4dba-af9b-a5df48f3ce8a@googlegroups.com> <6427a793-91a4-4feb-b067-ed89b4c04421@googlegroups.com> Injection-Date: Fri, 26 Jan 2018 04:50:51 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="10818"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50158 Date: 2018-01-25T22:50:50-06:00 List-Id: "Lionel Draghi" wrote in message news:6427a793-91a4-4feb-b067-ed89b4c04421@googlegroups.com... >> As to the question you didn't ask, you clearly need the container type >> somewhere in your interface, so you can pass container objects. (Or, I >> suppose, you could reference the type used in the instance of the >> Iterator_Interfaces.) Otherwise, you just have methods but no data. And >> there isn't anything interesting that you can do with just methods! > >Thanks Randy for the answer, this is actually my question. >And what you put into parenthesis was what I was trying to do. Formal package parameters that are given by <> are available inside the generic unit given their formal names. But now looking at the definition, I see the container type isn't in that signature. >Here is my point : >If I limit the procedure scope to a specific container, the generic is >simple : ... >But if want something that could be used with both Lists and Maps, I have >to provide much more parameters : ... Emmanuel already described using signature packages for this. But I probably would just use your original spec and add the container type and iterator function, something like: generic type Cursor is (<>); with function Image (C : Cursor) return String; type Container (<>) is private; with package Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, others => <>); with function Iterator (C : Container) return Iterator_Interfaces.Forward_Iterator'Class; function List_Image return String; Not sure if this is enough (I have work to do tonight!), but this is where I'd start. Randy.