小编joh*_*hjs的帖子

`prompt/control` 和 `shift/reset` 之间的区别示例

我不确定我是否理解分隔延续运算符对prompt/controlreset/shift之间的区别。我了解一些基本的使用示例,但在这些示例中它们的行为是相同的。

\n

我在Dariusz Biernacki 和 Olivier Danvy 的“ On the Dynamic Extent of Delimited Continuations ”中找到了这个例子:

\n
reset\n  (fn () => shift (fn k => 10 + (k 100))\n          + shift (fn k\xe2\x80\x99 => 1))\n\nprompt \n  (fn () => control (fn k => 10 + (k 100))\n          + control (fn k\xe2\x80\x99 => 1))\n
Run Code Online (Sandbox Code Playgroud)\n

racket/control我已将其翻译成 Scheme 并使用该库在 Racket 中成功运行并获得了预期结果:

\n
(reset  (+ (shift   k  (+ 10 (k 100)))\n           (shift   kk 1))) \n   ;; ==> 11\n\n(prompt …
Run Code Online (Sandbox Code Playgroud)

scheme ml delimited-continuations

8
推荐指数
1
解决办法
881
查看次数

标签 统计

delimited-continuations ×1

ml ×1

scheme ×1