Skip and Stop
In Goblin, skip and stop control how execution moves through repeating structures.
They work inside:
- loops (
while,for,repeat) - Sweep operations
Goblin intentionally uses plain-language control words instead of the traditional programming keywords:
skipinstead of continuestopinstead of break
The meaning is the same—the wording is simply clearer and easier to read.
Skip
skip immediately jumps to the next iteration of the current loop or the next match in a sweep.
What you write
skip
skip
Example (loop)
i | 0 repeat 5 i += 1 if i = 3 skip end say i end
i | 0 repeat 5 i += 1 if i = 3 skip end say i end
Output
1
2
4
5
When i becomes 3, that iteration is skipped and execution continues with the next one.
Stop
stop immediately exits the current loop or sweep.
What you write
stop
stop
Example (loop)
i | 0 repeat 10 i += 1 if i = 4 stop end say i end
i | 0 repeat 10 i += 1 if i = 4 stop end say i end
Output
1
2
3
When i reaches 4, the loop stops entirely.
Skip and Stop in Sweep
Sweep also supports skip and stop, but they operate on matches instead of loop iterations.
skip in sweep
Inside a sweep arm, skip cancels the current match and continues scanning for the next one.
sweep file "TODO" if :contains(self, "ignore") skip end self |= :replace(self, "TODO", "DONE") end
sweep file "TODO" if :contains(self, "ignore") skip end self |= :replace(self, "TODO", "DONE") end
If the matched region contains "ignore", that match is skipped and left unchanged.
stop in sweep
stop ends the sweep entirely.
sweep file "TODO" if :contains(self, "FINAL") stop end self |= :replace(self, "TODO", "DONE") end
sweep file "TODO" if :contains(self, "FINAL") stop end self |= :replace(self, "TODO", "DONE") end
Once "FINAL" is encountered, the sweep stops and no further matches are processed.
Where Skip and Stop Are Allowed
skip and stop must appear inside a structure that supports them.
Valid locations:
- loops
- Sweep
Using them elsewhere produces an error.
skip
skip
error: R0405: loop-control-outside-loop: ‘skip’ used outside of a loop
Why This Exists
Many programming languages use continue and break.
Goblin instead uses clear verbs:
- skip → skip this iteration or match
- stop → stop the loop or sweep entirely
This keeps control flow readable and consistent across both loops and Sweep.