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!news.unit0.net!news.uni-stuttgart.de!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!medsec1.medien.uni-weimar.de!slucks From: Stefan.Lucks@uni-weimar.de Newsgroups: comp.lang.ada Subject: Re: [ANN] List_Image v0.2.0 Date: Mon, 12 Feb 2018 11:57:16 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <575826a1-c983-49aa-95e2-54048f6b7b5b@googlegroups.com> <3b72aae1-7ff4-48a9-a154-f17cd6784334@googlegroups.com> <7f5fec97-6ae6-4833-87df-77aac5a8e4ff@googlegroups.com> <191ef0a8-865e-49be-baa6-6c5c2d0b55fc@googlegroups.com> <39661f79-1df7-41fb-8bf9-fec1d60da217@googlegroups.com> NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="915268786-1471366500-1518430777=:13057" X-Trace: pinkpiglet.scc.uni-weimar.de 1518433037 27106 141.54.178.228 (12 Feb 2018 10:57:17 GMT) X-Complaints-To: news@pinkpiglet.scc.uni-weimar.de NNTP-Posting-Date: Mon, 12 Feb 2018 10:57:17 +0000 (UTC) X-X-Sender: slucks@hexenstieg In-Reply-To: <39661f79-1df7-41fb-8bf9-fec1d60da217@googlegroups.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) Content-ID: Xref: reader02.eternal-september.org comp.lang.ada:50384 Date: 2018-02-12T11:57:16+01:00 List-Id: This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --915268786-1471366500-1518430777=:13057 Content-Type: text/plain; CHARSET=ISO-8859-15; FORMAT=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: 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)= =20 > with this simple utility, I tried another solution : I moved multi lines= =20 > declarations to platform dependent child packages named Unix_ and=20 > Windows_Predefined_Styles. Point 1: To avoid code duplication, would it not be better to define a single=20 generic package Predefined_Styples with a parameter EOL, and then creat=20 the same two packages by instantiation in the spec of List_Image, as=20 below? package Windows_Predefined_Styles is new Predefined_Styles(EOL =3D> Windows_EOL) package Unix_Predefined_Styles is new Predefined_Styles(EOL =3D> 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=20 string on windows, but then use Unix to process ist, or vice versa. For=20 portability, it might be better to fix an arbitrary line terminator -- LF,= =20 or CRLF or whatever, as long as it does never ocur as a part of a line=20 itself -- and then delegate the problem of properly printing a sequence of= =20 lines to the user. Oh, instead of delegating the problem to the user, you could even solve it= =20 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= =20 individual lines in Lines, calling Ada.Text_IO.Put_Line for each line. If= =20 EOL=3D"", Put_Lines will assume a single-line represenation and just call= =20 Ada.Text_IO.Put_Line(Lines); Unlike your current approach, this would allow implementations to be=20 completely independent from the operation system's line termination=20 convention. Of course, the user should always use List_Images.Text_IO.Put_Lines, to=20 print the output from List_Images.Image. Calling Ada.Text_IO directly=20 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-luck= s ----Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universit=E4t Weimar, Germany-= --- --915268786-1471366500-1518430777=:13057--