`最终``最后蒙版异步''例外

发布于 2025-02-05 05:43:16 字数 500 浏览 3 评论 0原文

我仍然无法将头缠绕在掩蔽中,以异步异常。

最后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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生殊途 2025-02-12 05:43:16

的目的最后块是sequel无论如何都将执行。如果a被异步异常中断,则执行sequel。如果续集被异常中断怎么办?或者仅在a续集之间提出例外?然后sexel仍然需要完成运行。

因此,在运行a本身时,在a中掩盖异步异常。因此,如果在执行最后续集执行期间的任何时候, sequel 将完​​全执行。只有a可以被异常中断。

The intent of a finally block is that the sequel is executed no matter what. If a is interrupted by an asynchronous exception, then sequel is executed. What if sequel is interrupted by the exception? Or the exception is raised just between a and sequel? Then sequel still needs to finish running.

Therefore asynchronous exceptions are masked in a finally sequel except while running a itself. Thus sequel will be fully executed if the exception is raised at any time during the execution of a finally sequel. Only a can be interrupted by the exception.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文