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] Keyword only parameter argument in __getitem__ syntax #3333

Open
1 task done
soraros opened this issue Jul 30, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request mojo-repo Tag all issues with this label

Comments

@soraros
Copy link
Contributor

soraros commented Jul 30, 2024

Review Mojo's priorities

What is your request?

Allow using the syntax s[idx, label="test"] for fn __getitem__[*, label: String](self, idx: Int) -> R. Note that if both label and idx are runtime/compile-time, the syntax works fine; this feature request is for support when there is a mix of them

What is your motivation for this change?

  • Achieve better uniformity between runtime and compile-time APIs.
  • Enable interesting API designs such as:
struct Pointer:
  ...
  fn __getitem__[type: DType, //, *, size](self: Pointer[Scalar[type]], offset: Int) -> SIMD[dtype, size]:
    ...

fn main():
  p[idx, size=simd_width]

Any other details?

N/A

@soraros soraros added enhancement New feature or request mojo-repo Tag all issues with this label labels Jul 30, 2024
@soraros soraros changed the title [Feature Request] Labeled parameter argument in __getitem__ syntax [Feature Request] Keyword only parameter argument in __getitem__ syntax Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

1 participant