Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"You must have an IQ of at least half a million." -- Popeye


devel / comp.lang.ada / Re: Better way to fill Storage_IO?

SubjectAuthor
* Better way to fill Storage_IO?Michael Hardeman
+* Re: Better way to fill Storage_IO?Simon Wright
|+* Re: Better way to fill Storage_IO?Michael Hardeman
||`* Re: Better way to fill Storage_IO?Simon Wright
|| +- Re: Better way to fill Storage_IO?Dmitry A. Kazakov
|| `* Re: Better way to fill Storage_IO?J-P. Rosen
||  +* Re: Better way to fill Storage_IO?Björn Lundin
||  |`* Re: Better way to fill Storage_IO?J-P. Rosen
||  | +- Re: Better way to fill Storage_IO?Dmitry A. Kazakov
||  | `* Re: Better way to fill Storage_IO?Björn Lundin
||  |  `* Re: Better way to fill Storage_IO?Niklas Holsti
||  |   `* Re: Better way to fill Storage_IO?J-P. Rosen
||  |    `- Re: Better way to fill Storage_IO?Randy Brukardt
||  `- Re: Better way to fill Storage_IO?Simon Wright
|`* Re: Better way to fill Storage_IO?Dmitry A. Kazakov
| +* Re: Better way to fill Storage_IO?Michael Hardeman
| |`- Re: Better way to fill Storage_IO?Per Sandberg
| `* Re: Better way to fill Storage_IO?J-P. Rosen
|  `- Re: Better way to fill Storage_IO?Jeffrey R. Carter
`- Re: Better way to fill Storage_IO?Shark8

1
Better way to fill Storage_IO?

<c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5191&group=comp.lang.ada#5191

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:4756:: with SMTP id k22mr887466qtp.193.1621277044767; Mon, 17 May 2021 11:44:04 -0700 (PDT)
X-Received: by 2002:a25:cb56:: with SMTP id b83mr1755613ybg.73.1621277044463; Mon, 17 May 2021 11:44:04 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 17 May 2021 11:44:04 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=99.10.228.144; posting-account=AgomvAoAAAAj6rtZlNDUf1S1XVXbXDpg
NNTP-Posting-Host: 99.10.228.144
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
Subject: Better way to fill Storage_IO?
From: mhardema...@gmail.com (Michael Hardeman)
Injection-Date: Mon, 17 May 2021 18:44:04 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 28
 by: Michael Hardeman - Mon, 17 May 2021 18:44 UTC

So I've been messing around with the new Ada 2020 package Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it correctly it allows you to treat your program's memory like a stream without having to open file descriptors (which should make it faster?). That seems like a powerful abstraction to me and a great addition to the language.

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Streams; use Ada.Streams;
with Ada.Streams.Storage.Unbounded; use Ada.Streams.Storage.Unbounded;

procedure Test is
Test : String := "040b2cec765b4bbbdb29d83b6dcaf776";
Test_Stream : aliased Stream_Type;
begin
String'Write(Test_Stream'Access, Test);
for I in 1 .. Element_Count (Test_Stream) loop
declare
C : Character;
begin
Character'Read (Test_Stream'Access, C);
Put (C);
end;
end loop;
end Test;

I was wondering if we could find a better way to fill the stream other than writing the variables into it? Can anyone figure out a good way to just stream a variable's bytes directly?

Re: Better way to fill Storage_IO?

<lymtstxjdv.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5192&group=comp.lang.ada#5192

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Mon, 17 May 2021 20:14:36 +0100
Organization: Aioe.org NNTP Server
Lines: 36
Message-ID: <lymtstxjdv.fsf@pushface.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:KcWswe0cAKnhjwOwbVKAk0GBTgM=
 by: Simon Wright - Mon, 17 May 2021 19:14 UTC

Michael Hardeman <mhardeman25@gmail.com> writes:

> So I've been messing around with the new Ada 2020 package
> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
> correctly it allows you to treat your program's memory like a stream
> without having to open file descriptors (which should make it
> faster?). That seems like a powerful abstraction to me and a great
> addition to the language.

This would be my version:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Streams.Storage.Unbounded;

procedure Test is
Test : constant String := "040b2cec765b4bbbdb29d83b6dcaf776";
Test_Stream : aliased Ada.Streams.Storage.Unbounded.Stream_Type;
begin
String'Output (Test_Stream'Access, Test);
declare
S : constant String := String'Input (Test_Stream'Access);
begin
Put_Line (S);
end;
end Test;

'Output writes the discriminants of the object, if any, then the object;
'Input uses them to reconstruct the object, so in this case that means
the bounds, and hence the length.

> I was wondering if we could find a better way to fill the stream other
> than writing the variables into it? Can anyone figure out a good way
> to just stream a variable's bytes directly?

This *is* the way to just stream the variable's bytes directly. What
sort of syntax were you hoping for?

Re: Better way to fill Storage_IO?

<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5193&group=comp.lang.ada#5193

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:5613:: with SMTP id ca19mr1394362qvb.3.1621279433381;
Mon, 17 May 2021 12:23:53 -0700 (PDT)
X-Received: by 2002:a25:c588:: with SMTP id v130mr1924073ybe.504.1621279433123;
Mon, 17 May 2021 12:23:53 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 17 May 2021 12:23:52 -0700 (PDT)
In-Reply-To: <lymtstxjdv.fsf@pushface.org>
Injection-Info: google-groups.googlegroups.com; posting-host=99.10.228.144; posting-account=AgomvAoAAAAj6rtZlNDUf1S1XVXbXDpg
NNTP-Posting-Host: 99.10.228.144
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com> <lymtstxjdv.fsf@pushface.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
Subject: Re: Better way to fill Storage_IO?
From: mhardema...@gmail.com (Michael Hardeman)
Injection-Date: Mon, 17 May 2021 19:23:53 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2806
 by: Michael Hardeman - Mon, 17 May 2021 19:23 UTC

On Monday, May 17, 2021 at 3:14:43 PM UTC-4, Simon Wright wrote:
>
> 'Output writes the discriminants of the object, if any, then the object;
> 'Input uses them to reconstruct the object, so in this case that means
> the bounds, and hence the length.
> > I was wondering if we could find a better way to fill the stream other
> > than writing the variables into it? Can anyone figure out a good way
> > to just stream a variable's bytes directly?
> This *is* the way to just stream the variable's bytes directly. What
> sort of syntax were you hoping for?

I was kind of hoping there would be an interface like Ada.Text_IO.Text_Streams, where you could just directly stream from the variable's address or access without having to write the variable into the stream first. I'm not sure, but the writing part seems a bit like an extra step.

This would be my version:
>
> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.Streams.Storage.Unbounded;
>
> procedure Test is
> Test : constant String := "040b2cec765b4bbbdb29d83b6dcaf776";
> Test_Stream : aliased Ada.Streams.Storage.Unbounded.Stream_Type;
> begin
> String'Output (Test_Stream'Access, Test);
> declare
> S : constant String := String'Input (Test_Stream'Access);
> begin
> Put_Line (S);
> end;
> end Test;

I was kind of trying to show you could move through the stream like a parser instead of just consuming the whole thing. i.e. like if you wanted to parse the hex into an array of Unsigned_32 or Unsigned_64 for some algorithm.

Re: Better way to fill Storage_IO?

<s7uj5p$10p7$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5194&group=comp.lang.ada#5194

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Mon, 17 May 2021 22:20:11 +0200
Organization: Aioe.org NNTP Server
Lines: 54
Message-ID: <s7uj5p$10p7$1@gioia.aioe.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Mon, 17 May 2021 20:20 UTC

On 2021-05-17 21:14, Simon Wright wrote:
> Michael Hardeman <mhardeman25@gmail.com> writes:
>
>> So I've been messing around with the new Ada 2020 package
>> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
>> correctly it allows you to treat your program's memory like a stream
>> without having to open file descriptors (which should make it
>> faster?). That seems like a powerful abstraction to me and a great
>> addition to the language.

1. It was always possible, since Ada 95, actually. So it is not that
great addition.

2. The package as described is not a replacement for I/O, because it
lacks blocking/synchronization and because it does not work between
processes. E.g. at the end of the stream Read must rather block for an
incoming Write. Both are quite possible to implement though.

A great addition would be properly tagged protected objects and tasks. A
blocking stream cannot support timed entry call syntax like this:

select
S := String'Input (Pipe'Access); -- This is not Ada!
or delay 1.0;
raise Timed_Out;
end select;

And note another problem. Entries do not work with indefinite objects.
You cannot return String from an entry call.

And yet another problem, you cannot use returned objects in many places,
like in an entry call above.

>> I was wondering if we could find a better way to fill the stream other
>> than writing the variables into it? Can anyone figure out a good way
>> to just stream a variable's bytes directly?

Allocators, of course. I am using both allocators and memory-mapped
streams (though of a greater variety, e.g. for blocked exchange,
encryption, interporcess communication).

> This *is* the way to just stream the variable's bytes directly. What
> sort of syntax were you hoping for?

Both allocators and streams require explicit specification of the type.
Clearly, that is a way around multiple dispatch, but it is way too
heavy. Access to stream is no more necessary in 'Input. It was not
necessary when it was introduced in Ada 95. The Rosen's trick allows
circumvent in- parameter modes, when necessary.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Better way to fill Storage_IO?

<11979adf-d841-4b67-8693-567e6fe8bc55n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5195&group=comp.lang.ada#5195

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:e113:: with SMTP id c19mr1831621qkm.329.1621284490997;
Mon, 17 May 2021 13:48:10 -0700 (PDT)
X-Received: by 2002:a25:6d02:: with SMTP id i2mr2508161ybc.309.1621284490828;
Mon, 17 May 2021 13:48:10 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Mon, 17 May 2021 13:48:10 -0700 (PDT)
In-Reply-To: <s7uj5p$10p7$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=99.10.228.144; posting-account=AgomvAoAAAAj6rtZlNDUf1S1XVXbXDpg
NNTP-Posting-Host: 99.10.228.144
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org> <s7uj5p$10p7$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <11979adf-d841-4b67-8693-567e6fe8bc55n@googlegroups.com>
Subject: Re: Better way to fill Storage_IO?
From: mhardema...@gmail.com (Michael Hardeman)
Injection-Date: Mon, 17 May 2021 20:48:10 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael Hardeman - Mon, 17 May 2021 20:48 UTC

On Monday, May 17, 2021 at 4:20:14 PM UTC-4, Dmitry A. Kazakov wrote:
> On 2021-05-17 21:14, Simon Wright wrote:
> > Michael Hardeman <mhard...@gmail.com> writes:
> >
> >> So I've been messing around with the new Ada 2020 package
> >> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
> >> correctly it allows you to treat your program's memory like a stream
> >> without having to open file descriptors (which should make it
> >> faster?). That seems like a powerful abstraction to me and a great
> >> addition to the language.
> 1. It was always possible, since Ada 95, actually. So it is not that
> great addition.
>
> 2. The package as described is not a replacement for I/O, because it
> lacks blocking/synchronization and because it does not work between
> processes. E.g. at the end of the stream Read must rather block for an
> incoming Write. Both are quite possible to implement though.
>
> A great addition would be properly tagged protected objects and tasks. A
> blocking stream cannot support timed entry call syntax like this:
>
> select
> S := String'Input (Pipe'Access); -- This is not Ada!
> or delay 1.0;
> raise Timed_Out;
> end select;
>
> And note another problem. Entries do not work with indefinite objects.
> You cannot return String from an entry call.
>
> And yet another problem, you cannot use returned objects in many places,
> like in an entry call above.
> >> I was wondering if we could find a better way to fill the stream other
> >> than writing the variables into it? Can anyone figure out a good way
> >> to just stream a variable's bytes directly?
> Allocators, of course. I am using both allocators and memory-mapped
> streams (though of a greater variety, e.g. for blocked exchange,
> encryption, interporcess communication).
> > This *is* the way to just stream the variable's bytes directly. What
> > sort of syntax were you hoping for?
> Both allocators and streams require explicit specification of the type.
> Clearly, that is a way around multiple dispatch, but it is way too
> heavy. Access to stream is no more necessary in 'Input. It was not
> necessary when it was introduced in Ada 95. The Rosen's trick allows
> circumvent in- parameter modes, when necessary.
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Hey Dmitry,

> Allocators, of course. I am using both allocators and memory-mapped
> streams (though of a greater variety, e.g. for blocked exchange,
> encryption, interporcess communication).

Could you show me an example of how I could do this with allocators?

Re: Better way to fill Storage_IO?

<s8006p$kra$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5196&group=comp.lang.ada#5196

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Tue, 18 May 2021 11:08:41 +0200
Organization: Adalog
Lines: 27
Message-ID: <s8006p$kra$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org> <s7uj5p$10p7$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 18 May 2021 09:08:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="2ac88b944233c89f1998c01a90cbe718";
logging-data="21354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18yNEZZ+gt8LlTqlq/1e+VI"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Cancel-Lock: sha1:M/saDV0eKWVjmBNumqhmPzoO3Z0=
In-Reply-To: <s7uj5p$10p7$1@gioia.aioe.org>
Content-Language: fr
 by: J-P. Rosen - Tue, 18 May 2021 09:08 UTC

Le 17/05/2021 à 22:20, Dmitry A. Kazakov a écrit :
> On 2021-05-17 21:14, Simon Wright wrote:
>> Michael Hardeman <mhardeman25@gmail.com> writes:
>>
>>> So I've been messing around with the new Ada 2020 package
>>> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
>>> correctly it allows you to treat your program's memory like a stream
>>> without having to open file descriptors (which should make it
>>> faster?). That seems like a powerful abstraction to me and a great
>>> addition to the language.
>
> 1. It was always possible, since Ada 95, actually. So it is not that
> great addition.
For example, you can get Storage_Stream from Adalog's components page:
https://www.adalog.fr/en/components.html#Storage_Stream

[...]
> And note another problem. Entries do not work with indefinite objects.
> You cannot return String from an entry call.
True, but you can return an indefinite holder containing the string.

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Better way to fill Storage_IO?

<s803ql$c94$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5197&group=comp.lang.ada#5197

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spam.jrc...@spam.not.acm.org (Jeffrey R. Carter)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Tue, 18 May 2021 12:10:29 +0200
Organization: Also freenews.netfront.net; news.tornevall.net;
news.eternal-september.org
Lines: 10
Message-ID: <s803ql$c94$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org> <s7uj5p$10p7$1@gioia.aioe.org>
<s8006p$kra$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 18 May 2021 10:10:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9f5c8599f9ac7d2b8f69db1653e7feeb";
logging-data="12580"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Fh25X/f/4KLaqc0fksVd6GWLfEM+mq/M="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.8.1
Cancel-Lock: sha1:HiZ3zXSogmsvSDJ1TjkY3FO10rw=
In-Reply-To: <s8006p$kra$1@dont-email.me>
Content-Language: en-US
 by: Jeffrey R. Carter - Tue, 18 May 2021 10:10 UTC

On 5/18/21 11:08 AM, J-P. Rosen wrote:
>
> True, but you can return an indefinite holder containing the string.

Usually called Unbounded_String.

--
Jeff Carter
"Damn it, Jim, I'm an actor, not a doctor."
124

Re: Better way to fill Storage_IO?

<BLPoI.473076$e0cb.182702@fx19.ams4>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5198&group=comp.lang.ada#5198

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mb-net.net!open-news-network.org!news.mind.de!bolzen.all.de!npeer.as286.net!npeer-ng0.as286.net!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx19.ams4.POSTED!not-for-mail
Subject: Re: Better way to fill Storage_IO?
Newsgroups: comp.lang.ada
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org> <s7uj5p$10p7$1@gioia.aioe.org>
<11979adf-d841-4b67-8693-567e6fe8bc55n@googlegroups.com>
From: per.s.sa...@bahnhof.se (Per Sandberg)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <11979adf-d841-4b67-8693-567e6fe8bc55n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 65
Message-ID: <BLPoI.473076$e0cb.182702@fx19.ams4>
X-Complaints-To: abuse@usenet.se
NNTP-Posting-Date: Tue, 18 May 2021 14:00:01 UTC
Organization: usenet.se
Date: Tue, 18 May 2021 16:00:01 +0200
X-Received-Bytes: 3770
 by: Per Sandberg - Tue, 18 May 2021 14:00 UTC

To emulate a stream on "any" locatoion
https://github.com/persan/a-stream-tools
/P

On 17/05/2021 22:48, Michael Hardeman wrote:
> On Monday, May 17, 2021 at 4:20:14 PM UTC-4, Dmitry A. Kazakov wrote:
>> On 2021-05-17 21:14, Simon Wright wrote:
>>> Michael Hardeman <mhard...@gmail.com> writes:
>>>
>>>> So I've been messing around with the new Ada 2020 package
>>>> Ada.Streams.Storage.Bounded/Unbounded; and if I'm understand it
>>>> correctly it allows you to treat your program's memory like a stream
>>>> without having to open file descriptors (which should make it
>>>> faster?). That seems like a powerful abstraction to me and a great
>>>> addition to the language.
>> 1. It was always possible, since Ada 95, actually. So it is not that
>> great addition.
>>
>> 2. The package as described is not a replacement for I/O, because it
>> lacks blocking/synchronization and because it does not work between
>> processes. E.g. at the end of the stream Read must rather block for an
>> incoming Write. Both are quite possible to implement though.
>>
>> A great addition would be properly tagged protected objects and tasks. A
>> blocking stream cannot support timed entry call syntax like this:
>>
>> select
>> S := String'Input (Pipe'Access); -- This is not Ada!
>> or delay 1.0;
>> raise Timed_Out;
>> end select;
>>
>> And note another problem. Entries do not work with indefinite objects.
>> You cannot return String from an entry call.
>>
>> And yet another problem, you cannot use returned objects in many places,
>> like in an entry call above.
>>>> I was wondering if we could find a better way to fill the stream other
>>>> than writing the variables into it? Can anyone figure out a good way
>>>> to just stream a variable's bytes directly?
>> Allocators, of course. I am using both allocators and memory-mapped
>> streams (though of a greater variety, e.g. for blocked exchange,
>> encryption, interporcess communication).
>>> This *is* the way to just stream the variable's bytes directly. What
>>> sort of syntax were you hoping for?
>> Both allocators and streams require explicit specification of the type.
>> Clearly, that is a way around multiple dispatch, but it is way too
>> heavy. Access to stream is no more necessary in 'Input. It was not
>> necessary when it was introduced in Ada 95. The Rosen's trick allows
>> circumvent in- parameter modes, when necessary.
>>
>> --
>> Regards,
>> Dmitry A. Kazakov
>> http://www.dmitry-kazakov.de
>
> Hey Dmitry,
>
>> Allocators, of course. I am using both allocators and memory-mapped
>> streams (though of a greater variety, e.g. for blocked exchange,
>> encryption, interporcess communication).
>
> Could you show me an example of how I could do this with allocators?
>

Re: Better way to fill Storage_IO?

<247c7317-13ab-436b-ac9c-31f594c40b73n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5199&group=comp.lang.ada#5199

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:148a:: with SMTP id t10mr5433595qtx.214.1621356631702;
Tue, 18 May 2021 09:50:31 -0700 (PDT)
X-Received: by 2002:a25:e753:: with SMTP id e80mr8837966ybh.277.1621356631491;
Tue, 18 May 2021 09:50:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Tue, 18 May 2021 09:50:31 -0700 (PDT)
In-Reply-To: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC
NNTP-Posting-Host: 146.5.2.231
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <247c7317-13ab-436b-ac9c-31f594c40b73n@googlegroups.com>
Subject: Re: Better way to fill Storage_IO?
From: onewinge...@gmail.com (Shark8)
Injection-Date: Tue, 18 May 2021 16:50:31 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Shark8 - Tue, 18 May 2021 16:50 UTC

On Monday, May 17, 2021 at 12:44:05 PM UTC-6, mhard wrote:
Here's an implementation of a string-as-a-stream: https://stackoverflow.com/a/66971547/608963
It was used in a JSON parser, so you certainly can use it for parsing... actually the idea here: to have a single production-method shared by stream and string [and file] is really quite nice maintenance-wise, even if you have to jump through a few hoops (like constructing this stream-string type) in order to obtain it.

Re: Better way to fill Storage_IO?

<lypmxndbf2.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5200&group=comp.lang.ada#5200

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Tue, 18 May 2021 21:39:13 +0100
Organization: Aioe.org NNTP Server
Lines: 56
Message-ID: <lypmxndbf2.fsf@pushface.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:tUIRvcXLHhPe+/5iPjn/fAU7myk=
 by: Simon Wright - Tue, 18 May 2021 20:39 UTC

Michael Hardeman <mhardeman25@gmail.com> writes:

> I was kind of hoping there would be an interface like
> Ada.Text_IO.Text_Streams, where you could just directly stream from
> the variable's address or access without having to write the variable
> into the stream first. I'm not sure, but the writing part seems a bit
> like an extra step.
[...]
> I was kind of trying to show you could move through the stream like a
> parser instead of just consuming the whole thing. i.e. like if you
> wanted to parse the hex into an array of Unsigned_32 or Unsigned_64
> for some algorithm.

I don't understand the scenario.

Source >> Stream >> Destination

If Source and Destination are in the same process, there's no need to
involve streams at all.

If Source and Destination are separated - different processes on the
same computer, different computers (possibly with different endianness),
different times - we have to agree on a protocol as to what's sent over
the stream. For a String Z, perhaps the first 4 bytes are the
little-endian Z'First, the next are Z'Last, then the actual bytes of Z.

That's what streams are for (and that's what String'Output does).

Once you have the stream, you can go through it in any way you need to;
you must know what to expect so as to make sense of it. In your example,
you have to know that the bytes in the stream are hex characters.

==========

As to creating the stream: I suppose there could be something like
'Image, where the attribute could originally only be applied to a type:
you used to have to say

Integer'Image (An_Integer)

whereas now you can say just

An_Integer'Image

so as well as the current ARM 13.13.2(4), for subtype S of type T

procedure S'Write(
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in T)

one could have for an object O

procedure O'Write(
Stream : not null access Ada.Streams.Root_Stream_Type'Class)

but we don't, not even in Ada 202x.

Re: Better way to fill Storage_IO?

<s82aua$144u$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5201&group=comp.lang.ada#5201

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 08:24:10 +0200
Organization: Aioe.org NNTP Server
Lines: 31
Message-ID: <s82aua$144u$1@gioia.aioe.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org>
NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Dmitry A. Kazakov - Wed, 19 May 2021 06:24 UTC

On 2021-05-18 22:39, Simon Wright wrote:
> Michael Hardeman <mhardeman25@gmail.com> writes:
>
>> I was kind of hoping there would be an interface like
>> Ada.Text_IO.Text_Streams, where you could just directly stream from
>> the variable's address or access without having to write the variable
>> into the stream first. I'm not sure, but the writing part seems a bit
>> like an extra step.
> [...]
>> I was kind of trying to show you could move through the stream like a
>> parser instead of just consuming the whole thing. i.e. like if you
>> wanted to parse the hex into an array of Unsigned_32 or Unsigned_64
>> for some algorithm.
>
> I don't understand the scenario.
>
> Source >> Stream >> Destination
>
> If Source and Destination are in the same process, there's no need to
> involve streams at all.

The picture actually is:

Producer -> Output stream = Input Stream -> Consumer

The producer could be a code generator, the consumer could be a parser.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Better way to fill Storage_IO?

<s82e2r$81l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5202&group=comp.lang.ada#5202

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 09:17:47 +0200
Organization: Adalog
Lines: 21
Message-ID: <s82e2r$81l$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 May 2021 07:17:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ff5b2d12dd419f7edcb4d1a7a5d231c6";
logging-data="8245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+S1h4qf8dVtLHTerx5AyY"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:8o6IBPc1I3MJ2gVpve63zgBfG4A=
In-Reply-To: <lypmxndbf2.fsf@pushface.org>
Content-Language: fr
 by: J-P. Rosen - Wed, 19 May 2021 07:17 UTC

Le 18/05/2021 à 22:39, Simon Wright a écrit :
> so as well as the current ARM 13.13.2(4), for subtype S of type T
>
> procedure S'Write(
> Stream : not null access Ada.Streams.Root_Stream_Type'Class;
> Item : in T)
>
> one could have for an object O
>
> procedure O'Write(
> Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>
> but we don't, not even in Ada 202x.
For what benefit? Saving a few keystrokes?

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Better way to fill Storage_IO?

<s82i3g$el$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5203&group=comp.lang.ada#5203

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: b.f.lun...@gmail.com (Björn Lundin)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 10:26:24 +0200
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <s82i3g$el$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 May 2021 08:26:24 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3294e74acc61672f724a4128636404d8";
logging-data="469"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AvR9E1B2kLV/4nvKNrQWS"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
Cancel-Lock: sha1:otsj9aGFXJNv9pVS4QnvkBBoyCU=
In-Reply-To: <s82e2r$81l$1@dont-email.me>
Content-Language: en-US
 by: Björn Lundin - Wed, 19 May 2021 08:26 UTC

Den 2021-05-19 kl. 09:17, skrev J-P. Rosen:
> Le 18/05/2021 à 22:39, Simon Wright a écrit :
>> so as well as the current ARM 13.13.2(4), for subtype S of type T
>>
>>     procedure S'Write(
>>        Stream : not null access Ada.Streams.Root_Stream_Type'Class;
>>        Item : in T)
>>
>> one could have for an object O
>>
>>     procedure O'Write(
>>        Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>>
>> but we don't, not even in Ada 202x.
> For what benefit? Saving a few keystrokes?
>

The Integer'Image(An_Integer) changed to An_Integer'Image

the Verb(Object, Parameter) changed to Object.Verb(Parameter)

It does not have to save keystrokes, but it has to be more readable.
More readable is of course in the eye of the beholder.

package Coded_Values is

type WCS_Next_Location_Type_Type is (
Reject_Position,
Selection_Point,
Transfer_Unit);

end Coded_Values;

with Coded_Values;
with Text_Io;

package Test is

Next_Location : Coded_Values.WCS_Next_Location_Type_Type :=
Coded_Values.Selection_Point;

Given the above I do prefer

Text_IO.Put_Line ("Next is " & Next_Location'Image);

over

Text_IO.Put_Line ("Next is " &
Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));

or when a use clause is in effect
Text_IO.Put_Line ("Next is " &
WCS_Next_Location_Type_Type'Image(Next_Location));

even with a use clause I prefer the 'image on the variable.
In my eyes

Text_IO.Put_Line ("Next is " & Next_Location'Image);

Is the better and more readable choice.

That is likely the case of the analog stream discussion above.

Syntax matter. If Ada is to grow it has to have a pleasant syntax,
that is not perceived as clumsy or overly wordy.

--
Björn

Re: Better way to fill Storage_IO?

<ly1ra2ivgg.fsf@pushface.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5204&group=comp.lang.ada#5204

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail
From: sim...@pushface.org (Simon Wright)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 16:39:43 +0100
Organization: Aioe.org NNTP Server
Lines: 17
Message-ID: <ly1ra2ivgg.fsf@pushface.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
NNTP-Posting-Host: yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin)
X-Notice: Filtered by postfilter v. 0.9.2
Cancel-Lock: sha1:Jq3y8gMF0A5D7NtulSFTEZ45F3c=
 by: Simon Wright - Wed, 19 May 2021 15:39 UTC

"J-P. Rosen" <rosen@adalog.fr> writes:

> Le 18/05/2021 à 22:39, Simon Wright a écrit :
>> so as well as the current ARM 13.13.2(4), for subtype S of type T
>> procedure S'Write(
>> Stream : not null access Ada.Streams.Root_Stream_Type'Class;
>> Item : in T)
>> one could have for an object O
>> procedure O'Write(
>> Stream : not null access Ada.Streams.Root_Stream_Type'Class)
>> but we don't, not even in Ada 202x.
> For what benefit? Saving a few keystrokes?

I was going to remark on the unlikelihood of ARG's accepting this
keystroke-saving change unless there was evidence of massive demand. In
the case of 'Image, there was the popularity of AdaCore's 'Img
extension.

Re: Better way to fill Storage_IO?

<s83oo3$s2s$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5206&group=comp.lang.ada#5206

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 21:25:56 +0200
Organization: Adalog
Lines: 24
Message-ID: <s83oo3$s2s$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
<s82i3g$el$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 May 2021 19:25:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="ff5b2d12dd419f7edcb4d1a7a5d231c6";
logging-data="28764"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lYJSfoN91yCiFqqDb0bPw"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:ONtyOrcECs6tHzdJXocAVpjFcMI=
In-Reply-To: <s82i3g$el$1@dont-email.me>
Content-Language: fr
 by: J-P. Rosen - Wed, 19 May 2021 19:25 UTC

Le 19/05/2021 à 10:26, Björn Lundin a écrit :
> Given the above I do prefer
>
>
> Text_IO.Put_Line ("Next is " & Next_Location'Image);
>
> over
>
> Text_IO.Put_Line ("Next is " &
> Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));

Interesting example. When I define a type that I want to be able to
print, I define also (in the same place) an instantiation of
Integer_IO/Enumeration_IO, and I would write:
Put ("Next is "); Put (Next_Location); New_Line;

'Image was not intended for regular IO.

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Better way to fill Storage_IO?

<s83qkt$1ovh$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5207&group=comp.lang.ada#5207

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail
From: mail...@dmitry-kazakov.de (Dmitry A. Kazakov)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 21:58:25 +0200
Organization: Aioe.org NNTP Server
Lines: 37
Message-ID: <s83qkt$1ovh$1@gioia.aioe.org>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
<s82i3g$el$1@dont-email.me> <s83oo3$s2s$1@dont-email.me>
NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Dmitry A. Kazakov - Wed, 19 May 2021 19:58 UTC

On 2021-05-19 21:25, J-P. Rosen wrote:
> Le 19/05/2021 à 10:26, Björn Lundin a écrit :
>> Given the above I do prefer
>>
>>
>> Text_IO.Put_Line ("Next is " & Next_Location'Image);
>>
>> over
>>
>> Text_IO.Put_Line ("Next is " &
>> Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));
>
> Interesting example. When I define a type that I want to be able to
> print, I define also (in the same place) an instantiation of
> Integer_IO/Enumeration_IO, and I would write:
>    Put ("Next is "); Put (Next_Location); New_Line;
>
> 'Image was not intended for regular IO.

Maybe it was so in 1983. These days immediate I/O is impractical. Most
of use cases is about formatting strings and very rarely writing the
result into some file, usually stream. So 'Image is far more frequently
used than Integer_IO, Enumeration_IO etc. I did not use any of that for
decades. A programmer would not even care about them, because he will
not suddenly change the programming technique universally used with GUI
widgets, streams, database interfaces, for some obscure generic packages
when Text_IO gets involved.

So let's modify the example to:

Dialog.Message.Set_Text ("Next is " &
Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

Re: Better way to fill Storage_IO?

<s83rr7$krq$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5208&group=comp.lang.ada#5208

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: b.f.lun...@gmail.com (Björn Lundin)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Wed, 19 May 2021 22:18:47 +0200
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <s83rr7$krq$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
<s82i3g$el$1@dont-email.me> <s83oo3$s2s$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 19 May 2021 20:18:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="3294e74acc61672f724a4128636404d8";
logging-data="21370"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gpE9TJzG2XP3UKjEne3DI"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
Cancel-Lock: sha1:hH+87+XWpJP73oSIfAUFeIokMqI=
In-Reply-To: <s83oo3$s2s$1@dont-email.me>
Content-Language: en-US
 by: Björn Lundin - Wed, 19 May 2021 20:18 UTC

Den 2021-05-19 kl. 21:25, skrev J-P. Rosen:
> Le 19/05/2021 à 10:26, Björn Lundin a écrit :
>> Given the above I do prefer
>>
>>
>> Text_IO.Put_Line ("Next is " & Next_Location'Image);
>>
>> over
>>
>> Text_IO.Put_Line ("Next is " &
>> Coded_Values.WCS_Next_Location_Type_Type'Image(Next_Location));
>
> Interesting example. When I define a type that I want to be able to
> print, I define also (in the same place) an instantiation of
> Integer_IO/Enumeration_IO, and I would write:
>    Put ("Next is "); Put (Next_Location); New_Line;
>
> 'Image was not intended for regular IO.
>

If a function/procedure is public, users will use them.
And very likely in ways 'not intended',
So there should be a clear statement in the RM making it clear
that using 'Image is not for regular IO.

We use tons of it for writing to log files
This is why I want 'image for record types.
It would save me from writing To_String functions dumping record values
into the log. I think it made it into 202x but I am not sure.

And reasoning 'when I define a type I want to print...' does
not really appeal to me. I'd like the language to provide a way to
create a string version of my variables - basically any of them -
for log file use. When I define a type I am not always thinking if this
may or may not will be logged in the future, by someone else.
This leads to all types must define a Image/To_String function.

Why? Whats the point? What is the gain?

For records with nested lists I can see challenges,
but for scalar values? Floats? Fixed?

Why not have an easy-to-use AND readable solution?

--
Björn

Re: Better way to fill Storage_IO?

<igmavfFqf2mU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5209&group=comp.lang.ada#5209

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.h...@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Thu, 20 May 2021 08:38:55 +0300
Organization: Tidorum Ltd
Lines: 31
Message-ID: <igmavfFqf2mU1@mid.individual.net>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
<s82i3g$el$1@dont-email.me> <s83oo3$s2s$1@dont-email.me>
<s83rr7$krq$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net zBOVSSoOtePO0NA8OWeoww6Wt9Yym0QrKj+P4nW+/lPBZNRcsT
Cancel-Lock: sha1:EVcmAWXDy5ufP+Cbmhq5BD9uDto=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
Gecko/20100101 Thunderbird/78.7.0
In-Reply-To: <s83rr7$krq$1@dont-email.me>
Content-Language: en-US
 by: Niklas Holsti - Thu, 20 May 2021 05:38 UTC

On 2021-05-19 23:18, Björn Lundin wrote:
> Den 2021-05-19 kl. 21:25, skrev J-P. Rosen:
>> ....
>> 'Image was not intended for regular IO.
>>
>
> If a function/procedure is public, users will use them.

I agree, and I use 'Image a lot.

> And very likely in ways 'not intended',
> So there should be a clear statement in the RM making it clear
> that using 'Image is not for regular IO.

What could the RM say, as motivation? Your karma will decrease 5 points
every time you use 'Image for regular IO? Or every such use brings a
1/10000 chance of aborting the program or producing wrong results? :-)

> We use tons of it for writing to log files
> This is why I want 'image for record types.
> It would save me from writing To_String functions dumping record values
> into the log. I think it made it into 202x but I am not sure.

It is in the 202x proposal, RM 4.10 (32/5). See
http://www.ada-auth.org/standards/2xaarm/html/AA-4-10.html.

Re: Better way to fill Storage_IO?

<s850rr$mvm$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5210&group=comp.lang.ada#5210

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ros...@adalog.fr (J-P. Rosen)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Thu, 20 May 2021 08:50:37 +0200
Organization: Adalog
Lines: 27
Message-ID: <s850rr$mvm$1@dont-email.me>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com>
<lymtstxjdv.fsf@pushface.org>
<3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com>
<lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me>
<s82i3g$el$1@dont-email.me> <s83oo3$s2s$1@dont-email.me>
<s83rr7$krq$1@dont-email.me> <igmavfFqf2mU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 20 May 2021 06:50:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="220a71665d3acf0f4960dbbf373ce8a7";
logging-data="23542"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+oUz2YpvoubdVMkV13ppsr"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:6Hms3K6pHiYSdpoFbh7awHMFVWE=
In-Reply-To: <igmavfFqf2mU1@mid.individual.net>
Content-Language: fr
 by: J-P. Rosen - Thu, 20 May 2021 06:50 UTC

Le 20/05/2021 à 07:38, Niklas Holsti a écrit :
> What could the RM say, as motivation? Your karma will decrease 5 points
> every time you use 'Image for regular IO? Or every such use brings a
> 1/10000 chance of aborting the program or producing wrong results? :-)
The concern I have with 'Image is that it provides no formatting.
Also for file IO, Put(I) (from Integer_IO) is better than
Put(Integer'Image(I)), because the former will never break the value on
two lines, while the latter can if the line length is bounded, making
the value impossible to read later. Of course, uses other than file IO
do not have this constraint.

The concern I have with Obj'Image is that there is no clean model of
what it is. All other attributes are properly defined as predefined
functions with a profile, they can be used to instantiate generics, etc.

"X'Image denotes the result of calling function S'Image with Arg being
X, where S is the nominal subtype of X."

So, it's a special notation, like a kind of macro, with no proper
definition. This hurts my purist's state of mind...

--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52
https://www.adalog.fr

Re: Better way to fill Storage_IO?

<s86niu$kvl$1@franka.jacob-sparre.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5213&group=comp.lang.ada#5213

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!paganini.bofh.team!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail
From: ran...@rrsoftware.com (Randy Brukardt)
Newsgroups: comp.lang.ada
Subject: Re: Better way to fill Storage_IO?
Date: Thu, 20 May 2021 17:24:29 -0500
Organization: JSA Research & Innovation
Lines: 28
Message-ID: <s86niu$kvl$1@franka.jacob-sparre.dk>
References: <c6e99ba9-6455-4279-b175-343735acf2ecn@googlegroups.com> <lymtstxjdv.fsf@pushface.org> <3cfe02b8-18d3-4673-b808-48ad29092517n@googlegroups.com> <lypmxndbf2.fsf@pushface.org> <s82e2r$81l$1@dont-email.me> <s82i3g$el$1@dont-email.me> <s83oo3$s2s$1@dont-email.me> <s83rr7$krq$1@dont-email.me> <igmavfFqf2mU1@mid.individual.net> <s850rr$mvm$1@dont-email.me>
Injection-Date: Thu, 20 May 2021 22:24:30 -0000 (UTC)
Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226";
logging-data="21493"; mail-complaints-to="news@jacob-sparre.dk"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246
 by: Randy Brukardt - Thu, 20 May 2021 22:24 UTC

"J-P. Rosen" <rosen@adalog.fr> wrote in message
news:s850rr$mvm$1@dont-email.me...
....
> "X'Image denotes the result of calling function S'Image with Arg being X,
> where S is the nominal subtype of X."
>
> So, it's a special notation, like a kind of macro, with no proper
> definition. This hurts my purist's state of mind...

Naw, it's an attribute, just like 'Pos and 'First(N), neither of which
correspond to anything you can write. Saying that attributes are subprograms
(outside of the cases where redefinition is allowed, like 'Read) simply buys
a vast amount of special-case work with virtually no benefit to the user.
(In Janus/Ada, at least, we have to fake treating these things as functions,
as we could not afford [back in the day, of course] the space to materialize
all of these little-used functions. [Float types have some 20-odd of
them!]).

If someone has to pay a price, it might as well be the language standard and
not every implementer (and the users that actually try to use these things
as functions and run into bugs in stuff no one ever tries).

Water under the dam in any case, since no one has any reason to change any
of this.

Randy.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor