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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.222.25 with SMTP id v25mr21087623iog.103.1517355173522; Tue, 30 Jan 2018 15:32:53 -0800 (PST) X-Received: by 10.157.3.6 with SMTP id 6mr239781otv.3.1517355173321; Tue, 30 Jan 2018 15:32:53 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!g80no1441111itg.0!news-out.google.com!s63ni2144itb.0!nntp.google.com!w142no1448760ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 30 Jan 2018 15:32:53 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a01:e35:2ecd:88c0:2ca7:86cb:394c:f39c; posting-account=O1Kt4QoAAABKYAjrg-cGai_vZLnN2LEw NNTP-Posting-Host: 2a01:e35:2ecd:88c0:2ca7:86cb:394c:f39c References: <61ba3677-0041-4dba-af9b-a5df48f3ce8a@googlegroups.com> <6427a793-91a4-4feb-b067-ed89b4c04421@googlegroups.com> <3af9cfc4-d434-4d60-a4ed-17a16f75717f@googlegroups.com> <3da7bd47-c325-4b25-bb6e-6f53773835ef@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <875dd197-fc4e-4f0d-b5b7-7dee9fb0740b@googlegroups.com> Subject: Re: Iterable container as generic parameter From: Lionel Draghi Injection-Date: Tue, 30 Jan 2018 23:32:53 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 3222 X-Received-Body-CRC: 2985264760 Xref: reader02.eternal-september.org comp.lang.ada:50217 Date: 2018-01-30T15:32:53-08:00 List-Id: As an overview : -- ------------------------------------------------------------------------- -- Cursors -- ------------------------------------------------------------------------- generic type Container (<>) is limited private; type Cursor is private; with function First (Self : Container) return Cursor is <>; with function Has_Element (Pos : Cursor) return Boolean is <>; with function Next (Pos : Cursor) return Cursor is <>; package Cursors_Signature is end; -- ------------------------------------------------------------------------- -- The Image function -- ------------------------------------------------------------------------- generic with package Cursors is new Cursors_Signature (<>); with function Image (C : Cursors.Cursor) return String is <>; with package Style is new List_Style (<>); function Image (Cont : in Cursors.Container) return String; Image's formals reflect the three parameters of the function, no garbage, that's not to bad. And instantiation is pretty easy : use Integer_Lists; package Integer_Lists_Cursors is new List_Image.Cursors_Signature (Container => List, Cursor => Cursor); function Image (C : Cursor) return String is (Integer'Image (Element (C))); function Integer_List_Image is new List_Image.Image (Cursors => Integer_Lists_Cursors, Style => List_Image.Bracketed_List_Style);