我遇到了一個使用call/cc解釋Continuations的片段。在下面提供的片段中,call/cc調用的fn的延續是整個let塊還是調用/ cc下面的行?也有人可以提供一個解釋,爲什麼不提供整個let塊作爲延續?什麼是呼叫/ cc在一個區塊的延續
#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)
我從例子中推斷出來。在'(+ 1(call/cc(lambda(k)(k 2)))3)'中,延續是'(fn [v](+ 1 v 2))'。但在'(let(bindings)'的情況下,延續是調用/ cc後語句的狀態,我想(我認爲我是對的)let(bindings)可以被重寫爲lambda()其中的代碼在一個do塊中,所以繼續是有效的調用/ cc之後的語句集合 – draklor40