Implement native Iterator system
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 61
Description
Description
Currently, Vx for loops are hardcoded to iterate over integer ranges (for i in start..end { ... }). We need native support for generalized iterators, similar to Rust's Iterator trait, to allow iterating over custom collections, arrays, and ranges seamlessly.
Proposed Implementation
- Parser & AST Extensions:
- Add support for generic parameters in traits (e.g.,
trait Iterator<T> { ... }). - Add support for generic parameters in
implblocks (e.g.,impl<T> Iterator<T> for MyStruct<T>).
- Add support for generic parameters in traits (e.g.,
- Standard Library Additions:
- Introduce
enum Option<T> { Some(T), None }. - Introduce
trait Iterator<T> { fn next() -> Option<T>; }(or with appropriateselfbinding once supported). - Introduce a
Rangestruct that implementsIterator.
- Introduce
- Compiler Lowering:
- Update the
ForLoopStmtparser to accept any expression (for item in expr { ... }). - Modify the semantic analyzer to verify that
exprimplementsIteratororIntoIterator. - Lower the
forloop in MLIR into a generic loop that calls.next()and matches onSome/None.
- Update the
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 by tracing the ForLoopStmt parser, semantic analyzer, and MLIR lowering mentioned in the proposal. Review how integer ranges are currently represented and lowered, then map the required parser, AST, standard-library, type-checking, and lowering changes. Done means custom collections, arrays, and ranges can be iterated through the native Iterator and Option abstractions.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100