From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!yy9MKEJN2ULhWGfnfq4v5w.user.gioia.aioe.org.POSTED!not-for-mail From: 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 Message-ID: References: <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= Xref: reader02.eternal-september.org comp.lang.ada:62007 List-Id: Michael Hardeman 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.