From: Stefan.Lucks@uni-weimar.de
Subject: Re: [ANN] List_Image v0.2.0
Date: Mon, 12 Feb 2018 11:57:16 +0100
Date: 2018-02-12T11:57:16+01:00 [thread overview]
Message-ID: <alpine.DEB.2.21.1802121117400.13057@hexenstieg> (raw)
In-Reply-To: <39661f79-1df7-41fb-8bf9-fec1d60da217@googlegroups.com>
[-- Attachment #1: Type: text/plain, Size: 2909 bytes --]
Thank you, the List_Image package is really cool!
I have two points to make:
On Sun, 11 Feb 2018, Lionel Draghi wrote:
> [...] to avoid forcing users to pull to much packages (unless standard)
> with this simple utility, I tried another solution : I moved multi lines
> declarations to platform dependent child packages named Unix_ and
> Windows_Predefined_Styles.
Point 1:
To avoid code duplication, would it not be better to define a single
generic package Predefined_Styples with a parameter EOL, and then creat
the same two packages by instantiation in the spec of List_Image, as
below?
package Windows_Predefined_Styles is new
Predefined_Styles(EOL => Windows_EOL)
package Unix_Predefined_Styles is new
Predefined_Styles(EOL => Unix_EOL)
> The choice will still be done explicitly in the user code.
Indeed!
> And there is a not so satisfying code duplication.
That is the problem with two different packages.
Point 2:
The entire approach gets in trouble if you ever generate and store a
string on windows, but then use Unix to process ist, or vice versa. For
portability, it might be better to fix an arbitrary line terminator -- LF,
or CRLF or whatever, as long as it does never ocur as a part of a line
itself -- and then delegate the problem of properly printing a sequence of
lines to the user.
Oh, instead of delegating the problem to the user, you could even solve it
for the user by defining a child package
package List_Image.Text_IO is
procedure Put_Lines(Lines: String; EOL: String);
end List_Image.Text_IO;
The implementation would "with Ada.Text_IO", and then iterate through the
individual lines in Lines, calling Ada.Text_IO.Put_Line for each line. If
EOL="", Put_Lines will assume a single-line represenation and just call
Ada.Text_IO.Put_Line(Lines);
Unlike your current approach, this would allow implementations to be
completely independent from the operation system's line termination
convention.
Of course, the user should always use List_Images.Text_IO.Put_Lines, to
print the output from List_Images.Image. Calling Ada.Text_IO directly
would be a compatibility issue. Consequently, you could (re-)define
type Image_String is new String;
generic
with package Cursors is new Cursors_Signature (<>);
with function Image (C : Cursors.Cursor) return String is <>;
with package Style is new Image_Style (<>);
function Image (Cont : in Cursors.Container) return Image_String;
and
procedure Put_Lines(Lines: Image_String; EOL: String);
Would that make sense to you?
Stefan
-------- I love the taste of Cryptanalysis in the morning! --------
www.uni-weimar.de/de/medien/professuren/mediensicherheit/people/stefan-lucks
----Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany----
next prev parent reply other threads:[~2018-02-12 10:57 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
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 [this message]
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