# Loops

**URL:** https://revolt.metaeducation.com/forum/c/development/loops/65.md

[Latest](https://revolt.metaeducation.com/forum/latest.md) · [Categories](https://revolt.metaeducation.com/forum/categories.md) · [Tags](https://revolt.metaeducation.com/forum/tags.md)

---

## [About the Loops category](https://revolt.metaeducation.com/forum/t/about-the-loops-category/2478)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [June 7, 2025, 9:57am UTC](https://revolt.metaeducation.com/forum/t/about-the-loops-category/2478 "2025-06-07T09:57:28Z")

</div>

Loops in Revolt are a bit different from historical Redbol. They follow the Loop Result Protocol BREAK and CONTINUE are definitional There seemed to be enough posts about loops to give them their own category. …

---

## [FOR-BOTH: Loop Composability For The Win ❗](https://revolt.metaeducation.com/forum/t/for-both-loop-composability-for-the-win/1833)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 2\
**Last updated:** [September 14, 2026, 3:20am UTC](https://revolt.metaeducation.com/forum/t/for-both-loop-composability-for-the-win/1833 "2026-09-14T03:20:02Z")

</div>

FOR-BOTH was an early talking point for an extremely simple usermode loop construct that would be built out of two FOR-EACH loops: \>\> for-both x \[1 2\] \[3 4\] \[print \[x\]\] 1 2 3 4 A naive implementation of this in Rebol2 …

---

## [WHILE Loop Condition Conservatism Examined](https://revolt.metaeducation.com/forum/t/while-loop-condition-conservatism-examined/2669)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [January 30, 2026, 7:30pm UTC](https://revolt.metaeducation.com/forum/t/while-loop-condition-conservatism-examined/2669 "2026-01-30T19:30:42Z")

</div>

In the CONDITION slot, WHILE only accepts BLOCK! and FRAME! (e.g. a function to call). There was a comment in the source that said: // It was considered if \`while okay \[...\]\` should infinite loop, and then // \`while nu…

---

## [Virtual Binding + Macros =\> BREAK, CONTINUE, AGAIN](https://revolt.metaeducation.com/forum/t/virtual-binding-macros-break-continue-again/2479)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 5\
**Last updated:** [January 26, 2026, 6:57pm UTC](https://revolt.metaeducation.com/forum/t/virtual-binding-macros-break-continue-again/2479 "2026-01-26T18:57:36Z")

</div>

In the last moments of 2023, Revolt finally bit the bullet and made BREAK and CONTINUE definitional (it was a long time coming, just hadn't gotten around to it...): Definitional Break and Continue: The Time Is Now This…

---

## [The Mismatch of Arity-1 UNTIL and Arity-2 WHILE](https://revolt.metaeducation.com/forum/t/the-mismatch-of-arity-1-until-and-arity-2-while/594)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 5\
**Last updated:** [May 12, 2025, 5:58am UTC](https://revolt.metaeducation.com/forum/t/the-mismatch-of-arity-1-until-and-arity-2-while/594 "2025-05-12T05:58:27Z")

</div>

Long ago, there was a fervent debate about whether UNTIL was a word that was "naturally paired" with WHILE. So it was wondered if UNTIL should be an arity-2 function which was effectively WHILE-NOT, instead of its arity…

---

## [Definitional Break and Continue... the Time is Now](https://revolt.metaeducation.com/forum/t/definitional-break-and-continue-the-time-is-now/2066)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 2\
**Last updated:** [November 8, 2025, 8:13pm UTC](https://revolt.metaeducation.com/forum/t/definitional-break-and-continue-the-time-is-now/2066 "2025-11-08T20:13:33Z")

</div>

I was writing what I thought to be a clever bit of code, discussed here for-each file ... \[ parse file \[thru any \[".reb" ".r"\] \<end\> | (continue)\] ... \] I thought it was pleasing to have the CONTINUE in the rul…

---

## [Should modifying variables during a Loop affect it?](https://revolt.metaeducation.com/forum/t/should-modifying-variables-during-a-loop-affect-it/938)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 8\
**Last updated:** [June 9, 2025, 2:05pm UTC](https://revolt.metaeducation.com/forum/t/should-modifying-variables-during-a-loop-affect-it/938 "2025-06-09T14:05:34Z")

</div>

Here is the behavior of changing a REPEAT variable in Rebol2 and R3-Alpha: rebol2\>\> repeat n 3 \[print "What happens?" n: 3\] What happens? == 3 Here's that same behavior in Red: red\>\> repeat n 3 \[print "What happens?" …

---

## [\[REPEAT 1\] =\> ATTEMPT (Not As Useless As It Looks)](https://revolt.metaeducation.com/forum/t/repeat-1-attempt-not-as-useless-as-it-looks/2480)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [June 7, 2025, 11:26am UTC](https://revolt.metaeducation.com/forum/t/repeat-1-attempt-not-as-useless-as-it-looks/2480 "2025-06-07T11:26:40Z")

</div>

Historical Rebol had a use for ATTEMPT that we don't really need anymore... due to how definitional ERROR!s work and being covered by other things. When the word was freed up, I thought This looks like a perfect name fo…

---

## [I'm bringin' EVERY back (yeah!)](https://revolt.metaeducation.com/forum/t/im-bringin-every-back-yeah/915)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [November 19, 2018, 3:25pm UTC](https://revolt.metaeducation.com/forum/t/im-bringin-every-back-yeah/915 "2018-11-19T15:25:46Z")

</div>

(:man\_dancing: :musical\_note: :desktop\_computer: ...them other boys don't know how to hack (yeah!) :musical\_note: :man\_dancing: :computer:) With apologies to Justin Timberlake, I re-present to you EVERY. It was tempor…

---

## [Seeing LETs In Loop Conditions In Loop Bodies](https://revolt.metaeducation.com/forum/t/seeing-lets-in-loop-conditions-in-loop-bodies/2446)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [May 11, 2025, 6:57pm UTC](https://revolt.metaeducation.com/forum/t/seeing-lets-in-loop-conditions-in-loop-bodies/2446 "2025-05-11T18:57:47Z")

</div>

So I'm really a fan of it when languages let you do things like introduce variables in loop conditions that are only visible in the body. C99 actually lets you do this with for loops (not others, though): for (int x = …

---

## [Tunnelling BREAK and CONTINUE Across Binding](https://revolt.metaeducation.com/forum/t/tunnelling-break-and-continue-across-binding/2133)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 0\
**Last updated:** [January 24, 2024, 8:56pm UTC](https://revolt.metaeducation.com/forum/t/tunnelling-break-and-continue-across-binding/2133 "2024-01-24T20:56:51Z")

</div>

In %make-reb-lib.r, there's are abstractions for helping you do something for every API definition. The APIs are in an array of objects, and the idea is to go through all the objects and run some code bound into each on…

---

## [Special Syntax for FOR-EACH/etc. to receive ACTION!s?](https://revolt.metaeducation.com/forum/t/special-syntax-for-for-each-etc-to-receive-action-s/955)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 1\
**Last updated:** [May 18, 2025, 1:02pm UTC](https://revolt.metaeducation.com/forum/t/special-syntax-for-for-each-etc-to-receive-action-s/955 "2025-05-18T13:02:29Z")

</div>

Here is some pretty innocuous-looking code: n: 1 for-each item block \[ print \["the" item "is" n "in the block"\] n: n + 1 \] But because Rebol runs ACTION!s when they are bound to WORD!s, and you can put ACTION!s…

---

## [Modifying While Iterating: Crash, Nonsense, Predictable, or Illegal?](https://revolt.metaeducation.com/forum/t/modifying-while-iterating-crash-nonsense-predictable-or-illegal/1317)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 5\
**Last updated:** [December 27, 2024, 4:21pm UTC](https://revolt.metaeducation.com/forum/t/modifying-while-iterating-crash-nonsense-predictable-or-illegal/1317 "2024-12-27T16:21:51Z")

</div>

Every imperative language has the problem of when you modify a data structure, you run the risk of confusing other code that is looking at that data structure at the same time. Whether it's threads competing for access,…

---

## [Using loops with ELSE](https://revolt.metaeducation.com/forum/t/using-loops-with-else/523)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 4\
**Last updated:** [February 19, 2018, 10:51am UTC](https://revolt.metaeducation.com/forum/t/using-loops-with-else/523 "2018-02-19T10:51:08Z")

</div>

Loop constructs return NULL when there is a BREAK, and generally return a VOID if they never run their bodies. This gives some nice expressive power, such as this example from some code that appends encapped data to exe…

---

## [The Simple-yet-Powerful Loop Result Protocol](https://revolt.metaeducation.com/forum/t/the-simple-yet-powerful-loop-result-protocol/609)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 3\
**Last updated:** [January 25, 2021, 9:09am UTC](https://revolt.metaeducation.com/forum/t/the-simple-yet-powerful-loop-result-protocol/609 "2021-01-25T09:09:23Z")

</div>

Loops return null if-and-only-if they break One very good reason this rule exists is to make it easy to build custom loop constructs out of several other loop constructs. You can tell "from the outside" whether one of y…

---

## [Compatibility MAP-EACH (and problems therewith)](https://revolt.metaeducation.com/forum/t/compatibility-map-each-and-problems-therewith/1192)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 4\
**Last updated:** [August 5, 2020, 9:51pm UTC](https://revolt.metaeducation.com/forum/t/compatibility-map-each-and-problems-therewith/1192 "2020-08-05T21:51:13Z")

</div>

In trying to make a shim where MAP-EACH splices and has /ONLY, I thought the easiest way of doing it might be to redo it in terms of a COLLECT of a FOR-EACH. This delves some into the ambition of Revolt to raise the bar…

---

## [Generic Looping: Cutting FOR Back a Bit](https://revolt.metaeducation.com/forum/t/generic-looping-cutting-for-back-a-bit/1310)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 1\
**Last updated:** [July 27, 2020, 12:30pm UTC](https://revolt.metaeducation.com/forum/t/generic-looping-cutting-for-back-a-bit/1310 "2020-07-27T12:30:11Z")

</div>

Trying to convert code to be stackless is difficult, and the more fiddly code you have the harder it can be. The implementation of FOR loops is rather complex, because it tries to support FOR looping over a series...whi…

---

## [Infinite Loops vs. Errors](https://revolt.metaeducation.com/forum/t/infinite-loops-vs-errors/936)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 1\
**Last updated:** [December 29, 2018, 8:38pm UTC](https://revolt.metaeducation.com/forum/t/infinite-loops-vs-errors/936 "2018-12-29T20:38:43Z")

</div>

There's a seemingly innocuous response to an edge case in FOR in R3-Alpha: \>\> for i 1 10 0 \[print "???"\] == none That's a change from Rebol2, where it would infinite loop. The change was deliberate, and is part of a d…

---

## [Remove-each x \[for-each map-each remove-each\] \[x = 'remove-each\]](https://revolt.metaeducation.com/forum/t/remove-each-x-for-each-map-each-remove-each-x-remove-each/262)

<div class="topic-metadata">

**Author:** [@hostilefork](https://revolt.metaeducation.com/forum/u/hostilefork)\
**Replies:** 4\
**Last updated:** [August 23, 2017, 3:52am UTC](https://revolt.metaeducation.com/forum/t/remove-each-x-for-each-map-each-remove-each-x-remove-each/262 "2017-08-23T03:52:20Z")

</div>

TL;DR =\> How do people feel about REMOVE-EACH locking the array which is to be removed from during the removal process (so it appears unmodified while running the loop body, even if removals have been indicated). Then a…
