[SG16-Unicode] std::byte based I/O library

Lyberta lyberta at lyberta.net
Thu Feb 7 20:59:00 CET 2019


>      There should be no "text IO". Binding attributes on stream objects to
> "handle text" is the mistake IO streams made; it absolutely muddled the
> concerns of IO streams and turned them into stateful messes on the same
> level of floating point and having to save / restore FP registers after
> each call or specific use in order to not break everything downstream /
> used after you made a few calls with specific "sticky" flags.

So do you want to pass the state explicitly such as

std::io::read(stream, state, variable);

My idea is a bit of compromise that I put everything in a single object
and provide a simple accessor function to change it such as

auto my_state = stream.state();
// ...
// Change state
// ...
stream.state() = my_state;

That way we still have the convenient syntax of

std::io::read(stream, variable);

>      If you want IO in your text library, make it a single, atomic call
> where all the information required to serialize the text properly is done
> in a single function.

I'm totally fine with this design but I wonder if anyone actually has a
use case where they can't just parse all the text into string at once.
But I'm fine with skipping this use case for now.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://www.open-std.org/pipermail/unicode/attachments/20190207/f7e68d86/attachment.bin 


More information about the Unicode mailing list