The prime motivation for finally
clauses is to guarantee clean-up of resources like open files, locks, etc. For example, the Julia docs on finally
clauses present the following example.
f = open("file")
try
# operate on file f
finally
close(f)
end
In codes like this, there is some syntactic “gap” between returning from open()
and entering the try
block. This raises the question: does the language guarantee that no exception can be thrown in this gap? It’s clear that nothing “internal” can throw an exception (there simply isn’t anything which could do that), but what about e.g. interrupts?