Skip to content

Eliminating usize #99

Description

@DavePearce

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions