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

[Feature Request] Introduce alias Byte = UInt8 #3634

Open
1 task done
soraros opened this issue Oct 10, 2024 · 4 comments
Open
1 task done

[Feature Request] Introduce alias Byte = UInt8 #3634

soraros opened this issue Oct 10, 2024 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers mojo-repo Tag all issues with this label

Comments

@soraros
Copy link
Contributor

soraros commented Oct 10, 2024

Review Mojo's priorities

What is your request?

As title.

What is your motivation for this change?

It helps document the intent, especially in low-level code (e.g., memcpy), where we treat the underlying type as just a pack of bits rather than a numerical type, similar to the distinction between i1 and bool.

We could introduce a nominal type Byte which implicitly converts to UInt8, but that feels more complex than necessary.

Any other details?

N/A

@soraros soraros added enhancement New feature or request mojo-repo Tag all issues with this label labels Oct 10, 2024
@martinvuyk
Copy link
Contributor

I think it's also important to note that in Python byte is it's own object type with it's own type of representation (prints with b'{value_here}') and many other byte related things.

Also, Span[Uint8] could be aliased to ByteArray and List[UInt8] to Bytes since their APIs are very similar to byte operations

(btw typo in the title)

@JoeLoser JoeLoser changed the title [Feature Request] Introduce alias Bype = UInt8 [Feature Request] Introduce alias Byte = UInt8 Oct 14, 2024
Copy link
Collaborator

Have you seen #2096 (comment) and our feedback there? I'd be open to someone adding a lightweight alias in the meantime to improve readability/express intent better at call sites.

@soraros
Copy link
Contributor Author

soraros commented Oct 14, 2024

Have you seen #2096 (comment) and our feedback there?

Yea, I think Bytes needs way more justification and design.

I'd be open to someone adding a lightweight alias in the meantime to improve readability/express intent better at call sites.

Let's move forward with simply alias Byte = UInt8 then. I think it's a good first issue.

@JoeLoser JoeLoser added the good first issue Good for newcomers label Oct 14, 2024 — with Linear
Copy link
Collaborator

Sounds good, just added "good first issue". Whoever takes this, feel free to add the alias and we can incrementally apply it where we're working with "Bytes".

modularbot pushed a commit that referenced this issue Oct 16, 2024
[External] [stdlib] Introduce `Byte`

And use it in `memory.mojo`. Related to
#3634.

Co-authored-by: soraros <soraros@users.noreply.github.com>
Closes #3670
MODULAR_ORIG_COMMIT_REV_ID: c69c46207857968bb2c4d752c3b5c2952de081ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants