“呼叫抄送” Scala 中的模式?
我找到了一篇很好的文章,关于使用当前延续进行调用
图案。据我了解,他们使用Scheme和无限延续
。文章中的模式可以在 Scala 中实现吗?有没有关于 Scala 中的分隔延续
模式的文章?
I found a good article, about call with current continuation
patterns. As I understand, they use Scheme and undelimited continuations
. Can the patterns from the article be implemented in Scala? Is there any article about delimited continuations
patterns in Scala ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,他们绝对可以。
callCC
在 Scala 中看起来像这样:其中
Cont
是一个捕获延续的数据结构:以下是如何使用它来模拟已检查异常:
您可以按如下方式调用此函数:
Yes, they absolutely can.
callCC
looks like this in Scala:Where
Cont
is a data structure that captures a continuation:Here's how you might use it to simulate checked exceptions:
You would call this function as follows:
Scala 有一个类型化分隔延续的实现,它过去随编译器和标准库一起提供,但已被提取到 外部模块从那时起就几乎烂掉了。这是一个巨大的耻辱,我鼓励任何对定界延续感兴趣的人通过使用和贡献它来表明他们关心它的存在。
Scala has an implementation of typed delimited continuations which used to be shipped with the compiler and standard library, but has been extracted to an external module and pretty much left to rot since then. It's a great shame, and I encourage anyone who's interested in delimited continuations to show that they care about its existence by using and contributing to it.