comp.lang.ada
 help / color / mirror / Atom feed
* Better way to fill Storage_IO?
@ 2021-05-17 18:44 Michael Hardeman
  2021-05-17 19:14 ` Simon Wright
  2021-05-18 16:50 ` Shark8
  0 siblings, 2 replies; 20+ messages in thread
From: Michael Hardeman @ 2021-05-17 18:44 UTC (permalink / raw)


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?

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-05-20 22:24 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 18:44 Better way to fill Storage_IO? Michael Hardeman
2021-05-17 19:14 ` Simon Wright
2021-05-17 19:23   ` Michael Hardeman
2021-05-18 20:39     ` Simon Wright
2021-05-19  6:24       ` Dmitry A. Kazakov
2021-05-19  7:17       ` J-P. Rosen
2021-05-19  8:26         ` Björn Lundin
2021-05-19 19:25           ` J-P. Rosen
2021-05-19 19:58             ` Dmitry A. Kazakov
2021-05-19 20:18             ` Björn Lundin
2021-05-20  5:38               ` Niklas Holsti
2021-05-20  6:50                 ` J-P. Rosen
2021-05-20 22:24                   ` Randy Brukardt
2021-05-19 15:39         ` Simon Wright
2021-05-17 20:20   ` Dmitry A. Kazakov
2021-05-17 20:48     ` Michael Hardeman
2021-05-18 14:00       ` Per Sandberg
2021-05-18  9:08     ` J-P. Rosen
2021-05-18 10:10       ` Jeffrey R. Carter
2021-05-18 16:50 ` Shark8

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox