comp.lang.ada
 help / color / mirror / Atom feed
From: Lionel Draghi <lionel.draghi@gmail.com>
Subject: Re: [ANN] List_Image v0.2.0
Date: Thu, 1 Feb 2018 07:48:28 -0800 (PST)
Date: 2018-02-01T07:48:28-08:00	[thread overview]
Message-ID: <caa38e97-31e2-4f48-86ce-0eb0e0e9daca@googlegroups.com> (raw)
In-Reply-To: <p4uo7u$1gb$2@dont-email.me>

Le jeudi 1 février 2018 10:56:16 UTC+1, J-P. Rosen a écrit :
> Le 31/01/2018 à 22:11, Lionel Draghi a écrit :
> > 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.
> There is none, for the simple reason that some operating systems have no
> physical line terminator. That's why we have a New_Line procedure in
> Ada, rather than some special character.
> 
> What I do when I need to return strings that span several lines is to
> mark the places with LF; when I need to /print/ these strings, I scan
> them and call New_Line at the place of the LF.

Good idea to have portable code.
 
In my case, as the function is returning the image string, but isn't in charge of printing it, it would “pass the buck” to the user.
I could add an helper Put_Image function, but it's not a totally satisfying solution anyway.

My (maybe naïve) view is that we are getting in complex discussions and weird code patterns to solve a pretty simple problem.
A Text_IO.Line_Terminator function, returning LF or CRLF or a null String for those OSes you just mentioned would be a drastic improvement over current situation.

Because of exceptional situations, we are depriving most Ada users of a simple solution to a common problem (probably discussed hundred time in cla, approximatively, I didn’t check ). 
It would be a OK to specify that this function has a platform dependent semantic, that will be specified by implementors (*). Isn’t it already the case, and for much more complex OS dependent functions?

If we can specify a standard Ada.Directories, I can’t imagine Line_Terminator being a problem!   

In the meantime, I understand from that discussion that I can hardly find a clean internal solution to this problem.
The only clean solution I see, is precisely to “pass the bucket” on the user side, by removing the default declaration of EOL, and asking to the user to provide the convenient value. 
Or to have a separate function, with different possible implementations (one being the GNAT dependent proposed by Emmanuel).

Lionel

(*) : we maybe don't even need to specify that the function shall return LF on unix family OSes and CRLF on Windows


  reply	other threads:[~2018-02-01 15:48 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 [this message]
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