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

Introduce Byte, Bytes, and Chars aliases #2740

Closed
wants to merge 1 commit into from

Conversation

keplersj
Copy link
Contributor

@keplersj keplersj commented Jun 3, 2016

Fixes #1348

@asterite
Copy link
Member

asterite commented Jun 3, 2016

Thanks!

We can maybe start with just Bytes, I'm not sure Byte would be used (typing UInt8 is almost as easy) and Chars has no use case right now. I just mentioned those other in a theoretical way.

@ozra
Copy link
Contributor

ozra commented Jun 4, 2016

Byte feels nice for working with "binary buffers" rather than UInt8 which could be seen as more ambiguous. Obviously would go along well with Bytes.
Chars would be better off as CString or so for use cases I'd think of, no?

@jhass
Copy link
Member

jhass commented Jun 4, 2016

LibC::UnicodeString then? Though hard to argue whether it should be Slice(Char) or Char*.

@asterite
Copy link
Member

asterite commented Jun 4, 2016

The use of Slice(Char) is for IO, when you'd want to read a few chars instead of bytes with some encoding. For example:

io = ...

bytes = UInt8[1024]
io.read(bytes.to_slice)

chars = Char[1024]
io.read(chars.to_slice)

This would be similar to C# (read chars from a text reader, or read bytes from a binary stream). However, we haven't found a real use case for that yet, so for now I wouldn't introduce a Chars alias.

@ozra
Copy link
Contributor

ozra commented Jun 4, 2016

Ah, right, Char = 32bit, my mind was in C-world X-|

@keplersj keplersj mentioned this pull request Jun 8, 2016
@keplersj keplersj closed this Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants