At some point I added the ability of CONTINUE to take a parameter. The idea was that CONTINUE with a parameter would act the same as if the loop body had completed with that value. One place this is most useful is MAP-EACH:
>> map-each x [1 2 3] [
if x = 2 [continue <twenty>] else [x * 10]
]
== [10 <twenty> 30]
But what should CONTINUE with no argument do? In the MAP-EACH case, I think it should pretty obviously not add anything to the output.
>> map-each x [1 2 3] [
if x = 2 [continue] else [x * 10]
]
== [10 30]
Nice. But what about "ordinary" loops?
How about WHILE or REPEAT or FOR-EACH? If we wanted it to be novel, it could say "don't change the pending overall result from whatever the last loop iteration would have returned":
>> for-each x [1 2 3] [
if x = 3 [continue] else [x * 10]
]
== 20
Although I like that in theory, it would break the loop composition rules unless loops were allowed to be invisible. :-/
Think about the code I've previously written down to implement FOR-BOTH:
for-both: func ['var blk1 blk2 body] [
unmeta all [
meta for-each var blk1 body
meta for-each var blk2 body
]
]
That FOR-BOTH could not have a CONTINUE that would run in the body of the second FOR-EACH and carry over a value from the first FOR-EACH.
Given that we'd be setting a standard that would be difficult to follow, I think the answer has to be:
>> for-each x [1 2 3] [
if x = 3 [continue] else [x * 10]
]
== ~none~ ; isotope
What about UNTIL and CONTINUE TRUE?
I've given a rule that CONTINUE passed a parameter effectively jumps to the end of the loop body as if it had finished with that value. But in UNTIL, the loop's body also is the condition. So what about:
>> until [print "A" if true [continue true] else [<unreachable>]] print "B"
A
B
It seems to make a certain amount of sense.