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

language: look into overloading the array[x] syntax to support multiple number types. #2076

Open
spotandjake opened this issue Mar 22, 2024 · 0 comments

Comments

@spotandjake
Copy link
Member

spotandjake commented Mar 22, 2024

It would be really nice from a code perspective if we could do something like arr[1l] or arr[1ul]. This would require allowing us to override the array get syntax which I don't think we currently support from a type checking perspective. It might be worth looking into allowing this eventually though.

Possible Idea 1

Given hindley milner doesn't support union types in its inferencing algorithm we could maybe require you the user to specify the type allowing something like arr[t: Int32], this could maybe generate a different ast node with a different type signature, we could warn the user when they use something different.

Possible Idea 2

Another idea, that would need some work would be to treat [] get syntax as an operator this would allow for a lot of great options because it could be linked to a function with the signature (arr: Array<a>, index: Number) => a, we would need to figure out how you would define this function but it would let us use the standard use syntax to select which one were refering to. This might also have some interesting consequences surrounding generators which could be useful.

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