`最终``最后蒙版异步''例外
我仍然无法将头缠绕在掩蔽中,以异步异常。
最后
在control.exception
掩盖操作中:
a `finally` sequel =
mask $ \restore -> do
r <- restore a `onException` sequel
_ <- sequel
return r
如果最后
内部不掩盖,会有什么区别?
a `finally` sequel = do
r <- a `onException` sequel
_ <- sequel
return r
回答这个问题将有助于我理解蒙版异步例外。我仍然无法很好地关联它。
I still can't wrap my head around masking asynchronous exceptions.
finally
in Control.Exception
masks the action:
a `finally` sequel =
mask $ \restore -> do
r <- restore a `onException` sequel
_ <- sequel
return r
What difference would it make if finally
internally doesn't mask?
a `finally` sequel = do
r <- a `onException` sequel
_ <- sequel
return r
Answering this question would help me understand masking asynchronous exceptions. I still can't relate to it quite well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
的目的最后
块是sequel
无论如何都将执行。如果a
被异步异常中断,则执行sequel
。如果续集
被异常中断怎么办?或者仅在a
和续集
之间提出例外?然后sexel
仍然需要完成运行。因此,在运行
a
本身时,在a
中掩盖异步异常。因此,如果在执行最后续集
执行期间的任何时候, sequel 将完全执行。只有a
可以被异常中断。The intent of a
finally
block is that thesequel
is executed no matter what. Ifa
is interrupted by an asynchronous exception, thensequel
is executed. What ifsequel
is interrupted by the exception? Or the exception is raised just betweena
andsequel
? Thensequel
still needs to finish running.Therefore asynchronous exceptions are masked in
a finally sequel
except while runninga
itself. Thussequel
will be fully executed if the exception is raised at any time during the execution ofa finally sequel
. Onlya
can be interrupted by the exception.