lang: dispatch operators to the `core::ops` traits
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 13h 13m
- Merged PRs (30d)
- 70
Description
a + b on a user type is a type error. Operators are built in for scalars and tensors, and there is no path from a BinaryOp to a user method.
What needs it. core::ops is a set of definitions that mean nothing until this exists. Wrapping<T>, Saturating<T> and Duration are unusable without it, and == on Option<T> cannot be written at all.
Today. src/hir/check/operators.rs handles scalar and tensor arithmetic directly. Tensors already get operator overloading of a sort -- x @ y and rank-2 * both route to linalg.matmul -- so there is a hook to generalize rather than a mechanism to invent.
Scope. Arithmetic and bitwise operators over Add/Sub/Mul/Div/Rem/BitAnd/BitOr/BitXor/Shl/Shr, comparisons over PartialEq/PartialOrd, and a[i] over Index/IndexMut. Output is an associated type in Rust, so this wants A10 first or a parameter in its place.
Part of the core library plan (#451), item A11. Needed by phase 2.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/hir/check/operators.rs and inspect how scalar, tensor, and linalg.matmul operators are dispatched. Read the core::ops definitions and the dependency on A10 in issue #451 before choosing how Output is represented. Done means arithmetic, bitwise, comparison, and indexing operators reach the corresponding user traits, including IndexMut.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100