Hi,
Would it make sense for Nim to borrow the following syntax from Python?
for i in 1..100:
someaction1(i)
if somecondition(i):
break
someaction2(i)
else:
echo "No i matches the condition!"
where the else clause is executed if and only if no break statement was executed in the for loop? I found also another nice explanation. This clause would save me adding a boolean flag to the loop.
I find this pattern quite useful in any kind of code that e.g. tests and acts on complex conditions in large arrays.
you can do the same with block labels:
block myBlock:
for i in 1..100:
someaction1(i)
if somecondition(i):
break myBlock
someaction2(i)
echo "No i matches the condition!"
So I would say, it doesn't make sense to add support for this syntax