Feat: The Mamba-style indexing of collections - #498
Draft
JSAbrahams wants to merge 2 commits into
Draft
Conversation
added 2 commits
August 28, 2026 14:08
If collection, mark as so. This allows us to: - First generate Python code were we style use C-style collection access if necessary (for lists). - And down the line also allows us to generate machine code where we distinguish between the two.
JSAbrahams
marked this pull request as draft
August 28, 2026 14:00
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #498 +/- ##
===========================================
- Coverage 92.50% 92.33% -0.17%
===========================================
Files 113 113
Lines 15709 15911 +202
===========================================
+ Hits 14531 14692 +161
- Misses 1178 1219 +41
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Unlike C-style languages, we index collections using round brackets regardless of collection type.
E.g. we don't distinguish between lists and maps.
We had wanted to implement this for some time, but now we actually implemented this.
This feature essentially fully leverages the type checker to detect if we are indexing a collection, and passes this information to the (Python) backend.
This means that collection indexing is decoupled from our syntax.
Concretely, this means that mamba style indexing
(and)is still desugared to Pythons[]C-style indexing.Becomes
In general, we also try to expand the code example section.
The README elaborates a bit more on why we opted for this perhaps unusual syntax which deviates from the C-style which dominates all languages.
The advantage of this decoupling is that it can work either way. If in future we opt to change our syntax (back/again), we can leave our backend untouched. We mainly need to change the type checker then to reject function calls and augment the grammar (if necessary) for indexes.
Added Tests