Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to "continue" (python) in rebol?

Tags:

python

rebol

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?

like image 720
Pierre Avatar asked Sep 07 '13 13:09

Pierre


1 Answers

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.

like image 114
DocKimbel Avatar answered Sep 28 '22 16:09

DocKimbel