Skip to content
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

Bytes module #418

Open
TimWhiting opened this issue Jan 3, 2024 · 0 comments
Open

Bytes module #418

TimWhiting opened this issue Jan 3, 2024 · 0 comments

Comments

@TimWhiting
Copy link
Collaborator

TimWhiting commented Jan 3, 2024

We need a bytes module for better working with file and network I/O.

See issue 388 for a discussion about unsigned integer values and the fact that Daan wants a bytes module to work at a bytes level for low level representations.

Quote from his comment there:

The idea is that we should always use (arbitrary precision) int 's in Koka as these are well behaved. The int8/16/32/64, ssize_t, and intptr_t are only there for interfacing to external libraries. Now, int32 and int64 have actual operations defined in std/num/int32 and std/num/int64 but this is mostly for specialized use cases like crypto or random. Moreover, we will not add unsigned variants -- but note that std/num/intxx provide ways to interpret a result as unsigned (or convert from int unsigned) (uint64,uint) as well as unsigned multiply (umul) so we can still perform unsigned operations. Again, regular code should just always use int . There are no modules for int8 or int16 as I think there is no good reason for doing mod-2^x operations on those (although I can imagine having simd operations in the future for those)

Furthermore, the plan is to create a good std/data/bytes module that gives views on bytes where you can read/write int8/16/32/64 types but always to/from int's on the Koka side.

(see also What About the Integer Numbers?)

Related:
(libuv: issue #341)
(libuv: PR: #384)

Ideally we would have not only have operations for reading / writing values into a byte buffer, but also a bytes iterator or byte slice that could read/write & advance using different methods like read-int32, read-float32, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant