biniou
biniou copied to clipboard
New module to export the untagged_read/write functions
Hello,
I think it may be useful to have a module so that people can directly read/write untagged values, without having to go through biniou's output buffer (and associated data copy).
Instead of using an output buffer, these functions would take an in or out_channel.
I'd like to expose in such module all the read/write_untagged_* functions but using channels for these ones.
Regards, F.
It's a matter of performance (how to write say 4 bytes to a channel but perform only one bound check internally?), and also reusability (can't use channels for writing to string or to an arbitrary buffer).
Did you take a look at Bi_outbuf.create_channel_writer
and Bi_inbuf.from_channel
?
Bi_outbuf.create_channel_writer
Yes, I saw the make_room function can write to an output channel.
Wouldn't it be possible to use a functor to have the read/write_untagged_* functions either work with a biniou in/out_buffer or an in/out channel?
I still think the read/write_untagged_* functions are useful even outside of biniou's context. Pervasives from stdlib provides output_binary_int and input_binary_int but nothing for floats for example.