Skip to content

Factor ast.Slice out into its own package#416

Merged
mcy merged 3 commits intomainfrom
mcy/sliceface
Jan 7, 2025
Merged

Factor ast.Slice out into its own package#416
mcy merged 3 commits intomainfrom
mcy/sliceface

Conversation

@mcy
Copy link
Member

@mcy mcy commented Jan 7, 2025

I plan to use this pattern when I implement the IR package, so having it not live in the AST package is a good idea.

I've also refactored the interfaces to be simpler, and to reduce the number of methods that actually need to be implemented: almost all types (except for ast.TypeList) that were previously an ast.Slice now have an accessor for it.

The ast.Slice.Iter function has been dropped, and iteration is now done with dedicated iterators in seq.

Copy link
Member

@jhump jhump left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.


// Delete deletes the element at the given index.
//
// Should panic if idx < 0 or idx > Len().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Should panic if idx < 0 or idx > Len().
// Should panic if idx < 0 or idx >= Len().

@mcy mcy enabled auto-merge (squash) January 7, 2025 19:19
@mcy mcy merged commit b04f563 into main Jan 7, 2025
7 checks passed
@mcy mcy deleted the mcy/sliceface branch January 7, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants