Replies: 1 comment
-
Since the resumption escapes the handler you should probably use
Output:
The explanation is that when you capture a resumption, there is no guarantee that the finalizers will ever run - if you never call resume. So at a high level the default behavior is to run finalizers after the operation finishes if there is no call to resume. For example, you want to close a file even if there is an exception thrown when working with the file. |
Beta Was this translation helpful? Give feedback.
-
This is probably a documentation issue, but the book section 3.4.11 says this about
finally
:My understanding of this is if I enter a continuation one or zero times, it should work as expected. But actually even with entering it once you can run a finalizer twice:
Output:
Note that "After op1" is printed once (i.e. the continuation is called once), but "In finally" is printed twice.
Beta Was this translation helpful? Give feedback.
All reactions