Is there a way to break out of a named block from a proc called within that block. I want to make some code a bit more readable by doing something like:
proc foo() =
break outer
block outer:
while true:
foo()
I cant't figure out how to have the outer block inside the scope of the procyou can use an exception to do this:
proc foo() =
raise newException(CatchableError, "?")
try:
while true:
foo()
except:
echo "terminated"
Though without knowing what exactly you want to do, I would rather return a value and then break the loop from the caller site based on it's value.
I should have remembered that I could just do something like this:
proc foo(bar: var bool) =
bar = false
var bar = true
while bar:
foo(bar)
Thanks for the comments!