comp.lang.ada
 help / color / mirror / Atom feed
From: Lionel Draghi <lionel.draghi@gmail.com>
Subject: Re: [ANN] List_Image v0.2.0
Date: Wed, 31 Jan 2018 13:11:49 -0800 (PST)
Date: 2018-01-31T13:11:49-08:00	[thread overview]
Message-ID: <ad7ef232-0bd5-443a-b2f8-815c227eee49@googlegroups.com> (raw)
In-Reply-To: <da6805ff-8429-4ca0-bbb5-f5462040989d@googlegroups.com>

Le 31/01/2018 à 08:27, emmanuel... a écrit :
>> List_Image is a small helper to print the content of Ada predefined containers, available here : https://github.com/LionelDraghi/List_Image
> 
> 
> Nice !
> 
> And well documented :-)

Thanks! :-)

...
> Some comments on the code:
> 
>    * EOL should be defined different when on Windows. I used to test whether the GNAT.OS_Lib.Directory_Separator is '\', perhaps there's a better way nowadays. For sure, a "Is_Windows" constant would be useful somewhere.
> 
>       EOL : constant String := (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 Linux 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 traits containers. So there's some code sharing to be done here :-) However, the profile of Has_Element and Next, in my case, was also receiving the container as a parameter, so that they could be compatible with the formal containers distributed with GNAT, and used in SPARK. It is easy to ignore that extra 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 comprehensive naming scheme.

For Next and Has_Element, changing the profile would prevent the easy instantiation with Ada containers. 
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 generic. 

> For some reason, I was also passing No_Element and "=", but without looking 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. 
The code was simpler when using the Length function instead. 
I remembered that for some reason you decided to provide your own Ada.Containers.Count_Type in your Container, so I choose to stick to First/Next/Has_Element instead of First/Next/Length. 
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 Unbounded_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 no counter at all (and thus no copy-on-write). Again in the spirit of sharing a signature-based library somewhere

Yes, I prefer to avoid non standard dependencies.
But we could provide an alternate body. 

>      By the way, using  'Tmp := Tmp & "...";' is inefficient compared to '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 parameters. I also had very limited success with that. As a result, the generic algorithms 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. 


 


  reply	other threads:[~2018-01-31 21:11 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  0:44 [ANN] List_Image v0.2.0 Lionel Draghi
2018-01-31  7:27 ` briot.emmanuel
2018-01-31 21:11   ` Lionel Draghi [this message]
2018-02-01  8:05     ` briot.emmanuel
2018-02-01  9:48     ` J-P. Rosen
2018-02-01 15:48       ` Lionel Draghi
2018-02-01 17:20         ` bozovic.bojan
2018-02-01 18:31           ` Lionel Draghi
2018-02-01 18:45             ` bozovic.bojan
2018-02-01 20:26               ` Dennis Lee Bieber
2018-02-02  5:25                 ` J-P. Rosen
2018-02-02  0:02             ` Randy Brukardt
2018-02-02  0:31               ` Simon Clubley
2018-02-02 18:34               ` Lionel Draghi
2018-02-02 22:40                 ` Randy Brukardt
2018-02-11 23:27                   ` Lionel Draghi
2018-02-12  6:55                     ` J-P. Rosen
2018-02-12 20:44                       ` Lionel Draghi
2018-02-12 10:57                     ` Stefan.Lucks
2018-02-12 21:41                       ` Lionel Draghi
2018-03-07 10:17                     ` Semantic versioning (Was: [ANN] List_Image v0.2.0) Jacob Sparre Andersen
2018-02-01 20:11         ` [ANN] List_Image v0.2.0 J-P. Rosen
2018-02-01 21:08           ` Simon Wright
2018-02-01  0:27   ` Randy Brukardt
2018-02-01  7:55     ` briot.emmanuel
2018-02-01 23:56       ` Randy Brukardt
2018-02-02 15:48         ` Simon Wright
2018-02-02 22:54           ` Randy Brukardt
2018-02-01  8:08     ` Simon Wright
2018-02-01  8:24       ` Dmitry A. Kazakov
replies disabled

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