Closed pnelson closed 6 months ago
This should almost certainly go in the buffer module, but otherwise seems reasonable.
The ffi module and peg module have some of this functionality but with other limitations. I would prefer if this were just folded into the buffer module as "binary" isn't particularly descriptive for a module name.
I suspect many binary protocols need to encode/decode floats to/from big/little endian. Here is a first draft, should it be included in the standard library.
I am not tied to the
binary
module as I'm aware there existsbuffer/*
functions that are similar and it could possibly be bundled into the existingbuffer
module. I was concerned about the naming becausebuffer/push-word
already exists and the signature is different with no control over endianness. I thought it might be confusing to addbuffer/push-uint32
in that case - but maybe not.Additionally,
binary/write-float32
andbinary/write-float64
could potentially be removed if we implement something likemath/float32-bits
andmath/float64-bits
respectively for constructing sizeduint
s from the underlying bits and then lean onbinary/write-uint32
andbinary/write-uint64
to write to the buffer.I just wanted to start these discussions and fix any outstanding bugs that may be present.