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

Eliminating usize #99

Open
DavePearce opened this issue Sep 26, 2021 · 0 comments
Open

Eliminating usize #99

DavePearce opened this issue Sep 26, 2021 · 0 comments

Comments

@DavePearce
Copy link
Member

There's an interesting issue with languages that have usize, in that you can never convert between an int and a usize without risking an overflow. How can we avoid this?

An interesting observation is that Java does not have this problem. In fact, Java limited array indices to int types (i.e. 32bit) which does indeed limit the maximum size of an array.

One option is to allow the user to specify this. For example, T[u32] indicates an array of type T with indices of type u32. That means the array has a maximum size limit, but also means we can read indices into u32 without risk of coercion failures.

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

No branches or pull requests

1 participant