vx-lang / vx-lang/Vx

Implement native Iterator system

Open
#110 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core-lang enhancement
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
  1. Parser & AST Extensions:
    • Add support for generic parameters in traits (e.g., trait Iterator<T> { ... }).
    • Add support for generic parameters in impl blocks (e.g., impl<T> Iterator<T> for MyStruct<T>).
  2. Standard Library Additions:
    • Introduce enum Option<T> { Some(T), None }.
    • Introduce trait Iterator<T> { fn next() -> Option<T>; } (or with appropriate self binding once supported).
    • Introduce a Range struct that implements Iterator.
  3. Compiler Lowering:
    • Update the ForLoopStmt parser to accept any expression (for item in expr { ... }).
    • Modify the semantic analyzer to verify that expr implements Iterator or IntoIterator.
    • Lower the for loop in MLIR into a generic loop that calls .next() and matches on Some/None.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.