feat(translate): implement +LOOP word for strided DO loops#28
Merged
tetsuo-cpp merged 3 commits intocanonfrom Feb 19, 2026
Merged
feat(translate): implement +LOOP word for strided DO loops#28tetsuo-cpp merged 3 commits intocanonfrom
tetsuo-cpp merged 3 commits intocanonfrom
Conversation
tetsuo-cpp
commented
Feb 19, 2026
Owner
Author
tetsuo-cpp
left a comment
There was a problem hiding this comment.
Code Review
Clean, well-structured PR. The emitLoopEnd extraction is a natural refactoring that eliminates duplication without over-abstracting. The +LOOP implementation is minimal and easy to follow.
Tests
Thorough coverage — translation IR check, error case, and full pipeline test.
Two items to consider
-
Negative step values: Standard Forth
+LOOPuses a direction-sensitive termination check — positive step terminates whenindex >= limit, negative step terminates whenindex < limit. The current implementation always usesslt, so negative step values will produce an infinite loop. Worth documenting the limitation or addressing it. -
CLAUDE.md: The supported words list says
DO LOOP I J Kbut doesn't mention+LOOP.
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
emitLoopEndhelperLOOPto use the new helper+LOOPwhich pops an arbitrary step from the data stackTest plan
plus-loop.forthplus-loop-without-do-error.forthplus-loop.forthCloses #25