我遇到了一个使用 call/cc 解释 Continuations 的片段。在下面提供的代码段中,由 call/cc 调用的 fn 的延续是整个 let 块,还是 call/cc 下面的行?也有人可以解释为什么不提供整个 let 块作为延续?
#lang racket
(define resume-test-3 #f)
(define test-3 (lambda ()
; the let defines a variable i local to the lambda, and
; sets its value to 0
(let ((i 0))
;
(call/cc (lambda (k) (set! resume-test-3 k)))
;
; The next time the-continuation is called, we start here.
(displayln "I am back ")
(set! i (+ i 1))
; and return the value i
i
)
))
(test-3)
(resume-test-3)
(resume-test-3)