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
[stdlib] Audit uses of StaticIntTuple
#2515
Comments
I propose to use 'NTuple[2, Int]' as the type alias for 'Tuple[Int, Int]', and 'NTuple[N, T]' in general, so that it can be easily dispatch on 'N'. |
Can you elaborate on the value of the type alias? I'm not sure I understand the full value yet. Are there places you have in mind in the library that would benefit from this? |
NTuple[2, Int] = Tuple[Int, Int]
NTuple[3, Int] = Tuple[Int, Int, Int] Or In general I should be able to write alias NTuple[N, T] = Tuple[VariadicPack[T, N]] Then I can dispatch on |
@JoeLoser while working on this I found a potential issue, StaticIntTuple is imported in builtin/int.mojo which exposes it everywhere as all builtins, is exposing stuff in this way intentional? |
Maybe we should open an issue to have a new mechanism in the stdlib to define what exactly does not need import and what needs imports. This issue has bitten me quite a few times. EDIT: Created the issue and proposed a fix that must be implemented partly on the compiler side: |
Seems like |
Off-topic: Why |
@msaelices it's ongoing changes, you can take a look at #2335 |
Similar in spirit to #2514, it would be nice to audit our use of
StaticIntTuple
in the standard library which is a mix ofInlineArray[Int, size]
with some odd APIs that make it represents dimensions or tuple-like things.Where it makes sense, it would be good to simplify APIs to not be coupled to this unique/non-generic type. For example, this Int._divmod function should just return a
Tuple[Int, Int]
instead of using this unique type. There's no reason to preferStaticIntTuple[2]
overTuple[Int, Int]
here.Feel free to ask questions about specific APIs if you're not sure whether to change it or not.
The text was updated successfully, but these errors were encountered: