I am converting some python code to rebol, and I just came across a "continue" instruction. It interrupts the processing of a loop, going to the next iteration of the loop.
I find this word quite elegant and readable.
I came across some answers there: (in French), but nothing really "elegant": http://pl.legoff.free.fr/dotclear/vf/index.php/post/2003/01/05/Equivalent-d-un-Continue-ou-Next-dans-une-bouc As this converation is about 10 years old, maybe some improvements were made in Rebol since?
You can do it in Rebol2 using exceptions:
continue: does [throw 'continue]
loop 2 [
catch [
print {"This'll print", {DocKimbel} said.}
continue
print {"This won't print", {DocKimbel} said.}
]
]
In case you have custom exceptions to handle in the loop, you can use the /name refinement as in catch/name [...] 'continue to avoid catching other exceptions. It is even possible to override iterators to do it transparently for you, but at the cost of some slower performances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With