-
-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iolist_size crashes on non-byte aligned bit strings #320
Comments
Thank you |
How do we fix this? Do bit strings need to be byte-aligned? Erlang iolists are formed from byte-aligned binaries. Do we deprecate |
Great point. Do they always need to be byte aigned? Is there a function to get the bit size of an iolist? |
Iolists need to be byte-aligned according to their Erlang type specs. You can combine bit strings into lists. However, they will fail for byte_size, even if they add up to a byte-aligned value:
There is a The real problem will be networks and file I/O. I think both need byte boundaries. I don't think you can send/write a fraction of a byte. I feel like you'd be forced into size checking a bit string list before doing anything useful with it. |
I think being byte aligned makes sense, but it has some uncomfortable API implications. If a bit string is added that is not byte aligned should it fail? That implies it should return a I also wonder if the name |
The problem is that we cannot tell if the bit string is byte-aligned at compile-time. Here's the option I've been thinking about:
|
forbidding expressions where the static size isn't multiple of 8 to compile would be a good start |
can someone showcase a use case of partial bitstrings?
they don't seem to work at the moment |
gleam-lang/gleam#1591 is related
|
I think the answer is to:
|
We will not do this, bit strings of any size are perfectly valid in BEAM languages. The plan here is to make BitBuilders always byte aligned, as they are intended to be in Erlang. The name is misleading, we may want to change it to BinaryBuilder or ByteBuilder |
crashes with
The text was updated successfully, but these errors were encountered: