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.36.11.6 with SMTP id 6mr4486006itd.11.1517433109685; Wed, 31 Jan 2018 13:11:49 -0800 (PST) X-Received: by 10.157.3.6 with SMTP id 6mr394154otv.3.1517433109548; Wed, 31 Jan 2018 13:11:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!w142no186946ita.0!news-out.google.com!s63ni2843itb.0!nntp.google.com!w142no186945ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 31 Jan 2018 13:11:49 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a01:e35:2ecd:88c0:9ed:3f69:b34b:5209; posting-account=O1Kt4QoAAABKYAjrg-cGai_vZLnN2LEw NNTP-Posting-Host: 2a01:e35:2ecd:88c0:9ed:3f69:b34b:5209 References: <575826a1-c983-49aa-95e2-54048f6b7b5b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: [ANN] List_Image v0.2.0 From: Lionel Draghi Injection-Date: Wed, 31 Jan 2018 21:11:49 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Body-CRC: 3446681370 X-Received-Bytes: 4941 Xref: reader02.eternal-september.org comp.lang.ada:50231 Date: 2018-01-31T13:11:49-08:00 List-Id: Le 31/01/2018 =C3=A0 08:27, emmanuel... a =C3=A9crit : >> List_Image is a small helper to print the content of Ada predefined cont= ainers, available here : https://github.com/LionelDraghi/List_Image >=20 >=20 > Nice ! >=20 > And well documented :-) Thanks! :-) ... > Some comments on the code: >=20 > * EOL should be defined different when on Windows. I used to test whet= her the GNAT.OS_Lib.Directory_Separator is '\', perhaps there's a better wa= y nowadays. For sure, a "Is_Windows" constant would be useful somewhere. >=20 > EOL : constant String :=3D (if Is_Windows then ASCII.CR & ASCII.LF = else ASCII.LF); I defaulted EOL to Windows CRLF, because it's seems to work well on my Linu= x box also. But note that it can be overridden when instantiating Cursors. I don't now a standard way to get the good line terminator. > * Cursors_SIgnature is what I was calling a Forward_Cursor in the trai= ts containers. So there's some code sharing to be done here :-) However, th= e profile of Has_Element and Next, in my case, was also receiving the conta= iner as a parameter, so that they could be compatible with the formal conta= iners distributed with GNAT, and used in SPARK. It is easy to ignore that e= xtra parameter for the standard Ada containers, but not possible to invent = it if not given. I am always open to Identifiers changes to have a more coherent and compreh= ensive naming scheme. For Next and Has_Element, changing the profile would prevent the easy insta= ntiation with Ada containers.=20 If we want the same simplicity with another container collection, I suppose= there's no way out, we need to provide more versions of this Cursor generi= c.=20 > For some reason, I was also passing No_Element and "=3D", but without loo= king at the code in more details, my first thought now is that these should= not be there, so your approach is lighter and likely better. My hesitation was on the Has_Element parameter.=20 The code was simpler when using the Length function instead.=20 I remembered that for some reason you decided to provide your own Ada.Conta= iners.Count_Type in your Container, so I choose to stick to First/Next/Has_= Element instead of First/Next/Length.=20 The body code is more complex, but the component has no dependency (except = Unbounded_String in the body), and that's better for reusability. > * It would be more efficient to use GNATCOLL.Strings instead of Unboun= ded_Strings (a lot more effort was done for performance there), but then it= adds a dependency on a third party library. GNATCOLL.Strings is also using= some kind of traits-based approach (and I have a version locally that uses= traits to decide whether to use atomic counters, non-atomic counters, or n= o counter at all (and thus no copy-on-write). Again in the spirit of sharin= g a signature-based library somewhere Yes, I prefer to avoid non standard dependencies. But we could provide an alternate body.=20 > By the way, using 'Tmp :=3D Tmp & "...";' is inefficient compared t= o 'Append (Tmp, "...")` so I would recommend the latter. OK, I will update the code. > * I see you finally gave up on using the iterable as formal parameter= s. I also had very limited success with that. As a result, the generic algo= rithms have to be written using explicit cursors, but since they are reused= easily, that's not such an issue. Yes, this is my conclusion for this POC! :-) Thanks again Emmanuel for all the useful inputs.=20 =20